Repository navigation
feat: expose the running build's commit at GET /version - #1639
Merged
Merged
Conversation
Post-deploy smoke tests need to confirm the new revision is serving traffic
before testing it (az containerapp update returns before traffic shifts).
.git is excluded from the Docker build context, so the image could not know
which commit it was built from.
- Dockerfile: SOURCE_REVISION build arg -> -p:SourceRevisionId, so
AssemblyInformationalVersion becomes 1.0.0+<sha>. Declared after COPY . .
so restore layers stay cached.
- Workflow: pass SOURCE_REVISION=${{ github.sha }} to both image builds
(production imports the same image, so it reports the same commit).
- GET/HEAD /version returns {version, commit}: no-store, not rate limited,
excluded from tracing like /health and /alive. Not shown in the site UI.
Use HasJsonContent, IsValidJsonObject and JsonElement IsDeepEqualTo so a renamed or extra field in the /version payload fails the test.
BenjaminMichaelis
added a commit
that referenced
this pull request
Nov 15, 2026
## Why Production is currently promoted as soon as `deploy-development` finishes, even if dev is broken. `az containerapp update` also returns about 45 s **before** traffic shifts to the new revision. Builds on #1639 (`GET /version`). ## What New steps at the end of `deploy-development`: 1. **Wait for the new revision.** `scripts/wait-for-deployed-commit.sh` polls `https://dev.essentialcsharp.com/version` until it reports `github.sha` 3 times in a row (10-minute timeout). The URL can be overridden with `vars.SITE_BASE_URL`. On timeout it prints `az containerapp revision list`. 2. **Smoke test.** `dotnet test` runs the new `EssentialCSharp.Web.E2ETests` project filtered to `[Category=Deployed]`. TRX results are uploaded on failure. The steps run **inside** `deploy-development`, not in a separate job, so they hold its concurrency group, and the next push can't swap the dev image mid-test. `deploy-production` already `needs` this job, so a failed smoke run blocks promotion. Dev keeps the failed build until the next push; there is no automatic rollback. ### Checks (anonymous, read-only apart from one form post per provider) | Check | Catches | |---|---| | `/health`, `/alive` return 200 | App is up | | `/version` commit equals `github.sha` | Testing the right build | | `/home` renders, and its canonical link uses the deployed origin | `SiteSettings:BaseUrl` misconfiguration | | Sitemap has more than 100 pages, all on the deployed host, and a chapter page renders | Image built without book content, broken content routing | | Login page has the hCaptcha site key and GitHub/Microsoft buttons | Captcha or external login config missing (captcha fails closed) | | `POST /Identity/Account/ExternalLogin` for GitHub and Microsoft returns 302 to the provider's authorize endpoint with `client_id` and `redirect_uri=<site>/signin-<provider>` | Provider registration, client id, callback/forwarded-headers config | The full OAuth round trip, secrets and consent are out of scope. Logged-in flows (login and AI chat) will follow separately. They need a dev test account and a captcha decision first. ### Safety and robustness - Tests **skip** unless `E2E_BASE_URL` or `E2E_EXPECTED_COMMIT` is set, so the normal 3-OS PR test run is unaffected. If either is set, the tests always run, so a malformed URL fails the gate instead of skipping everything and passing. - Each request is retried once on 429, 5xx, a connection error or a timeout. - Each run makes about 13 requests. Only 2 count against the content limiter (20/hour per IP for anonymous users). `/health`, `/alive` and `/version` are exempt. ## Verification - Ran the deployed tests against real dev before #1639 deployed: 7/8 passed. `/version` returned 302 because that build predates it, which is expected. After this merges, the deploy will include `/version`. - Exercised the wait script locally against a fake `/version` for success, wrong-commit timeout, unreachable host (the curl error is shown) and missing `jq`. - Unset variables give 8 skipped tests. A malformed `E2E_BASE_URL` makes all 8 fail with a clear message.
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.
Why
This is groundwork for post-deploy smoke tests that will gate production.
az containerapp updatereturns about 45 s before traffic shifts to the new revision, so a smoke test that starts right away would test the old build. Today the site can't say which commit it is running..gitis excluded from the Docker build context, and nothing passes the SHA in.What
SOURCE_REVISIONbuild arg is passed todotnet buildas-p:SourceRevisionId, soAssemblyInformationalVersionbecomes1.0.0+<sha>.COPY . ., so restore layers stay cached. EveryRUNafter anARGimplicitly uses it.SOURCE_REVISION=${{ github.sha }}to both image builds.deploy-productionimports the same image from dev ACR, so prod reports the same commit.GET/HEAD /versionreturns{ "version": "1.0.0+<sha>", "commit": "<sha>" }.Cache-Control: no-store, is not rate limited, and is excluded from tracing like/healthand/alive.deployed/prod/<sha>tags./versionworks underdotnet runand Aspire too.Tests
VersionEndpointTests:no-store.HEADreturns 200.BuildInfoparsing cases.GITHUB_ACTIONS=true) that the build is stamped withGITHUB_SHA. I simulated it locally: it passes with HEAD and fails with a wrong SHA.All 202 Web tests pass locally.
I did not run a real
docker buildlocally. Building with-p:SourceRevisionId=deadbeefcafeproduced1.0.0+deadbeefcafe. The container-validation job builds the image, and the upcoming dev smoke step will assert that/version's commit equalsgithub.sha.