Repository navigation
chore(approvals): merge main into the approvals trunk (#38497 refresh) #3622
Workflow file for this run
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
| # Scaffold E2E — the first-run experience as a regression gate (#2908). | |
| # | |
| # Two failure classes broke `npm create objectstack` in the past and neither | |
| # was visible to unit tests: | |
| # 1. The bundled template drifted from the published framework (pinned | |
| # ^6.0.0 while the registry was at 14.x; used APIs removed in 14.x). | |
| # 2. Nothing ever exercised the published package end-to-end, so registry | |
| # breakage would only be found by a real new user. | |
| # | |
| # Job 1 (PRs touching the scaffolder / docker example) scaffolds with the repo-built | |
| # scaffolder and runs the generated project against this checkout's packed tarballs, not | |
| # the registry: install → validate → build → test → boot → health probes → docker. That | |
| # run scaffolds with `--skip-install` and installs the project itself, so it | |
| # exercises the scaffolder's `--skip-install` shape; a second, throwaway | |
| # project is scaffolded WITHOUT it purely to assert the shape a real user | |
| # ships (the pinned Dockerfile — see that step for why the split exists). | |
| # Job 2 (nightly) does the same via the *published* `create-objectstack@latest` | |
| # across every template in the registry — the new-user canary. | |
| # | |
| # Every step below is part of an install/build/boot/docker pipeline, not a named local | |
| # verification script a dev pre-runs with `pnpm check:x` — there is no check family here | |
| # to discover, deliberately (#9187): | |
| # dispatch-gates: no-check-families -- steps are an e2e pipeline, not named local checks | |
| name: Scaffold E2E | |
| on: | |
| pull_request: | |
| paths: | |
| - 'packages/create-objectstack/**' | |
| - 'docker/**' | |
| - '.github/workflows/scaffold-e2e.yml' | |
| schedule: | |
| - cron: '23 3 * * *' | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| # A newer run for the same pull request supersedes this one, so the older run is | |
| # cancelled. The group key is ci.yml's shape; `cancel-in-progress` is true only on | |
| # `pull_request`, so no other event's run is ever cancelled. The schedule and dispatch | |
| # runs share a group keyed on their own event and wait for each other instead. | |
| concurrency: | |
| group: scaffold-e2e-${{ github.workflow }}-${{ github.event_name }}-${{ github.event.pull_request.number || github.event.after || github.ref }} | |
| cancel-in-progress: ${{ github.event_name == 'pull_request' }} | |
| jobs: | |
| scaffold-local: | |
| name: Scaffold with repo dist | |
| if: github.event_name != 'schedule' | |
| runs-on: ubuntu-latest | |
| # Raised from 20 for what the tarball install adds to the old leg: the | |
| # framework closure build, packing every publishable package, and three | |
| # image builds (the official one, the scaffolded build stage, the | |
| # candidate layer). | |
| timeout-minutes: 45 | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v7 | |
| - name: Setup workspace | |
| uses: ./.github/actions/setup-workspace | |
| - name: Setup turbo cache | |
| uses: actions/cache@v6 | |
| with: | |
| path: .turbo/cache | |
| key: ${{ runner.os }}-turbo-${{ github.job }}-${{ github.sha }} | |
| restore-keys: | | |
| ${{ runner.os }}-turbo-${{ github.job }}- | |
| ${{ runner.os }}-turbo- | |
| - name: Build the scaffolder | |
| run: pnpm --filter create-objectstack build | |
| - name: Scaffold a project | |
| run: | | |
| cd "$RUNNER_TEMP" | |
| node "$GITHUB_WORKSPACE/packages/create-objectstack/bin/create-objectstack.js" e2e-app --skip-install --skip-skills | |
| # The project is installed from THIS checkout's packed tarballs, so every | |
| # package it reaches must be built before it is packed. The build set is | |
| # read off the project the scaffolder just emitted, never a hand list: | |
| # each `@objectstack/*` dependency it declares, with turbo's `^build` | |
| # bringing that package's own workspace dependencies along. A package | |
| # outside that closure is still packed (the pin set must stay total, see | |
| # scripts/publish-smoke-pack.mjs) but nothing installs it. | |
| - name: Build the framework the generated project depends on | |
| run: | | |
| FILTERS=$(node -p ' | |
| const pkg = require(process.env.RUNNER_TEMP + "/e2e-app/package.json"); | |
| const names = [pkg.dependencies, pkg.devDependencies] | |
| .flatMap((deps) => Object.keys(deps ?? {})) | |
| .filter((name) => name.startsWith("@objectstack/")); | |
| if (names.length === 0) throw new Error("the generated project declares no @objectstack/* dependency — nothing to build or to test"); | |
| names.map((name) => "--filter=" + name).join(" "); | |
| ') | |
| echo "turbo run build $FILTERS" | |
| # shellcheck disable=SC2086 # FILTERS is a word list on purpose. | |
| pnpm exec turbo run build $FILTERS | |
| # `pnpm pack` applies the same manifest rewrites as `pnpm publish`, so a | |
| # tarball is what the registry would hand a new user once this checkout | |
| # is released. The packer is shared with scripts/create-scaffold-smoke.sh | |
| # (`os-create-smoke.yml`) and the release smoke: it owns the publishable | |
| # population and writes the name → `file:` tarball map the next step pins. | |
| - name: Pack this checkout's publishable packages | |
| run: node scripts/publish-smoke-pack.mjs "$RUNNER_TEMP/tarballs" | |
| # The generated project's dependency SPECS are left exactly as the | |
| # scaffolder wrote them — they are what is on trial. Resolution is | |
| # redirected through the project's OWN pnpm overrides, appended to the | |
| # pnpm-workspace.yaml the template ships (its build approvals are part of | |
| # what a user gets, so they stay part of what is tested). Anything not in | |
| # the map — typescript, vitest, every third-party transitive — resolves | |
| # from the registry, as it would for a user. | |
| # | |
| # There is no registry fallback and no `engines.protocol` re-stamp: the | |
| # project is tested at the version this checkout would publish, against | |
| # the protocol this checkout implements. A red here is a red about what | |
| # the next release would ship. | |
| - name: Install generated project (this checkout's packed tarballs) | |
| run: | | |
| cd "$RUNNER_TEMP/e2e-app" | |
| node - "$RUNNER_TEMP/tarballs/overrides.json" pnpm-workspace.yaml <<'EOF' | |
| const { existsSync, readFileSync, writeFileSync } = require('node:fs'); | |
| const [overridesPath, wsPath] = process.argv.slice(2); | |
| if (!existsSync(wsPath)) { | |
| console.log('::error::the scaffolder wrote no pnpm-workspace.yaml, so there is nowhere to pin the packed tarballs (and a fresh pnpm install would refuse the build scripts the template relies on)'); | |
| process.exit(1); | |
| } | |
| const overrides = JSON.parse(readFileSync(overridesPath, 'utf8')); | |
| const lines = [ | |
| readFileSync(wsPath, 'utf8').replace(/\s*$/, ''), | |
| '', | |
| '# appended by scaffold-e2e.yml: every publishable package of the checkout', | |
| '# redirected to its packed tarball; package.json is left as scaffolded.', | |
| 'overrides:', | |
| ...Object.entries(overrides).map(([name, spec]) => ` '${name}': '${spec}'`), | |
| ]; | |
| writeFileSync(wsPath, lines.join('\n') + '\n'); | |
| console.log(`pinned ${Object.keys(overrides).length} package(s) to packed tarballs in ${wsPath}`); | |
| EOF | |
| pnpm install --no-frozen-lockfile | |
| # Every @objectstack/* name the project declares must resolve from a | |
| # tarball. A pinned name that resolved from the registry tested | |
| # PUBLISHED code; a declared name that resolved from neither means the | |
| # lockfile shape this reads has moved — both red, by name. | |
| node - "$RUNNER_TEMP/tarballs/overrides.json" <<'EOF' | |
| const { readFileSync } = require('node:fs'); | |
| const names = Object.keys(JSON.parse(readFileSync(process.argv[2], 'utf8'))); | |
| const pkg = JSON.parse(readFileSync('package.json', 'utf8')); | |
| const declared = [pkg.dependencies, pkg.devDependencies] | |
| .flatMap((deps) => Object.keys(deps ?? {})) | |
| .filter((name) => name.startsWith('@objectstack/')); | |
| const lock = readFileSync('pnpm-lock.yaml', 'utf8').split(/\r?\n/); | |
| const esc = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); | |
| const pinned = new Set(); | |
| const leaked = new Set(); | |
| for (const name of names) { | |
| const key = new RegExp(`^\\s*'?${esc(name)}@([^']+?)'?:\\s*$`); | |
| for (const line of lock) { | |
| const m = key.exec(line); | |
| if (!m) continue; | |
| if (m[1].startsWith('file:')) pinned.add(name); | |
| else if (/^[0-9]/.test(m[1])) leaked.add(`${name}@${m[1]}`); | |
| } | |
| } | |
| const unpinned = declared.filter((name) => !pinned.has(name)); | |
| if (leaked.size > 0 || unpinned.length > 0) { | |
| for (const l of [...leaked].sort()) console.log(`::error::resolved from the registry, not from its tarball: ${l}`); | |
| for (const n of unpinned) console.log(`::error::declared by the generated project but not resolved from a tarball: ${n}`); | |
| process.exit(1); | |
| } | |
| console.log(`${pinned.size} package(s) resolved from packed tarballs, 0 from the registry; all ${declared.length} declared @objectstack/* dependencies among them`); | |
| EOF | |
| - name: Validate and build the generated project | |
| run: | | |
| cd "$RUNNER_TEMP/e2e-app" | |
| npm run validate | |
| npm run build | |
| # The starter's own test (`starter.test.ts`): it boots the generated | |
| # project's stack in-process through @objectstack/verify, as installed | |
| # from this checkout's packed tarballs, and asserts one business fact on | |
| # the real engine. | |
| # A scaffold whose `test` script is red out of the box teaches its user | |
| # to ignore tests, so the starter ships it green or not at all. | |
| - name: Test the generated project | |
| run: | | |
| cd "$RUNNER_TEMP/e2e-app" | |
| npm test | |
| # Two questions this step must answer about its own server, and used to | |
| # answer neither (#9779). Both belong here rather than in the CLI: `os | |
| # start` is already correct — the shell around it was not. | |
| # | |
| # 1. IS ANYTHING ALREADY SERVING 8080, BEFORE WE BOOT ANYTHING? | |
| # `os start` is a PRODUCTION boot. packages/cli/src/commands/serve.ts | |
| # gates its port auto-shift on `flags.dev || NODE_ENV === 'development'` | |
| # and `start` spawns `serve` with neither (start.ts forces | |
| # NODE_ENV=production when the caller has not set it). Measured on this | |
| # checkout, a neighbouring server holding the requested port: | |
| # | |
| # $ os start --port 38200 # neighbour already on 38200 | |
| # ✗ Port 38200 is already in use. | |
| # ObjectStack does not auto-select a different port in production | |
| # $ echo $? | |
| # 1 | |
| # $ os start --port 38500 # nothing on 38500 | |
| # ✓ Server is ready → http://localhost:38500/ (stays up, 200s) | |
| # | |
| # So this step's server NEVER drifts to another port — it binds 8080 or | |
| # it dies. That is exactly what makes the WAIT LOOP the whole defect, | |
| # and it is why neither sibling fix filed alongside this one transfers: | |
| # there is no shifted port to read back (#9647) and no `--strictPort` to | |
| # ask for (#9578), because the CLI already behaves as if it had one. | |
| # The neighbour simply keeps answering 8080. Measured with the previous | |
| # block verbatim: the loop took its 200 on iteration 1 after 0s, then | |
| # asserted /api/v1/ready against the NEIGHBOUR's app, and `kill | |
| # "$SERVER_PID"` succeeded against our own `os start` — still booting, | |
| # not yet dead. Exit 0, on an app this job never started. | |
| # | |
| # A liveness check ALONE does not catch that: through the window that | |
| # decides the run, our process is genuinely alive. The one question that | |
| # separates the two worlds is whether something was already answering | |
| # the exact URL the loop accepts as proof — so that is asked first. | |
| # | |
| # 2. IS OUR OWN SERVER STILL ALIVE? | |
| # `os start` exits 1 on a busy port, an unreadable artifact, or any boot | |
| # failure. Unasked, the loop burns its full 60s and then reports only | |
| # "never became healthy" — the slowest, vaguest form of a fact the | |
| # process table had at second 2. | |
| # | |
| # The PORTS STAY FIXED, on purpose. Every `runs-on:` in this repo is | |
| # `ubuntu-latest` — one fresh VM per job — so no two CI jobs of this | |
| # workflow, or of any other, can share 8080. Per-run ports would trade a | |
| # readable literal for machinery that buys nothing on the runner this | |
| # actually runs on. The two guards are for the shared-namespace replay: | |
| # a self-hosted runner, or a developer running this block by hand in an | |
| # agent dispatch container. Deliberately still open at that grade: a | |
| # neighbour arriving AFTER the pre-flight and before our own bind. Closing | |
| # it needs an affirmative "our server bound" signal — the runtime state | |
| # file serve.ts publishes under OS_HOME — which is what to reach for if | |
| # this workflow ever moves onto a runner it shares. | |
| - name: Boot from the artifact and probe health | |
| run: | | |
| cd "$RUNNER_TEMP/e2e-app" | |
| if curl -fsS http://localhost:8080/api/v1/health > /dev/null 2>&1; then | |
| echo "::error::something is already serving http://localhost:8080/api/v1/health before this step booted anything — every probe below would assert against it, not against the app this job scaffolded" | |
| exit 1 | |
| fi | |
| npx os start --artifact ./dist/objectstack.json --port 8080 > server.log 2>&1 & | |
| SERVER_PID=$! | |
| ok="" | |
| for i in $(seq 1 30); do | |
| if ! kill -0 "$SERVER_PID" 2>/dev/null; then | |
| echo "::error::the server this step started exited before becoming healthy"; cat server.log; exit 1 | |
| fi | |
| if curl -fsS http://localhost:8080/api/v1/health > /dev/null 2>&1; then ok=1; break; fi | |
| sleep 2 | |
| done | |
| if [ -z "$ok" ]; then | |
| echo "::error::server never became healthy"; cat server.log; exit 1 | |
| fi | |
| curl -fsS http://localhost:8080/api/v1/ready | |
| kill "$SERVER_PID" | |
| - name: 'Skills boundary: only the curated skills/ catalog installs' | |
| # 15.1 third-party eval: the repo-internal dogfood-verification skill | |
| # (.claude/skills/) leaked into scaffolded projects. The scaffolder no | |
| # longer reads GitHub — it syncs the installed @objectstack/skills | |
| # package, asserted by the step after the pinned shape below — so | |
| # these two assertions now guard the GitHub path the docs keep as the | |
| # `next` channel, against THIS checkout: | |
| # 1. The documented command is `skills add …/objectstack/skills …` — | |
| # the /skills subpath is the hard boundary, because the skills | |
| # CLI's --all implies --skill '*' which INCLUDES | |
| # metadata.internal skills. Install from the subpath and assert | |
| # set-equality with the curated catalog. | |
| # 2. Interactive `skills add …/framework` (no --all) relies on | |
| # metadata.internal hiding — assert repo-root discovery surfaces | |
| # exactly the curated set and nothing internal. | |
| # The curated catalog is every skills/<dir>/ holding a SKILL.md — the | |
| # same tree @objectstack/skills ships whole (packages/skills/scripts/ | |
| # sync-catalog.mjs), read the same way as the package-catalog step | |
| # below. ⛔ Never a name glob or an allow-list here: a skill added to | |
| # skills/ would red this step until a governed edit of this file. | |
| # An internal skill placed in skills/ still fails: the CLI hides | |
| # metadata.internal skills, so the installed set (assertion 1) or the | |
| # listed count (assertion 2) falls short of the directory set. | |
| run: | | |
| cd "$RUNNER_TEMP" | |
| node "$GITHUB_WORKSPACE/packages/create-objectstack/bin/create-objectstack.js" skills-probe --skip-install --skip-skills | |
| cd skills-probe | |
| expected=$(for d in "$GITHUB_WORKSPACE"/skills/*/; do if [ -f "${d}SKILL.md" ]; then basename "$d"; fi; done | sort) | |
| if [ -z "$expected" ]; then | |
| echo "::error::skills/ holds no <skill>/SKILL.md — the curated catalog this step compares against is empty" | |
| exit 1 | |
| fi | |
| expected_count=$(echo "$expected" | wc -l | tr -d ' ') | |
| npx -y skills add "$GITHUB_WORKSPACE/skills" --all --copy | |
| installed=$(find . -name SKILL.md -not -path '*/node_modules/*' -exec dirname {} \; | xargs -rn1 basename | sort -u) | |
| echo "installed skills:"; echo "$installed" | |
| if [ "$installed" != "$expected" ]; then | |
| echo "::error::scaffolded skill set != curated skills/ catalog (internal-skill leak or missing skill)" | |
| printf 'expected:\n%s\n' "$expected" | |
| exit 1 | |
| fi | |
| # Strip ANSI color codes — the skills CLI colors the count even | |
| # when piped ("Found \e[32m9\e[39m skills"), which broke the greps. | |
| listing=$(npx -y skills add "$GITHUB_WORKSPACE" --list 2>&1 | sed 's/\x1b\[[0-9;]*m//g') | |
| echo "$listing" | |
| if echo "$listing" | grep -q 'dogfood-verification'; then | |
| echo "::error::repo-root discovery surfaced an internal skill (metadata.internal marker missing?)" | |
| exit 1 | |
| fi | |
| if ! echo "$listing" | grep -q "Found $expected_count skill"; then | |
| echo "::error::repo-root discovery does not match the curated catalog (expected $expected_count skills) — a SKILL.md outside skills/ is missing metadata.internal" | |
| exit 1 | |
| fi | |
| - name: 'Pinned shape: scaffold WITHOUT --skip-install, assert the pin ran' | |
| # Everything above scaffolds with `--skip-install` and installs the | |
| # project in a separate step, so the scaffolder's OWN post-install work | |
| # never runs — and the Dockerfile runtime-image pin (#9017) lives | |
| # exactly there. The shape those steps build and boot is therefore the | |
| # UNPINNED one (`FROM ghcr.io/objectstack-ai/objectstack:latest`), while | |
| # every real `npx create-objectstack` user ships the PINNED one, so the | |
| # pin silently ceasing to happen was invisible to this job (#9117). | |
| # | |
| # A second, throwaway project closes that gap the cheap way: scaffold it | |
| # the way a real user does — no `--skip-install` — and assert one thing, | |
| # that the emitted Dockerfile names the @objectstack/cli version this | |
| # project actually resolved. No docker build: the difference between the | |
| # two shapes is exactly one FROM tag, and the leg above already proves | |
| # the image builds and boots. runtime-image.test.ts covers the REWRITE | |
| # on fabricated input; what only an end-to-end run can catch is the pin | |
| # never RUNNING — a scaffolder that stops calling it, or an install path | |
| # that no longer leaves a resolvable CLI behind. | |
| # | |
| # No `--skip-skills` either: the scaffolder's skills step reads the | |
| # catalog out of the node_modules this same install wrote, so this is | |
| # the one project in the job whose skills a real user would get. The | |
| # step after this one asserts them. | |
| # | |
| # The unpublished-version window is the one degradation, and it is | |
| # evidenced rather than blanket. The install step above never meets | |
| # that window: it pins the project to this checkout's packed tarballs | |
| # in THIS WORKFLOW, not in the shipped scaffolder, so this step — whose | |
| # whole point is to run the scaffolder's OWN install against the | |
| # registry — cannot borrow it. | |
| # | |
| # WHY IT STILL LIVES HERE, RECORDED RATHER THAN TRIBAL (#9149). | |
| # Relocating the fallback into the scaffolder would remove this | |
| # degradation outright. It was considered and DECLINED at triage on | |
| # 2026-08-17: `create-objectstack` is a PUBLISHED package, so a fallback | |
| # that rewrites a real user's dependency ranges to `latest` is a | |
| # user-visible public-surface expansion, not CI scaffolding — and a user | |
| # scaffolding during a release window arguably wants a resolvable pin, | |
| # not a floating tag. Reopening it needs a decision card answering | |
| # #9149's three questions: where the rewrite belongs, whether `latest` | |
| # is right for a real user at all, and what happens to the release-time | |
| # stamping that rides the same step (`engines.protocol`, and since #9264 | |
| # `specVersion` too — see scripts/sync-template-versions.mjs). Until | |
| # such a card is ruled, the degradation stays ON PURPOSE, and this | |
| # pointer is why a reader finds that out here instead of rediscovering | |
| # it. | |
| # | |
| # WHAT THE DEGRADATION IS NOT ALLOWED TO SWALLOW. The registry answer is | |
| # classified THREE ways, not two. "npm says no version matches" and "npm | |
| # could not be reached" both surface as an empty string, and both used | |
| # to take the skip — so a registry outage could silently present itself | |
| # as the known window and carry the leg green. Now: | |
| # * unreachable registry ⇒ ::error:: — an unclassifiable | |
| # answer is never evidence of the window, so it is never skipped. | |
| # * reachable, range unsatisfiable ⇒ the known window ⇒ warn, and | |
| # assert the DEGRADED shape rather than nothing at all: with no | |
| # resolvable CLI the scaffolder pins nothing, so the template's own | |
| # `latest` tag must survive untouched. A tag that is neither | |
| # `latest` nor a resolved version means the scaffolder invented one | |
| # with nothing to resolve — a real defect this window must not hide. | |
| # * reachable, range satisfiable ⇒ the scaffolder's install path is | |
| # itself broken ⇒ ::error::. Unchanged: this is the branch that | |
| # still catches a genuinely broken scaffolder install. | |
| run: | | |
| cd "$RUNNER_TEMP" | |
| node "$GITHUB_WORKSPACE/packages/create-objectstack/bin/create-objectstack.js" pinned-probe | |
| cd pinned-probe | |
| if [ ! -f node_modules/@objectstack/cli/package.json ]; then | |
| RANGE=$(node -p "require('./package.json').devDependencies['@objectstack/cli']") | |
| # Asked WITHOUT the range first, so an unreachable registry cannot | |
| # masquerade as "that version is not published yet" and take the | |
| # skip below. Both failures read as an empty string; only this | |
| # rangeless probe tells them apart. | |
| if [ -z "$(npm view "@objectstack/cli" version 2>/dev/null)" ]; then | |
| echo "::error::cannot reach @objectstack/cli on the registry at all, so the emitted range '$RANGE' cannot be classified. An unreachable registry is NOT evidence of the unpublished-version window; refusing to skip the pinned-shape assertion on an answer this job cannot interpret." | |
| exit 1 | |
| fi | |
| if [ -z "$(npm view "@objectstack/cli@$RANGE" version 2>/dev/null)" ]; then | |
| echo "::warning::no @objectstack/cli matching '$RANGE' is on the registry — the unpublished-version window the install step's fallback exists for (that fallback lives in this workflow, not the scaffolder; #9149 records why). Pin-EQUALITY is SKIPPED for this run; the degraded shape is still asserted below." | |
| TAG=$(sed -n 's|^FROM ghcr\.io/objectstack-ai/objectstack:||p' Dockerfile) | |
| if [ "$TAG" != "latest" ]; then | |
| echo "::error::the scaffolder resolved no @objectstack/cli (nothing on the registry satisfies '$RANGE'), so it must leave the template's runtime tag at 'latest' — but the emitted Dockerfile FROM tag is '${TAG:-<none>}'. A tag invented with nothing to resolve is a real defect, not the unpublished-version window." | |
| exit 1 | |
| fi | |
| echo "degraded shape as expected: no resolvable CLI, FROM tag left at 'latest'" | |
| exit 0 | |
| fi | |
| echo "::error::the scaffolder ran its own install but left no node_modules/@objectstack/cli behind, though the registry does satisfy '$RANGE' — its install path is broken, so the Dockerfile pin can never run for a real user" | |
| exit 1 | |
| fi | |
| RESOLVED=$(node -p "require('./node_modules/@objectstack/cli/package.json').version") | |
| TAG=$(sed -n 's|^FROM ghcr\.io/objectstack-ai/objectstack:||p' Dockerfile) | |
| echo "resolved @objectstack/cli : $RESOLVED" | |
| echo "emitted Dockerfile FROM tag : ${TAG:-<none>}" | |
| if [ "$TAG" != "$RESOLVED" ]; then | |
| echo "::error::the scaffolder did NOT pin the Dockerfile runtime image: the emitted FROM tag is '${TAG:-<none>}' but this project resolved @objectstack/cli@$RESOLVED. This is the file every real npx create-objectstack user ships (#9017); the --skip-install legs in this job cannot see it." | |
| exit 1 | |
| fi | |
| echo "pinned as expected: FROM tag == resolved CLI ($RESOLVED)" | |
| - name: 'Skills: the scaffolder installed exactly the @objectstack/skills catalog' | |
| # The pinned-shape project above was scaffolded the way a real user | |
| # does it, skills included. The scaffolder syncs the catalog out of the | |
| # @objectstack/skills package its own install put in node_modules — at | |
| # the range it gives every @objectstack/* dependency, so the version of | |
| # @objectstack/spec — into .claude/skills/ as real files (the measured | |
| # shapes live in packages/create-objectstack/src/skills-install.ts). | |
| # So the catalog this step compares against is the package's, read off | |
| # the registry-installed node_modules, never this checkout's skills/: | |
| # the same skill names, the same count, copied rather than linked. | |
| # | |
| # The unpublished-version window degrades the way the pinned-shape step | |
| # does, and only that window: with nothing installed at all, that step | |
| # has already classified the registry answer and failed on any other | |
| # cause, so this step asserts the degraded shape — no skills from | |
| # anywhere — instead of nothing. An install that resolved the CLI but | |
| # no @objectstack/skills is a template that lost its dependency: red. | |
| run: | | |
| cd "$RUNNER_TEMP/pinned-probe" | |
| PKG=node_modules/@objectstack/skills | |
| if [ ! -f "$PKG/package.json" ]; then | |
| if [ -f node_modules/@objectstack/cli/package.json ]; then | |
| echo "::error::the scaffolder's install resolved @objectstack/cli but no @objectstack/skills, so this project got no skills catalog at its own version — the template no longer depends on the package" | |
| exit 1 | |
| fi | |
| if [ -e .claude/skills ]; then | |
| echo "::error::nothing was installed, yet .claude/skills exists — the scaffolder installed skills from a source other than the @objectstack/skills package" | |
| exit 1 | |
| fi | |
| echo "::warning::no @objectstack/skills is installed — the unpublished-version window the pinned-shape step classified. Catalog EQUALITY is SKIPPED for this run; the degraded shape (no skills from any source) was asserted." | |
| exit 0 | |
| fi | |
| skills_in() { for d in "$1"/*/; do [ -f "${d}SKILL.md" ] && [ ! -L "${d%/}" ] && basename "$d"; done | sort; } | |
| expected=$(skills_in "$PKG/dist/skills") | |
| installed=$(skills_in .claude/skills) | |
| echo "@objectstack/skills@$(node -p "require('./$PKG/package.json').version") catalog ($(echo "$expected" | grep -c .) skills):"; echo "$expected" | |
| echo "installed in .claude/skills ($(echo "$installed" | grep -c .) skills):"; echo "$installed" | |
| if [ -z "$expected" ]; then | |
| echo "::error::the installed @objectstack/skills holds no dist/skills/<skill>/SKILL.md — the layout the scaffolder reads has moved" | |
| exit 1 | |
| fi | |
| if [ "$installed" != "$expected" ]; then | |
| echo "::error::the skills the scaffolder installed are not the installed package's catalog (names and counts above)" | |
| exit 1 | |
| fi | |
| if [ -e .agents ] || [ -n "$(find .claude -type l)" ]; then | |
| echo "::error::the scaffolder linked the catalog instead of copying it — a clone of this project would hold dangling links into node_modules" | |
| exit 1 | |
| fi | |
| echo "skills as expected: .claude/skills == the installed @objectstack/skills catalog" | |
| # The Docker leg runs in three steps, and each one states what it proves | |
| # and what it does not. Nothing under docker/** and nothing in the | |
| # template is edited for this job: both Dockerfiles are built exactly as | |
| # they are in this checkout, and every CI-only piece is a layer or a | |
| # local tag on this runner. | |
| # | |
| # Step 1 of 3: the official runtime image, as it stands. | |
| # | |
| # PROVES: docker/Dockerfile from this checkout builds, and the image it | |
| # produces runs its own CLI (`os --version`) and reaches the SQL drivers | |
| # it promises — the same smoke docker-publish.yml runs on a released image. | |
| # | |
| # DOES NOT PROVE: that the official image's own CLI boots this checkout's | |
| # artifact. It is built with the PUBLISHED @objectstack/cli that the | |
| # registry's `latest` names, never this checkout's version: on the | |
| # Version Packages PR and after its merge, that version is not on the | |
| # registry yet, so passing it would make the build fail for a reason | |
| # unrelated to the change under review. The boot below runs the candidate | |
| # CLI from the layer in step 2, which shadows this one. | |
| - name: Build official runtime image from this checkout | |
| run: | | |
| PUBLISHED=$(npm view @objectstack/cli@latest version 2>/dev/null || true) | |
| if [ -z "$PUBLISHED" ]; then | |
| echo "::error::cannot read @objectstack/cli's latest version from the registry, so the official image cannot be built with a published CLI" | |
| exit 1 | |
| fi | |
| echo "Building docker/Dockerfile as it stands, with the published @objectstack/cli@$PUBLISHED" | |
| docker build -t os-official-e2e --build-arg OS_CLI_VERSION="$PUBLISHED" "$GITHUB_WORKSPACE/docker" | |
| GOT=$(docker run --rm os-official-e2e os --version) | |
| echo "$GOT" | |
| if ! printf '%s\n' "$GOT" | grep -qF "/$PUBLISHED "; then | |
| echo "::error::the official image's os --version does not name the @objectstack/cli@$PUBLISHED it was built with" | |
| exit 1 | |
| fi | |
| docker run --rm -w /usr/local/lib/node_modules os-official-e2e \ | |
| node -e "require('pg'); require('mysql2')" | |
| # Step 2 of 3: the candidate runtime layer. | |
| # | |
| # The scaffolded Dockerfile's build stage copies only the manifests and | |
| # runs a FROZEN install from the lockfile the install step above wrote. | |
| # That lockfile names each pinned package by a path relative to the | |
| # project (`file:../tarballs/…`), which does not exist inside the build | |
| # context. So the build stage's base image (read from the Dockerfile, | |
| # `FROM … AS build`) is re-tagged on this runner as itself plus the | |
| # tarballs, at the path the lockfile names from the stage's WORKDIR. The | |
| # scaffolded Dockerfile is then built unedited, `--target` its build stage. | |
| # | |
| # The candidate layer is the official image from step 1 with that build | |
| # stage's node_modules copied in at the same path and its `.bin` first on | |
| # PATH. It is tagged as the runtime image the scaffolded Dockerfile's | |
| # final stage names, so step 3 builds FROM it. | |
| # | |
| # Which `os` answers is asserted by its RESOLVED PATH, not by its version: | |
| # outside pre mode this checkout's CLI version equals the published one | |
| # step 1 installed globally, so a version match cannot tell the shadowing | |
| # CLI from the global one. The path is exported for step 3, which asks | |
| # the same question of the image that actually boots. | |
| # | |
| # PROVES: the scaffolded Dockerfile's build stage installs and builds the | |
| # project from this checkout's packages, and `os` in the layer is the | |
| # build stage's CLI, which runs inside the official image. | |
| # | |
| # DOES NOT PROVE: anything about the official image's global CLI (step 1 | |
| # covers what can be covered); that the candidate CLI reaches the image's | |
| # global `pg` / `mysql2` (the boot below uses SQLite); or that the build | |
| # stage's native modules built. `better-sqlite3` compiles with node-gyp | |
| # at install, and the build stage's base ships no Python, so its install | |
| # step fails there and the copied tree may carry no native addon (step 3 | |
| # prints the storage driver the container booted with). | |
| - name: Build the candidate runtime layer (scaffolded build stage + official image) | |
| run: | | |
| cd "$RUNNER_TEMP/e2e-app" | |
| BUILD_BASE=$(sed -n 's/^FROM \([^ ]*\) AS build$/\1/p' Dockerfile) | |
| BUILD_DIR=$(sed -n '/^FROM [^ ]* AS build$/,/^FROM /s/^WORKDIR \([^ ]*\)$/\1/p' Dockerfile | head -n 1) | |
| if [ -z "$BUILD_BASE" ] || [ -z "$BUILD_DIR" ]; then | |
| echo "::error::the scaffolded Dockerfile has no 'FROM <image> AS build' stage with a WORKDIR (read: base '${BUILD_BASE:-<none>}', workdir '${BUILD_DIR:-<none>}'), so the tarballs cannot be placed where its frozen install looks" | |
| exit 1 | |
| fi | |
| TARBALL_DIRS=$(grep -o "file:[^'\" ()]*\.tgz" pnpm-lock.yaml | sed 's|^file:||; s|/[^/]*$||' | { grep -v '^/' || true; } | sort -u) | |
| if [ -z "$TARBALL_DIRS" ] || [ "$(printf '%s\n' "$TARBALL_DIRS" | wc -l)" -ne 1 ]; then | |
| echo "::error::expected the lockfile to name every packed tarball under one project-relative directory, read: '${TARBALL_DIRS:-<none>}'" | |
| exit 1 | |
| fi | |
| IN_IMAGE=$(realpath -m "$BUILD_DIR/$TARBALL_DIRS") | |
| echo "build stage: FROM $BUILD_BASE, WORKDIR $BUILD_DIR; lockfile names $TARBALL_DIRS, so the tarballs go to $IN_IMAGE" | |
| mkdir -p "$RUNNER_TEMP/tarball-base/tarballs" | |
| cp "$RUNNER_TEMP"/tarballs/*.tgz "$RUNNER_TEMP/tarball-base/tarballs/" | |
| printf 'FROM %s\nCOPY tarballs/ %s/\n' "$BUILD_BASE" "$IN_IMAGE" > "$RUNNER_TEMP/tarball-base/Dockerfile" | |
| docker pull "$BUILD_BASE" | |
| docker build -t "$BUILD_BASE" "$RUNNER_TEMP/tarball-base" | |
| docker build --pull=false --target build -t e2e-app-build . | |
| CANDIDATE=$(node -p "require('./node_modules/@objectstack/cli/package.json').version") | |
| RUNTIME_TAG=$(sed -n 's|^FROM ghcr\.io/objectstack-ai/objectstack:||p' Dockerfile) | |
| if [ -z "$RUNTIME_TAG" ]; then | |
| echo "::error::no FROM ghcr.io/objectstack-ai/objectstack:<tag> line in the scaffolded Dockerfile — the runtime image the next step builds against cannot be named, so this job would silently test a pulled image instead of this checkout" | |
| exit 1 | |
| fi | |
| mkdir -p "$RUNNER_TEMP/candidate-layer" | |
| printf 'FROM os-official-e2e\nCOPY --from=e2e-app-build %s/node_modules %s/node_modules\nENV PATH=%s/node_modules/.bin:$PATH\n' \ | |
| "$BUILD_DIR" "$BUILD_DIR" "$BUILD_DIR" > "$RUNNER_TEMP/candidate-layer/Dockerfile" | |
| echo "Tagging the candidate layer ghcr.io/objectstack-ai/objectstack:$RUNTIME_TAG (read from the scaffolded Dockerfile)" | |
| docker build --pull=false -t "ghcr.io/objectstack-ai/objectstack:$RUNTIME_TAG" "$RUNNER_TEMP/candidate-layer" | |
| GOT=$(docker run --rm "ghcr.io/objectstack-ai/objectstack:$RUNTIME_TAG" os --version) | |
| echo "$GOT" | |
| if ! printf '%s\n' "$GOT" | grep -qF "/$CANDIDATE "; then | |
| echo "::error::os in the candidate layer is not this checkout's @objectstack/cli@$CANDIDATE" | |
| exit 1 | |
| fi | |
| CANDIDATE_OS="$BUILD_DIR/node_modules/.bin/os" | |
| RESOLVED=$(docker run --rm "ghcr.io/objectstack-ai/objectstack:$RUNTIME_TAG" sh -c 'command -v os') | |
| echo "os in the candidate layer resolves to: $RESOLVED" | |
| if [ "$RESOLVED" != "$CANDIDATE_OS" ]; then | |
| echo "::error::os in the candidate layer resolves to '$RESOLVED', not the build stage's $CANDIDATE_OS — the image's own global CLI would answer instead of this checkout's" | |
| exit 1 | |
| fi | |
| echo "CANDIDATE_OS=$CANDIDATE_OS" >> "$GITHUB_ENV" | |
| # Step 3 of 3: the scaffolded Dockerfile, built whole and booted. | |
| # | |
| # The blank template ships its own Dockerfile / docker-compose.yml / | |
| # .dockerignore, so build the generated project as-is rather than a | |
| # hand-kept copy (the standalone examples/docker copy was removed in | |
| # 6c28bac). | |
| # | |
| # PROVES: the template's Dockerfile, unedited, builds this project's | |
| # artifact with this checkout's CLI and boots it under `os start` inside | |
| # the official image's user, entrypoint, environment and healthcheck. | |
| # | |
| # Before it boots, the step right below builds the image and asks which | |
| # `os` its CMD resolves: it must be the candidate CLI step 2 placed, never | |
| # the global one. That assertion is a step of its own so the boot block | |
| # keeps the shape scaffold-e2e-boot-probe.test.ts runs against stubs. | |
| # | |
| # DOES NOT PROVE: the image a user pulls, whose CLI is the published one | |
| # (step 1). Nor the template Dockerfile's `npm ci` branch: this job | |
| # installs the project with pnpm, so the build stage takes the pnpm | |
| # branch, and no job on a pull request builds the `npm ci` branch any | |
| # more. Nor native SQLite: the driver line printed after the boot names | |
| # the storage driver the container was configured with, and with no | |
| # native addon built (step 2) the boot is not evidence that one loaded. | |
| # Scope, precisely: this is the `--skip-install` shape of that | |
| # path, so the Dockerfile built here still carries the floating tag. A | |
| # real `npm create objectstack` user ships the PINNED shape, which differs | |
| # by exactly one FROM tag — asserted by the pinned-shape step above rather | |
| # than built a second time here, since the layers below the tag are the | |
| # ones this build already proves (#9117). | |
| - name: Assert the scaffolded image runs the candidate CLI | |
| run: | | |
| cd "$RUNNER_TEMP/e2e-app" | |
| docker build --pull=false -t e2e-app . | |
| RESOLVED=$(docker run --rm e2e-app sh -c 'command -v os') | |
| echo "os in the image that boots resolves to: $RESOLVED" | |
| if [ -z "${CANDIDATE_OS:-}" ] || [ "$RESOLVED" != "$CANDIDATE_OS" ]; then | |
| echo "::error::os in the e2e-app image resolves to '$RESOLVED', not the candidate CLI '${CANDIDATE_OS:-<unset>}' — the boot in the next step would run a CLI this checkout did not build" | |
| exit 1 | |
| fi | |
| - name: Docker build and run (scaffolded Dockerfile) | |
| run: | | |
| cd "$RUNNER_TEMP/e2e-app" | |
| docker build --pull=false -t e2e-app . | |
| # The fixed container NAME and the fixed HOST PORT below both stay, | |
| # and they are a different animal from the in-process port shift the | |
| # two `os start` blocks guard against (#9779). Docker declines both | |
| # collisions at `docker run` time and never relocates: a duplicate | |
| # `--name e2e` is refused by name, and a taken `-p 18080:8080` fails | |
| # to bind rather than publishing somewhere else. Under this step's | |
| # `bash -e` either aborts the step before the loop is reached. So a | |
| # `docker run` that SUCCEEDED is proof that 18080 is ours — this leg | |
| # has no wrong-answer mode for a per-run port to remove. (Read from | |
| # docker's published behaviour, not measured: the dispatch container | |
| # this was written in ships the docker CLI with no daemon behind it.) | |
| # | |
| # What it did share with the other two is the missing question. The | |
| # loop asked only whether 18080 answered, so a container that started | |
| # and then died at second 3 cost the full 60s and reported "never | |
| # became healthy" instead of "it is not running, here is why". | |
| docker run -d --name e2e -p 18080:8080 \ | |
| -e OS_DATABASE_URL="file:/tmp/e2e.db" \ | |
| -e OS_SECRET_KEY="$(openssl rand -hex 32)" \ | |
| -e OS_AUTH_SECRET="$(openssl rand -hex 32)" \ | |
| e2e-app | |
| ok="" | |
| for i in $(seq 1 30); do | |
| if [ "$(docker inspect -f '{{.State.Running}}' e2e 2>/dev/null)" != "true" ]; then | |
| echo "::error::the container this step started is no longer running"; docker logs e2e; exit 1 | |
| fi | |
| if curl -fsS http://localhost:18080/api/v1/health > /dev/null 2>&1; then ok=1; break; fi | |
| sleep 2 | |
| done | |
| if [ -z "$ok" ]; then | |
| echo "::error::container never became healthy"; docker logs e2e; exit 1 | |
| fi | |
| echo "storage the container booted with (from its boot banner):" | |
| docker logs e2e 2>&1 | sed 's/\x1b\[[0-9;]*m//g' | grep -E 'Database:|Driver:' || echo " (the boot banner names no Database:/Driver: line)" | |
| docker rm -f e2e | |
| registry-canary: | |
| name: 'Registry canary: ${{ matrix.template }}' | |
| if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 15 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| # `blank` is the whole catalog: the five remote content templates | |
| # (todo, compliance, content, contracts, procurement) were delisted | |
| # from the marketplace and retired from the scaffolder, so canarying | |
| # them would gate the release on unmaintained content. | |
| template: [blank] | |
| steps: | |
| # The one literal Node pin left in the workflows: this job checks nothing | |
| # out (it scaffolds from the published package into RUNNER_TEMP), so | |
| # there is no .nvmrc to read. `pnpm check:node-version` holds it equal to | |
| # .nvmrc. | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v7 | |
| with: | |
| node-version: '22' | |
| - name: Scaffold with published create-objectstack@latest | |
| run: | | |
| cd "$RUNNER_TEMP" | |
| npx -y create-objectstack@latest canary-app -t ${{ matrix.template }} --skip-skills | |
| # `build` is the gate every template must pass; `validate` is run only | |
| # when the scaffolded project defines it (the now-retired remote | |
| # templates did not always ship it), and `test` likewise: a published | |
| # scaffolder older than the starter's test (`starter.test.ts`) declares none. | |
| - name: Gate the generated project | |
| run: | | |
| cd "$RUNNER_TEMP/canary-app" | |
| if node -e "process.exit(JSON.parse(require('fs').readFileSync('package.json','utf8')).scripts?.validate ? 0 : 1)"; then | |
| npm run validate | |
| fi | |
| npm run build | |
| if node -e "process.exit(JSON.parse(require('fs').readFileSync('package.json','utf8')).scripts?.test ? 0 : 1)"; then | |
| npm test | |
| fi | |
| # Same two guards, same reasoning, as `Boot from the artifact and probe | |
| # health` in scaffold-local — see the measurement written out there. Kept | |
| # as a copy rather than factored into a composite action: these two blocks | |
| # boot DIFFERENT artifacts (repo dist vs. the published scaffolder) and the | |
| # thing under test is the block a reader of this file can see whole. | |
| - name: Boot and probe health (blank only) | |
| if: matrix.template == 'blank' | |
| run: | | |
| cd "$RUNNER_TEMP/canary-app" | |
| if curl -fsS http://localhost:8080/api/v1/health > /dev/null 2>&1; then | |
| echo "::error::something is already serving http://localhost:8080/api/v1/health before this step booted anything — every probe below would assert against it, not against the app this job scaffolded" | |
| exit 1 | |
| fi | |
| npx os start --artifact ./dist/objectstack.json --port 8080 > server.log 2>&1 & | |
| SERVER_PID=$! | |
| ok="" | |
| for i in $(seq 1 30); do | |
| if ! kill -0 "$SERVER_PID" 2>/dev/null; then | |
| echo "::error::the server this step started exited before becoming healthy"; cat server.log; exit 1 | |
| fi | |
| if curl -fsS http://localhost:8080/api/v1/health > /dev/null 2>&1; then ok=1; break; fi | |
| sleep 2 | |
| done | |
| if [ -z "$ok" ]; then | |
| echo "::error::server never became healthy"; cat server.log; exit 1 | |
| fi | |
| curl -fsS http://localhost:8080/api/v1/ready | |
| kill "$SERVER_PID" |