Skip to content

Commit

Permalink
Add image name and system architecture to usage report
Browse files Browse the repository at this point in the history
  • Loading branch information
Floppy committed Nov 21, 2024
1 parent 8b7946b commit 5517876
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ jobs:
build-args: |
APP_VERSION=${{ steps.docker_meta.outputs.version }}
GIT_SHA=${{ github.sha }}
DOCKER_TAG=${{ steps.docker_meta.outputs.tags }}
solo:
runs-on: ubuntu-latest
Expand Down
2 changes: 2 additions & 0 deletions app/lib/usage_report.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ def self.generate
report.version do |version|
version.app Rails.application.config.app_version
version.sha Rails.application.config.git_sha
version.image ENV.fetch("DOCKER_TAG", nil)&.split(":")&.first
end
report.arch RUBY_PLATFORM
end
end

Expand Down
2 changes: 2 additions & 0 deletions docker/runtime.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,10 @@ ENV RUBY_YJIT_ENABLE="1"

ARG APP_VERSION
ARG GIT_SHA
ARG DOCKER_TAG
ENV APP_VERSION=$APP_VERSION
ENV GIT_SHA=$GIT_SHA
ENV DOCKER_TAG=$DOCKER_TAG

# Runtime environment variables
ENV PORT=3214
Expand Down
17 changes: 17 additions & 0 deletions spec/lib/usage_report_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,27 @@
expect(parsed["id"]).to eq "guid-goes-here"
end

it "includes architecture" do
stub_const("RUBY_PLATFORM", "test-arch")
expect(parsed["arch"]).to eq "test-arch"
end

it "includes application version" do
expect(parsed["version"]["app"]).to eq "test"
end

it "includes image type" do
ClimateControl.modify DOCKER_TAG: "ghcr.io/manyfold3d/manyfold:latest" do
expect(JSON.parse(described_class.generate)["version"]["image"]).to eq "ghcr.io/manyfold3d/manyfold"
end
end

it "works if there is no image type" do
ClimateControl.modify DOCKER_TAG: nil do
expect(JSON.parse(described_class.generate)["version"]["image"]).to be_nil
end
end

it "includes git SHA" do
expect(parsed["version"]["sha"]).to eq "deadbeef"
end
Expand Down

0 comments on commit 5517876

Please sign in to comment.