Skip to content

ci: smoke test dev after deploy and gate production on it - #1642

Merged
BenjaminMichaelis merged 3 commits into
mainfrom
feat/dev-smoke-gate
Nov 15, 2026
Merged

BenjaminMichaelis merged 3 commits into
mainfrom
feat/dev-smoke-gate

Conversation

@BenjaminMichaelis

Copy link
Copy Markdown
Member

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 feat: expose the running build's commit at GET /version #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.

deploy-development now waits until https://dev.essentialcsharp.com/version
reports the deployed commit (az containerapp update returns before traffic
shifts), then runs anonymous smoke tests from the new
EssentialCSharp.Web.E2ETests project. They run inside the deploy job so they
hold its concurrency group, and deploy-production needs this job, so a
failure blocks promotion.

Checks: /health and /alive, /version commit, home page and canonical origin,
sitemap lists the full book and a chapter renders, login page captcha and
external providers, and GitHub/Microsoft external login redirects carry a
client id and the deployed callback. Tests skip unless E2E_BASE_URL or
E2E_EXPECTED_COMMIT is set, and fail (rather than skip) on a malformed URL.
Use a non-null DeployedSite.RequiredBaseUrl (throws a descriptive error when
E2E_BASE_URL is missing or malformed) and the value returned by TUnit's
IsNotNull() instead of '!'.
Replace the hand-rolled retry helper with a ResilienceHandler built from
HttpRetryStrategyOptions (one retry; 5xx, 408, 429, connection errors and
per-attempt timeouts are transient; Retry-After honoured, capped at 30s).
Other statuses, including the redirects the tests assert on, return on the
first attempt. Same package the web app already uses for its HttpClients.
@BenjaminMichaelis
BenjaminMichaelis merged commit aad1787 into main Nov 15, 2026
14 checks passed
@BenjaminMichaelis
BenjaminMichaelis deleted the feat/dev-smoke-gate branch November 15, 2026 05:06
BenjaminMichaelis added a commit that referenced this pull request Nov 15, 2026
…#1643)

## Why

#1642 made the deployed smoke tests a gate on each dev deploy. Some
breakage happens **without a deploy**: expiring secrets or Key Vault
access, external-login app settings, content, or the site going down.
Nothing would notice those until the next push.

## What

- **`Scheduled-Smoke-Test-Development.yml`** runs the same
`[Category=Deployed]` tests against dev every 6 hours (`17 */6 * * *`)
and on `workflow_dispatch`.
- No expected commit, because dev may run any recent build between
deploys. `/version` must still answer with a commit.
  - TRX results are uploaded on failure.
- The workflow has its own concurrency group. It deliberately doesn't
share `deploy-development`: a queued run in a shared group would replace
a pending deployment.
- **`scripts/report-scheduled-smoke-result.sh`** keeps one
`smoke-test-failure` issue (the label is created on first use):

  | Situation | Action |
  |---|---|
| One failure (the previous pass/fail run succeeded) | `::warning::`
only, since one blip isn't an incident |
  | Second failure in a row | Open the issue |
| Still failing with an issue open | **Edit** the issue body with the
latest run (no notification every 6 h) |
  | A run passes with an issue open | Comment and close |
  | Cancelled | Nothing |

- A setup failure (checkout or .NET) counts as a failure, so the
reported outcome matches the run conclusion that the next run reads.
  - Cancelled and skipped runs don't break a failure streak.
- If the open-issue lookup fails, the step fails rather than treating it
as "no issue", which would risk duplicates.
  - Reporting only happens from `main`.

GitHub only emails the last person who edited a scheduled workflow, so
the issue is what makes failures visible to everyone.

## Cost and limits

Each run makes about 13 requests to dev, and 2 of them count against the
anonymous content limit (20/hour per IP). Each run takes about 2 minutes
on `ubuntu-latest`.

## Verification
- Every reporting branch tested in `DRY_RUN=true` with a fake `gh`:
open, update, close, warn, cancelled, and lookup error (the step fails).
- The real read-only `gh issue list` and `gh run list` queries were
dry-run against this repo.
- The smoke tests pass 8/8 against dev in the scheduled configuration
(no expected commit).
- **Not yet exercised:** the cron trigger and real issue creation. After
merge, start a run with **Actions → Scheduled smoke test (Development) →
Run workflow**.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant