feat(ci): automate OpenAPI spec sync from backend (ADR 0020)#222
Merged
Conversation
Add ADR 0020 (OpenAPI spec pipeline and version compatibility) and the receiver side of the pipeline: a `Sync OpenAPI spec from backend` workflow that, on a repository_dispatch from smartem-decisions (or manual/scheduled fallback), refreshes the committed swagger caches and rebuilds Pages by calling deploy-webui as a reusable workflow (workflow_call with a ref input, so it deploys the freshly-synced commit). Align docs and Claude Code guidance with the new flow: smartem-decisions is the canonical spec publisher; the devtools and frontend specs are downstream caches; the frontend's version check becomes semantic and observe-only.
Collaborator
Author
|
Companion PRs: backend DiamondLightSource/smartem-decisions#292 (canonical publisher + |
vredchenko
added a commit
to DiamondLightSource/smartem-frontend
that referenced
this pull request
Jun 2, 2026
## Summary Implements the **frontend side** of ADR 0020 (DiamondLightSource/smartem-devtools#222): finishes the backend-compatibility check and points the client at the canonical spec source. - **Boot-time check wired into `apps/smartem/src/main.tsx`** (live mode only) — queries the backend `/version` endpoint and compares it **semantically** (release portion, ignoring the `dev+sha` suffix) to the version the client was built against. Logs always; shows a **non-blocking dev banner** on drift. **Never enforced** — rolling deploys that momentarily differ don't break the app. - **`version-check.ts` rewritten** — fetches `/version` (was `/openapi.json`), semantic compare (was exact-string, which false-alarmed on every commit). Same exported surface, so the legacy `ApiVersionCheck` still builds. - **`api:fetch` repointed** — pulls the canonical spec from smartem-decisions (`docs/api/openapi.json`) instead of the stale devtools Pages copy. `npm run api:update` is now safe and canonical. ## Notes - The committed `openapi.json` is unchanged here (still has the endpoints from #108). Once the backend PR merges and publishes, a routine `npm run api:update` refreshes it; until then the observe-only check simply notes the client is slightly behind — which is honest and non-blocking. ## Companion PRs (merge together) - DiamondLightSource/smartem-decisions#292 — `/version` endpoint + canonical publisher. - DiamondLightSource/smartem-devtools#222 — ADR 0020 + sync pipeline. ## Test plan - [x] `npm run typecheck` clean - [x] `npx biome check` clean on touched files (+ lefthook) - [x] `npm run build:smartem` succeeds Closes #93.
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.
Summary
Implements the devtools side of ADR 0020 (added here): the SmartEM OpenAPI spec pipeline. smartem-decisions becomes the canonical publisher; this repo's swagger copies become auto-refreshed downstream caches.
docs/decision-records/decisions/0020-openapi-spec-pipeline-and-version-compatibility.md(+ index entry).sync-openapi-spec.yml— onrepository_dispatch(openapi-spec-updated) from smartem-decisions, or manualworkflow_dispatch, or a daily fallback schedule: downloads the canonical spec, refreshesdocs/api/smartem/swagger.json+webui/public/api/smartem/swagger.json, commits, and rebuilds Pages.deploy-webui.yml— made reusable (workflow_call+refinput) so the sync deploys the freshly-synced commit (sidesteps theGITHUB_TOKEN-push-doesn't-trigger rule).ARCHITECTURE.md, bothREPO-GUIDELINES.md,CLAUDE.md,docs/development/tools.md,docs/backend/api-documentation.mdupdated to describe the pipeline (the spec is no longer hand-maintained here).Companion PRs (merge together)
docs/api/openapi.json, dispatches here, adds/version.api:fetchrepointed at the canonical backend spec.Action required after merge
DEVTOOLS_DISPATCH_TOKENsecret in smartem-decisions (fine-grained PAT,Contents: writeon this repo, or a GitHub App). Until then the backend warns and the sync still runs viaworkflow_dispatch/schedule.docs/api/openapi.jsonexists on itsmain), run this repo'sSync OpenAPI spec from backendworkflow once viaworkflow_dispatchto seed the caches.Partially addresses #8 (consolidate API specs).