Skip to content

feat(ci): automate OpenAPI spec sync from backend (ADR 0020)#222

Merged
vredchenko merged 1 commit into
mainfrom
feat/openapi-spec-sync-pipeline
Jun 2, 2026
Merged

feat(ci): automate OpenAPI spec sync from backend (ADR 0020)#222
vredchenko merged 1 commit into
mainfrom
feat/openapi-spec-sync-pipeline

Conversation

@vredchenko
Copy link
Copy Markdown
Collaborator

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.

  • ADR 0020docs/decision-records/decisions/0020-openapi-spec-pipeline-and-version-compatibility.md (+ index entry).
  • sync-openapi-spec.yml — on repository_dispatch (openapi-spec-updated) from smartem-decisions, or manual workflow_dispatch, or a daily fallback schedule: downloads the canonical spec, refreshes docs/api/smartem/swagger.json + webui/public/api/smartem/swagger.json, commits, and rebuilds Pages.
  • deploy-webui.yml — made reusable (workflow_call + ref input) so the sync deploys the freshly-synced commit (sidesteps the GITHUB_TOKEN-push-doesn't-trigger rule).
  • Docs + Claude config alignmentARCHITECTURE.md, both REPO-GUIDELINES.md, CLAUDE.md, docs/development/tools.md, docs/backend/api-documentation.md updated to describe the pipeline (the spec is no longer hand-maintained here).

Companion PRs (merge together)

  • smartem-decisions#XXX — publisher: commits docs/api/openapi.json, dispatches here, adds /version.
  • smartem-frontend#XXX — consumer: observe-only semantic version check, api:fetch repointed at the canonical backend spec.

Action required after merge

  • Add the DEVTOOLS_DISPATCH_TOKEN secret in smartem-decisions (fine-grained PAT, Contents: write on this repo, or a GitHub App). Until then the backend warns and the sync still runs via workflow_dispatch/schedule.
  • Once the backend PR is merged (so docs/api/openapi.json exists on its main), run this repo's Sync OpenAPI spec from backend workflow once via workflow_dispatch to seed the caches.

Partially addresses #8 (consolidate API specs).

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.
@github-actions github-actions Bot added documentation Improvements or additions to project documentation devops CI/CD, deployment, infrastructure, or tooling work smartem-devtools:claude Claude Code configuration, skills, and prompts labels Jun 1, 2026
@vredchenko
Copy link
Copy Markdown
Collaborator Author

Companion PRs: backend DiamondLightSource/smartem-decisions#292 (canonical publisher + /version), frontend DiamondLightSource/smartem-frontend#109 (observe-only version check). Merge together.

@vredchenko vredchenko merged commit 4e88b7a into main Jun 2, 2026
8 checks passed
@vredchenko vredchenko deleted the feat/openapi-spec-sync-pipeline branch June 2, 2026 16:19
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

devops CI/CD, deployment, infrastructure, or tooling work documentation Improvements or additions to project documentation smartem-devtools:claude Claude Code configuration, skills, and prompts

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant