feat: add JSON /version/ build-info endpoint (#1366)#1369
Merged
Conversation
Expose the running code version as machine-readable JSON at /version/ (and /version.json) so we can confirm what code a server is actually deploying without fetching a full page and scraping the HTML comment in base.html. - New website/views/version.py: returns version/description/environment from settings plus git_sha + built_at read from a build-info file (fallback "unknown"). Sets Cache-Control: no-store so no proxy serves a stale string. - docker-entrypoint.sh captures `git rev-parse --short HEAD` + an ISO-8601 timestamp into a gitignored build-info.json once at container start, so the view never shells out to git per request and git isn't needed at runtime. - URL routes for /version/ and /version.json; gitignore build-info.json. - Regression tests for routing, payload-from-settings, no-store header, and the build-info read / missing-file "unknown" fallback. - Bump ML_WEBSITE_VERSION to 2.17.0. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1366.
What
Adds an unauthenticated, machine-readable build-info endpoint so we can confirm what code a server is actually running without fetching a full page and scraping the
<!-- Makeability Lab website version ... -->comment inbase.html. This is option (b) Full from the issue.How
website/views/version.py—version()view.version/description/environmentcome fromsettings.py;git_sha/built_atare read from a build-info file (falls back to"unknown"if absent, e.g. local dev). SetsCache-Control: no-storeso Apache/any proxy can't serve a stale version string. No per-requestgitshell-out.docker-entrypoint.sh— one early step writesbuild-info.jsonfromgit rev-parse --short HEAD+date --iso-8601=secondsat container start. The servers deploy via git so.gitis present; gracefully falls back to"unknown"if git is unavailable. This means git isn't needed in the runtime image.website/urls.py— routes/version/and/version.jsonto the view..gitignore— ignores the per-deploybuild-info.json.ML_WEBSITE_VERSION→2.17.0.Design notes
version/description— both already public via the HTML comment.git_sha+built_atare what actually answer "is prod stale?" — a bumped tag that never deployed shows an old SHA/timestamp at a glance./healthz-style building block if we later want uptime/version monitoring.Tests
website/tests/test_version_endpoint.py(6 tests): routing for both URLs, payload-from-settings,no-storeheader, build-info read from file, and the missing-file"unknown"fallback. All pass; smoke/view suites still green.curl /version/and/version.jsonboth return the JSON withCache-Control: no-store; the entrypoint snippet produces real values in-container.🤖 Generated with Claude Code