feat: expose running CalVer version via API (#126) #127
No reviewers
Labels
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: cal/major-domo-database#127
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "issue/126-feat-expose-running-calver-version-via-api"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #126
Summary
Implements all three approaches from the issue to make the running CalVer version discoverable without cross-referencing timestamps:
1. Build arg → env var (Dockerfile + CI)
Dockerfile:ARG BUILD_VERSION=devbaked intoENV APP_VERSION=$BUILD_VERSION— readable at runtime viaos.environ.get("APP_VERSION")build-args: BUILD_VERSION=${{ steps.version.outputs.version }}passed todocker/build-push-action— CI already extracts the version from the git tag, now it flows through to the image2. OCI image label (Dockerfile)
LABEL org.opencontainers.image.version=$BUILD_VERSION— visible viadocker inspectwithout running the container3.
/healthendpoint (app/main.py)GET /healthreturns{"status": "ok", "version": "2026.4.1"}— single API call to get the running versionDockerfileHEALTHCHECK from/api/v3/current(SQL query) to/health(no SQL, lightweight)"dev"whenAPP_VERSIONis not setFiles Changed
Dockerfile— build arg, OCI label, env var, HEALTHCHECK URL.gitea/workflows/docker-build.yml— passesBUILD_VERSIONbuild-argapp/main.py— addsGET /healthendpointOther observations
main.pyhas a duplicatedb_connection_middlewaredefinition (lines 74 and 88) — the second shadows the first. Pre-existing, out of scope.main.pyhas unused imports (datetime,Depends). Pre-existing, out of scope.AI Code Review
Files Reviewed
Dockerfile(modified).gitea/workflows/docker-build.yml(modified)app/main.py(modified)Findings
Correctness
No issues found.
ARG BUILD_VERSION=dev→ENV APP_VERSION=$BUILD_VERSIONis correct Dockerfile syntax.ARGvalue is in scope for bothLABELandENVinstructions in the same stage.LABEL org.opencontainers.image.version=$BUILD_VERSIONbakes the value at image build time — correct./api/v3/currentto/healthis consistent with the new endpoint.build-args: BUILD_VERSION=${{ steps.version.outputs.version }}correctly passes the CalVer tag (ordev) through to the image. Fordevtag pushes,versionoutput isdev, which matches the Dockerfile default — harmless redundancy.os.environ.get("APP_VERSION", "dev")inmain.pyis safe.osis already imported at line 4./healthendpoint is defined after all router includes (line 139+), avoiding any routing conflicts with the existing prefix-based API routes.Security
No issues found. Version disclosure via
/healthis intentional and consistent with the feature's purpose. No user input flows into the endpoint.Style & Conventions
/healthendpoint. The endpoint is trivial (env var read + dict return) so this is acceptable, but a basic integration test confirming the response shape would be consistent with the existing test suite.Suggestions
GET /healthreturning{"status": "ok"}and updates the Dockerfile HEALTHCHECK from/api/v3/currentto/health. If #125 merges before #127, this PR will have a conflict on both files. Consider coordinating merge order or superseding #125 with this PR (since #127 is a strict superset of #125's/healthwork).main.pyline 87: duplicatedb_connection_middlewareregistration (pre-existing, out of scope per PR body — noted for awareness).Verdict: COMMENT
Implementation is correct and complete. All three approaches (build-arg env var, OCI label,
/healthendpoint) are properly wired end-to-end. Only non-blocking observation is the potential merge conflict with PR #125. Approved — Gitea blocks self-review.Automated review by Claude PR Reviewer
9249cb06f0to4acf7b2afa