name: CI on: push: branches: - main pull_request: branches: - main workflow_dispatch: concurrency: # A release still runs this complete normal main-push workflow. Its immutable # source must not wait behind every ordinary main commit before acceptance. group: >- ci-${{ github.event_name == 'push' && github.ref == 'refs/heads/main' && startsWith(github.event.head_commit.message, 'chore: release v') && github.sha || github.event.pull_request.number || github.ref }} cancel-in-progress: ${{ github.event_name == 'pull_request' }} # Keep all ordinary main pushes; only newer changes to the same PR replace it. queue: ${{ github.event_name == 'pull_request' && 'single' || 'max' }} permissions: contents: read env: BUN_VERSION: '1.4.4' jobs: browser-device-scale: runs-on: ubuntu-latest timeout-minutes: 5 steps: - name: Checkout uses: actions/checkout@v6 - name: Set up the declared Bun uses: oven-sh/setup-bun@v2 with: bun-version: ${{ env.BUN_VERSION }} - name: Install the committed dependency graph run: bun install --frozen-lockfile - name: Build packages imported by subpath run: | stacks_subpath_targets=$(bun .github/scripts/subpath-packages.ts) for pkg in $stacks_subpath_targets; do (cd "storage/framework/core/$pkg" && bun run build) done - name: Verify actual browser device scale working-directory: ${{ runner.temp }} run: bun "${{ github.workspace }}/tests/browser/browse-device-scale.ts" - name: Verify trusted browser input delivery env: STACKS_BROWSER_TESTS: '1' run: bun test ./storage/framework/core/testing/tests/browser.test.ts ./storage/framework/core/testing/tests/browser-shared.test.ts - name: Verify native WebView documentation captures env: STACKS_BROWSER_TESTS: '1' run: bun test ./storage/framework/core/docs/tests/screenshots.test.ts ./storage/framework/core/docs/tests/screenshot-models.test.ts - name: Verify repeated mid-gesture rejection and cleanup env: STACKS_BROWSER_TESTS: '1' shell: bash run: | mkdir -p artifacts set -o pipefail bun test ./storage/framework/core/testing/tests/browser.test.ts --test-name-pattern 'never replays a gesture' --rerun-each=25 2>&1 | tee artifacts/mid-gesture-repetitions.log bun -e 'import { stripVTControlCharacters } from "node:util"; const text = stripVTControlCharacters(await Bun.file("artifacts/mid-gesture-repetitions.log").text()); if (!/\b25 pass\b/.test(text) || /\b[1-9]\d* (?:fail|skip)\b/.test(text)) throw new Error("Expected 25 actual passes without failures or skips")' release-evidence: name: Release evidence (${{ matrix.os }}) runs-on: ${{ matrix.os }} timeout-minutes: 10 strategy: fail-fast: false matrix: os: [ubuntu-latest, windows-latest] steps: - name: Checkout uses: actions/checkout@v6 - name: Set up the declared Bun uses: oven-sh/setup-bun@v2 with: bun-version: ${{ env.BUN_VERSION }} - name: Install the committed dependency graph run: bun install --frozen-lockfile - name: Build packages imported by subpath run: bun .github/scripts/source-release-evidence.ts build - name: Verify source gates, installed artifacts and subprocess ownership run: bun .github/scripts/source-release-evidence.ts test - name: Verify immediate readiness and exit ordering repeatedly run: bun .github/scripts/source-release-evidence.ts stress release-evidence-macos: name: Release evidence (macos-arm64) if: github.event_name != 'pull_request' runs-on: macos-latest timeout-minutes: 15 steps: - name: Checkout uses: actions/checkout@v6 - name: Set up the declared Bun uses: oven-sh/setup-bun@v2 with: bun-version: ${{ env.BUN_VERSION }} - name: Verify native platform run: bun -e 'if (process.platform !== "darwin" || process.arch !== "arm64" || Bun.version !== "1.4.4") throw new Error("Expected native macOS arm64 and Bun 1.4.4")' - name: Install committed dependencies run: bun install --frozen-lockfile - name: Build source packages run: bun .github/scripts/source-release-evidence.ts build - name: Verify release evidence run: bun .github/scripts/source-release-evidence.ts test - name: Stress immediate exit ordering run: bun .github/scripts/source-release-evidence.ts stress release-evidence-macos-pr: name: Release evidence (macos PR) if: github.event_name == 'pull_request' runs-on: macos-latest timeout-minutes: 15 steps: - name: Checkout uses: actions/checkout@v6 - name: Set up the declared Bun uses: oven-sh/setup-bun@v2 with: bun-version: ${{ env.BUN_VERSION }} - name: Verify native platform run: bun -e 'if (process.platform !== "darwin" || process.arch !== "arm64" || Bun.version !== "1.4.4") throw new Error("Expected native macOS arm64 and Bun 1.4.4")' - name: Install committed dependencies run: bun install --frozen-lockfile - name: Build source packages run: bun .github/scripts/source-release-evidence.ts build - name: Verify release evidence run: bun .github/scripts/source-release-evidence.ts test - name: Stress immediate exit ordering run: bun .github/scripts/source-release-evidence.ts stress dependency-locks: if: github.event_name == 'pull_request' runs-on: ubuntu-latest timeout-minutes: 15 steps: - name: Checkout uses: actions/checkout@v6 - name: Set up the pinned dependency tools uses: pantry-pm/pantry/packages/action@c7a4512c54606c2b0940e9809cb3454a2cbdf4fa with: version: '0.11.205' install: 'false' packages: 'bun.com@${{ env.BUN_VERSION }} git-scm.org curl.se sqlite.org' - name: Generate the candidate Bun lock with the normal installer run: bun install - name: Generate the candidate Pantry lock with the normal installer run: pantry install --ignore-scripts --quiet - name: Retain the actual installer outputs uses: actions/upload-artifact@v7 with: name: candidate-dependency-lockfiles-${{ github.sha }} path: | bun.lock pantry.lock if-no-files-found: error - name: Build packages imported by subpath run: | stacks_subpath_targets=$(bun .github/scripts/subpath-packages.ts) for pkg in $stacks_subpath_targets; do echo "::group::build @stacksjs/$pkg" (cd "storage/framework/core/$pkg" && bun run build) echo "::endgroup::" done - name: Check the generated locks still describe the committed workspace run: | if ! git diff --exit-code -- bun.lock pantry.lock; then echo "::error::Installing changed a committed lockfile. Run \`./pantry/.bin/bun install\` (the pinned Bun) and \`pantry install --ignore-scripts --quiet\`, then commit the result. Lockfile maintenance must not run project setup or database hooks." exit 1 fi lint: runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v6 with: fetch-depth: 0 - name: Setup Pantry uses: pantry-pm/pantry/packages/action@c7a4512c54606c2b0940e9809cb3454a2cbdf4fa # v0.11.205 with: version: '0.11.205' install: 'false' packages: 'bun.com@${{ env.BUN_VERSION }} git-scm.org curl.se sqlite.org' - name: Use cached node_modules uses: actions/cache@v5 with: path: node_modules key: ${{ runner.os }}-node-modules-${{ hashFiles('**/bun.lock') }} - name: Install dependencies run: bun install --frozen-lockfile # After the install: the bunfig preload resolves @stacksjs/env, so # anything invoking `bun` before node_modules exists dies with # `preload not found`. Only bites a project resolving the framework from # npm rather than a vendored storage/framework/core, but the ordering is # wrong either way. - name: Check lockfile version run: bun .github/scripts/check-lockfile-version.ts # CI must exercise the exact Bun that owns the committed lockfile and is # declared in package.json. Pantry provisions that version above; this # check fails the job if PATH ever selects another Bun. - name: Check the running Bun is the pinned one run: bun .github/scripts/check-bun-version.ts --strict - name: Check dependency state env: DEPENDENCY_BASE_SHA: ${{ github.event.pull_request.base.sha || github.event.before }} DEPENDENCY_HEAD_SHA: ${{ github.event.pull_request.head.sha || github.sha }} run: bun .github/scripts/check-dependency-commits.ts - name: Verify exact release source acceptance run: bun test ./.github/scripts/await-release-ci.test.ts - name: Verify canonical publication archive policies id: canonical-pack run: bun test ./.github/scripts/canonical-pack.acceptance.ts env: STACKS_PACK_EVIDENCE: ${{ runner.temp }}/canonical-pack - name: Retain canonical publication archive evidence if: always() && steps.canonical-pack.outcome != 'skipped' uses: actions/upload-artifact@v7 with: name: canonical-publication-pack-source path: ${{ runner.temp }}/canonical-pack if-no-files-found: error - name: Lint run: bun buddy lint typecheck: runs-on: ubuntu-latest steps: - name: Checkout Code uses: actions/checkout@v6 - name: Setup Pantry uses: pantry-pm/pantry/packages/action@c7a4512c54606c2b0940e9809cb3454a2cbdf4fa # v0.11.205 with: version: '0.11.205' install: 'false' packages: 'bun.com@${{ env.BUN_VERSION }} git-scm.org curl.se sqlite.org' - name: Use cached node_modules uses: actions/cache@v5 with: path: node_modules key: ${{ runner.os }}-node-modules-${{ hashFiles('**/bun.lock') }} - name: Install dependencies run: bun install --frozen-lockfile # Same reason the `test` job builds these, and the same two packages: # a workspace package's ROOT export resolves from source when `dist` is # missing, but a subpath pattern like `./composables/*` does not. `dist` # is gitignored and nothing else here builds it, so every # `@stacksjs/browser/composables/*` import is unresolvable and this job # has been red on: # # error TS2307: Cannot find module '@stacksjs/browser/composables/csrf' # error TS2307: Cannot find module '@stacksjs/browser/composables/useStorage' # # It stays green on developer machines because a stale `dist` is already # sitting there. # # Dependency order matters: browser's built `composables/useStorage.js` # imports `@stacksjs/composables/useStorage`, so composables has to exist # first or the same error moves one level down. # # `error-handling` and `storage` joined the list when the router and # logging packages started importing `@stacksjs/error-handling/handler`, # `/http`, `/error-page` and `@stacksjs/storage/uploaded-file`. # # The set is COMPUTED, not typed here. It used to be a hand-written list # with a test to catch it drifting; the test worked, naming `database` and # then `path`, but only after main had already gone red for a package # nobody had reason to know needed listing. - name: Build packages imported by subpath run: | stacks_subpath_targets=$(bun .github/scripts/subpath-packages.ts) for pkg in $stacks_subpath_targets; do echo "::group::build @stacksjs/$pkg" (cd "storage/framework/core/$pkg" && bun run build) echo "::endgroup::" done # Three typecheck scripts cover three disjoint surfaces, and only the # first was running here. `typecheck:app` covers app/, config/, routes/ # and resources/; `typecheck:views` covers every tracked .stx file. # Neither was wired in, so the two surfaces an app author actually edits # were unverified on every PR - which is how 75 .stx errors accumulated. # On the storefront cart, checkout and layout views as they stood before # 133a6c689d, what it reports is `Cannot find name 'requestContext'` (a # global both view servers install, which it now reads from # request-context.d.ts), untyped callback parameters and an undeclared # `window` property. What kept a shopper's cart off those views was not # a type error: see app/Storefront/StorefrontDatabase.ts and # verifyCartCookie in app/Storefront/CartCookie.ts. # # Kept as separate steps so a failure names the surface it came from. - name: Typecheck framework run: bun run typecheck # The framework config excludes tests, and `bun test` strips types, so # the `assertType<...>` and `@ts-expect-error` lines in the # `core/*/tests/*-types.test.ts` suites were never enforced - one in # chain-types had gone stale and still passed. - name: Typecheck type tests run: bun run typecheck:type-tests - name: Typecheck app run: bun run typecheck:app - name: Typecheck views run: bun run typecheck:views # `bench/` decides what this project may publish about its own # performance and no config included it, so its fixtures were implicitly # `any` and its provenance records could go missing unnoticed. The peer # frameworks are an isolated install, and the fixtures import them, so # they have to be present for the check to mean anything. - name: Install benchmark peers run: bun install --cwd bench/routing --frozen-lockfile - name: Typecheck benchmarks run: bun run typecheck:bench - name: Test benchmark harnesses run: bun run test:bench # Split across jobs: run one after another, the core packages' tests were # 15 of this job's 20 minutes and the longest path to a deploy (auth alone # 8, buddy 2). .github/scripts/core-tests.ts says which shard runs what: # auth by file over four, buddy alone, the rest over two by measured time. # The app-level suites ride with buddy, the lightest. Each shard sets up its # own services, in parallel. test: name: test (${{ matrix.shard }}) runs-on: ubuntu-latest strategy: fail-fast: false matrix: shard: [auth-1, auth-2, auth-3, auth-4, buddy, core-1, core-2] steps: - name: Checkout Code uses: actions/checkout@v6 - name: Setup Pantry uses: pantry-pm/pantry/packages/action@c7a4512c54606c2b0940e9809cb3454a2cbdf4fa # v0.11.205 with: version: '0.11.205' install: 'false' packages: 'bun.com@${{ env.BUN_VERSION }} git-scm.org curl.se sqlite.org ffmpeg.org@9.0.2' services: postgres@17.11 mysql@26.7.0 redis@8.8.0 dynamodb@3.3.0 - name: Use cached node_modules uses: actions/cache@v5 with: path: node_modules key: ${{ runner.os }}-node-modules-${{ hashFiles('**/bun.lock') }} - name: Install Dependencies id: install run: bun install --frozen-lockfile # Published-entrypoint probes execute compiled packages without source # aliases. Build their runtime dependencies as well as subpath targets, # so a clean checkout resolves roots such as strings and model-meta. - name: Build framework runtime packages run: | stacks_subpath_targets=$(bun .github/scripts/subpath-packages.ts --runtime) for pkg in $stacks_subpath_targets; do echo "::group::build @stacksjs/$pkg" (cd "storage/framework/core/$pkg" && bun run build) echo "::endgroup::" done - name: Configure private native CI service fixtures run: bun .github/scripts/configure-ci-services.ts - name: Test Suite if: ${{ matrix.shard == 'buddy' }} run: bun run test # `bun run test` shells out to `buddy test`, which only globs # /tests/**, so nothing under storage/framework/core/**/tests # runs there. This step covers every core package. # # One `bun test` per package, not one over the whole tree: `bun test # storage/framework/core` segfaults the runtime. And a loop rather than a # hand-written list — the list is how ~70 packages stayed uncovered while # five were wired, and how the wired five silently stopped being # representative. # # `router` is sharded. bun schedules its 27 files concurrently, and past # roughly 20 the suite stops finishing: every remaining test reports its # own timeout (77 phantom failures locally, 143 on Linux) even for purely # synchronous assertions. Each file passes alone, and split across two # shards the suite passes 283/283. The shard split is a workaround for # the runner, not for a product bug — the three REAL failures it was # hiding are fixed (route middleware registry leaking across files). # # The leading `./` is load-bearing. bunfig.toml sets `[test] root = # "tests"` so a bare `bun test` does not walk `pantry/` and exhaust file # descriptors (85ebd37886). A bare path argument is then treated as a # FILTER applied within that root, so `bun test storage/...` matches # nothing and exits non-zero — which would have reported all ~81 core # packages as failing. bun says so itself: "To treat ... as a path, run # bun test ./". Running from the package directory would also work # (`root` is cwd-relative) but breaks tests that resolve repo-root # paths, e.g. orm's sensitive-api-security.test.ts. # # commerce and cms are the exception, and only for `src/tests`. Those # suites are written for the SQLite harness each package's own # bunfig.toml preloads (`src/tests/setup.ts`), and bun reads bunfig from # the working directory only, so they run from the package directory, # the one place that preload applies. No CI step had reached them since # f25e67af9d (2026-05-11) replaced this job's bare `bun test`, which # picked up test files across the checkout, with `buddy test`. - name: Core tests (all packages) if: ${{ !cancelled() && steps.install.outcome == 'success' }} run: bun .github/scripts/core-tests.ts "${{ matrix.shard }}" - name: Workspace recovery process-inspection integration if: ${{ !cancelled() && steps.install.outcome == 'success' && matrix.shard == 'buddy' }} run: | # These positive recovery fixtures need complete process visibility. # Root on a shared CI host can still meet protected host processes. # A native PID namespace gives this fixture its own inspectable peers; # the ordinary suite still verifies protected-peer refusal separately. sudo --non-interactive unshare --fork --pid --mount-proc "$(command -v bun)" test ./storage/framework/core/storage/integration/temporary-workspaces.test.ts # The framework's default app layer keeps its tests beside the code they # test (the dashboard actions, functions and components under # storage/framework/defaults), and the server package keeps its one in # `test/`. Neither step above reaches them, and all 90 files were added # after f25e67af9d (2026-05-11) stopped this job running a bare # `bun test`, so none of them had run in CI. # The VS Code extension is a package of its own, outside the workspaces, # and its tests build it against @stacksjs/stx-vscode. - name: Install VS Code extension dependencies if: ${{ !cancelled() && steps.install.outcome == 'success' && matrix.shard == 'buddy' }} working-directory: storage/framework/defaults/ide/vscode run: bun install - name: Defaults and server tests if: ${{ !cancelled() && steps.install.outcome == 'success' && matrix.shard == 'buddy' }} run: bun test ./storage/framework/defaults ./storage/framework/server/test compile: runs-on: ubuntu-latest steps: - name: Checkout Code uses: actions/checkout@v6 - name: Setup Pantry uses: pantry-pm/pantry/packages/action@c7a4512c54606c2b0940e9809cb3454a2cbdf4fa # v0.11.205 with: version: '0.11.205' install: 'false' packages: 'bun.com@${{ env.BUN_VERSION }} git-scm.org curl.se sqlite.org' - name: Use cached node_modules uses: actions/cache@v5 with: path: node_modules key: ${{ runner.os }}-node-modules-${{ hashFiles('**/bun.lock') }} - name: Install Dependencies run: bun install --frozen-lockfile # Validate declarations before a frozen install: a build consumes the # committed graph, while the dependency-locks job generates updates. # Registry changes to system dependencies must not rewrite build inputs. - name: Validate the Pantry workspace lock working-directory: .github/scripts run: bun --no-env-file check-pantry-lock.ts - name: Install the pantry tree id: pantry-tree run: pantry install --frozen-lockfile --ignore-scripts --quiet - name: Retain the candidate after a failed frozen Pantry check if: failure() && steps.pantry-tree.outcome == 'failure' run: bun .github/scripts/diagnose-pantry-lock.ts - name: Retain dependency lockfiles and failure diagnostics if: always() uses: actions/upload-artifact@v7 with: name: dependency-lockfiles-${{ github.sha }} path: | bun.lock pantry.lock artifacts/pantry-lock-diagnostic/ if-no-files-found: error # The frozen install must still leave both committed lockfiles untouched. - name: Check the lockfiles still describe this workspace run: | if ! git diff --exit-code -- bun.lock pantry.lock; then echo "::error::Installing changed a committed lockfile. Run \`./pantry/.bin/bun install\` (the pinned Bun) and \`pantry install --ignore-scripts --quiet\`, then commit the result. Lockfile maintenance must not run project setup or database hooks." exit 1 fi # Standalone Buddy bundles every command and its package roots. Build the # same complete runtime package set as the published-root probes: a # package name can differ from its directory (desktop-build is in # desktop/), so the source wildcard cannot resolve every root. Preparing # only subpaths left desktop-build/dist absent on clean Linux runners. - name: Build packages bundled by standalone Buddy run: | stacks_subpath_targets=$(bun .github/scripts/subpath-packages.ts --runtime) for pkg in $stacks_subpath_targets; do echo "::group::build @stacksjs/$pkg" (cd "storage/framework/core/$pkg" && bun run build) echo "::endgroup::" done # The binaries are built only by the release job, on a tag, after npm # publish. So a dependency that grows a top-level await — which # `bun build --compile` refuses to bundle through a `require()` — took # three releases to notice: the packages published, the compile failed, # and nobody looked. One target here is enough to catch that, and it is # the cheap half of `compile:all`. - name: Compile the buddy binary run: | cd storage/framework/core/buddy bun run compile:linux-x64 artifact-freshness: runs-on: ubuntu-latest steps: - name: Checkout Code uses: actions/checkout@v6 - name: Setup Pantry uses: pantry-pm/pantry/packages/action@c7a4512c54606c2b0940e9809cb3454a2cbdf4fa # v0.11.205 with: version: '0.11.205' install: 'false' packages: 'bun.com@${{ env.BUN_VERSION }} git-scm.org curl.se sqlite.org' - name: Use cached node_modules uses: actions/cache@v5 with: path: node_modules key: ${{ runner.os }}-node-modules-${{ hashFiles('**/bun.lock') }} - name: Install Dependencies id: install run: bun install --frozen-lockfile # Same computed set, and for the same reason, as the step in `typecheck`: # these packages resolve only through a gitignored `dist/`, so a job that # imports one without building it fails to resolve it. This job had no # such step, and went red when the router started importing # `@stacksjs/logging/runtime`. - name: Build packages imported by subpath if: ${{ !cancelled() && steps.install.outcome == 'success' }} run: | stacks_subpath_targets=$(bun .github/scripts/subpath-packages.ts) for pkg in $stacks_subpath_targets; do echo "::group::build @stacksjs/$pkg" (cd "storage/framework/core/$pkg" && bun run build) echo "::endgroup::" done # One step per check, rather than one `run:` block running all of them. # # Two things were wrong with the block. Under `bash -e` the first failure # ended it, so a red `docs:artifacts:check` meant `docs:links:check` never # executed at all - it has never run on main. And a failure surfaced only # as the name of the block, so finding out WHICH check failed meant # grepping the raw log. # # `!cancelled()` is what actually fixes the masking: without it Actions # skips every later step once one fails, which is the same bug in a new # costume. The install guard keeps them from all failing noisily when the # real problem is that dependencies did not install. - name: docs:buddy:check if: ${{ !cancelled() && steps.install.outcome == 'success' }} run: bun run docs:buddy:check - name: docs:artifacts:check if: ${{ !cancelled() && steps.install.outcome == 'success' }} run: bun run docs:artifacts:check # The declarations half of #2056, which #2408 could not close while # generation was config-driven: a developer with every feature scaffolded # produced one file and CI produced another, so a diff meant nothing. # The script sets STACKS_CANONICAL_FEATURES, which makes the output a # function of the source tree - so a diff here means stale. It compares # every file generation touches, measured rather than listed: it used to # read one and pass while `database/types.d.ts` was stale (#2879). - name: declarations:check if: ${{ !cancelled() && steps.install.outcome == 'success' }} run: bun run declarations:check # The driver capability matrix, published from `capabilityRegistry` # (stacksjs/stacks#2056). That registry is the ALLOWLIST - a driver # missing from it cannot be configured - so the page and the registry # disagreeing means the docs name drivers that do not work, or omit ones # that do. The Azure adapter shipped in #1896 with no entry at all. - name: docs:capabilities:check if: ${{ !cancelled() && steps.install.outcome == 'success' }} run: bun run docs:capabilities:check # The desktop support matrix, published from `desktopSupportMatrix` # (stacksjs/stacks#2059). Every target there is experimental and unsigned, # and `assertDesktopReleaseChannel` enforces that - but the page a reader # sees is a copy, so this fails when the copy stops agreeing. - name: docs:desktop-matrix:check if: ${{ !cancelled() && steps.install.outcome == 'success' }} run: bun run docs:desktop-matrix:check - name: docs:links:check if: ${{ !cancelled() && steps.install.outcome == 'success' }} run: bun run docs:links:check # The imports in docs code samples, compiled for real # (stacksjs/stacks#2580). The baseline started at 170 and is now EMPTY # (#2581): every documented import compiles. A failure here is a # regression, not a backlog item - fix the sample rather than recording # it, unless the exception is deliberate and explained. - name: docs:snippets:check if: ${{ !cancelled() && steps.install.outcome == 'success' }} run: bun run docs:snippets:check - name: docs:agent-counts:check if: ${{ !cancelled() && steps.install.outcome == 'success' }} run: bun run docs:agent-counts:check - name: docs:native-skills:check if: ${{ !cancelled() && steps.install.outcome == 'success' }} run: bun run docs:native-skills:check - name: Deployment target resolution if: ${{ !cancelled() && steps.install.outcome == 'success' }} run: bun test ./.github/scripts/deploy/*.test.ts # Of the tests under .github/scripts today, only resolve-target's was # run, by name. No workflow had run the tests for the Bun pin, lockfile # version, subpath export and npm promotion checks. - name: Repository script tests if: ${{ !cancelled() && steps.install.outcome == 'success' }} run: bun test ./.github/scripts/*.test.ts # Asks the registry what each declared range actually admits, rather than # what happens to be installed here — a local checkout, a nested install # and a pantry copy all masked craft-native's missing subpaths until an # app installed the published package (#2322). - name: Subpath imports match declared ranges if: ${{ !cancelled() && steps.install.outcome == 'success' }} run: bun .github/scripts/check-subpath-exports.ts # Half of #2056's first criterion: docs:artifacts:check covers OpenAPI, # this covers the ungated barrels. Deliberately NOT models.ts, whose # contents depend on which features config enables and so differ between # a developer's machine and CI (#2408). - name: Generated barrels are current if: ${{ !cancelled() && steps.install.outcome == 'success' }} run: bun .github/scripts/check-generated-barrels.ts # A freshly scaffolded app must typecheck against the framework version it # pinned. `buddy new` writes the template from THIS checkout and pins a # PUBLISHED framework, so the two can disagree whenever the template # references something added since the last release — and the user sees the # error in a file they did not write (#2322, #2375). # # Not on pull_request: it scaffolds and installs a whole app, which is minutes # and a lot of disk for a check whose answer only changes when the template or # the published framework moves. scaffold-smoke: if: >- github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && github.ref == 'refs/heads/main') runs-on: ubuntu-latest steps: - name: Checkout Code uses: actions/checkout@v6 - name: Setup Pantry uses: pantry-pm/pantry/packages/action@c7a4512c54606c2b0940e9809cb3454a2cbdf4fa # v0.11.205 with: version: '0.11.205' install: 'false' packages: 'bun.com@${{ env.BUN_VERSION }} git-scm.org curl.se sqlite.org' - name: Install Dependencies run: bun install --frozen-lockfile - name: Scaffold an app and typecheck it run: bun .github/scripts/scaffold-smoke.ts # Its own job, and not one the Releaser waits for: the desktop template uses # config types that reach an app only once a release publishes them, so a # release that adds one would otherwise wait on a check only it can turn # green. Red here between a bump and its publish says what scaffold-smoke # says: `buddy new --desktop` is broken until the publish lands. scaffold-smoke-desktop: if: >- github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && github.ref == 'refs/heads/main') runs-on: ubuntu-latest steps: - name: Checkout Code uses: actions/checkout@v6 - name: Setup Pantry uses: pantry-pm/pantry/packages/action@c7a4512c54606c2b0940e9809cb3454a2cbdf4fa # v0.11.205 with: version: '0.11.205' install: 'false' packages: 'bun.com@${{ env.BUN_VERSION }} git-scm.org curl.se sqlite.org' - name: Install Dependencies run: bun install --frozen-lockfile - name: Scaffold a desktop app into a cloned repository and typecheck it run: bun .github/scripts/scaffold-smoke.ts --desktop deployment-target: if: >- github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && github.ref == 'refs/heads/main') runs-on: ubuntu-latest outputs: environment: ${{ steps.target.outputs.environment }} flag: ${{ steps.target.outputs.flag }} steps: - name: Checkout Code uses: actions/checkout@v6 - name: Setup Pantry uses: pantry-pm/pantry/packages/action@c7a4512c54606c2b0940e9809cb3454a2cbdf4fa # v0.11.205 with: version: '0.11.205' install: 'false' packages: 'bun.com@${{ env.BUN_VERSION }} git-scm.org curl.se sqlite.org' # Run from the script's own directory so the repo's `bunfig.toml` does not # apply. Bun reads `$cwd/bunfig.toml` and does not walk up, and this repo's # preloads the env plugin and the whole framework preloader - for a script # whose only import is `node:fs`. # # That is where `deployment-target` was spending 46 seconds, and where it # then overflowed the stack thousands of times AFTER printing the right # answer, failing a step that had already succeeded (stacksjs/stacks#2414). # From the repo root this takes 1.8s locally; from here, 0.05s. # # `$GITHUB_OUTPUT` is an absolute path, so appending to it is unaffected. - name: Resolve provisioned deployment target id: target working-directory: .github/scripts/deploy run: bun resolve-target.ts --ref "$GITHUB_REF" --github-output "$GITHUB_OUTPUT" deploy: concurrency: group: compute-${{ needs.deployment-target.outputs.environment }} cancel-in-progress: false if: >- github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && github.ref == 'refs/heads/main') needs: [lint, typecheck, test, compile, artifact-freshness, deployment-target] runs-on: ubuntu-latest timeout-minutes: 30 environment: name: ${{ needs.deployment-target.outputs.environment }} permissions: contents: read deployments: write id-token: write env: DEPLOY_ENVIRONMENT: ${{ needs.deployment-target.outputs.environment }} DEPLOY_FLAG: ${{ needs.deployment-target.outputs.flag }} steps: - name: Checkout Code uses: actions/checkout@v6 - name: Setup Pantry uses: pantry-pm/pantry/packages/action@c7a4512c54606c2b0940e9809cb3454a2cbdf4fa # v0.11.205 with: version: '0.11.205' install: 'false' packages: 'bun.com@${{ env.BUN_VERSION }} git-scm.org curl.se sqlite.org' # Before the install and the build, and inside the job that can actually # see this environment's secrets (stacksjs/stacks#2068). A missing # decryption key used to surface inside `buddy deploy`, minutes in and # after the release was built - and its symptom is not an error but every # configured value silently being its default. # # Run from the script's own directory for the same reason the resolver is: # this repo's bunfig preloads the whole framework for a script that # imports node:fs. - name: Preflight ${{ env.DEPLOY_ENVIRONMENT }} credentials working-directory: .github/scripts/deploy env: DOTENV_PRIVATE_KEY_PRODUCTION: ${{ secrets.DOTENV_PRIVATE_KEY_PRODUCTION }} run: bun resolve-target.ts --ref "$GITHUB_REF" --preflight - name: Use cached node_modules uses: actions/cache@v5 with: path: node_modules key: ${{ runner.os }}-node-modules-${{ hashFiles('**/bun.lock') }} - name: Install Dependencies run: bun install --frozen-lockfile - name: Prepare Deploy SSH Key env: DEPLOY_SSH_KEY: ${{ secrets.DEPLOY_SSH_KEY }} run: | if [ -z "$DEPLOY_SSH_KEY" ]; then echo "No deploy SSH key configured; continuing without one." exit 0 fi mkdir -p ~/.ssh chmod 700 ~/.ssh printf '%s\n' "$DEPLOY_SSH_KEY" > ~/.ssh/id_ed25519 chmod 600 ~/.ssh/id_ed25519 ssh-keygen -y -f ~/.ssh/id_ed25519 > ~/.ssh/id_ed25519.pub chmod 644 ~/.ssh/id_ed25519.pub # Pinned host keys for a `cloud.provider: 'ssh'` target. Optional: the # deploy falls back to accepting a key on first contact, which is what # the Hetzner path has always done. Note that a runner on GitHub's # network cannot reach a host on a home LAN at all. Deploying to one # needs either a self-hosted runner on that network or a tunnel, so this # job stays pointed at a publicly reachable target. - name: Prepare Known Hosts env: SSH_KNOWN_HOSTS: ${{ secrets.SSH_KNOWN_HOSTS }} run: | if [ -z "$SSH_KNOWN_HOSTS" ]; then echo "No pinned host keys configured; continuing without them." exit 0 fi mkdir -p ~/.ssh chmod 700 ~/.ssh printf '%s\n' "$SSH_KNOWN_HOSTS" >> ~/.ssh/known_hosts chmod 600 ~/.ssh/known_hosts - name: Deploy ${{ env.DEPLOY_ENVIRONMENT }} run: ./buddy deploy "$DEPLOY_FLAG" --yes env: APP_ENV: ${{ env.DEPLOY_ENVIRONMENT }} DOTENV_PRIVATE_KEY_PRODUCTION: ${{ secrets.DOTENV_PRIVATE_KEY_PRODUCTION }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Cloudflare, for projects whose `config/cloud.ts` declares a # `compute.proxy.cdn` block. Absent, the deploy still ships and still # publishes DNS; it just skips proxying, zone settings, cache rules # and the post-deploy edge purge — so the release goes out and # visitors keep being served the previously cached document. # # buddy resolves its DNS provider from the zone's live nameservers, so # this is also what a zone delegated to Cloudflare reconciles through. CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} COPYFILE_DISABLE: '1' publish-commit: if: github.event_name == 'pull_request' needs: [lint, typecheck, test, compile, artifact-freshness] runs-on: ubuntu-latest steps: - uses: actions/checkout@v6 - name: Setup Pantry uses: pantry-pm/pantry/packages/action@c7a4512c54606c2b0940e9809cb3454a2cbdf4fa # v0.11.205 with: version: '0.11.205' install: 'false' packages: 'bun.com@${{ env.BUN_VERSION }} git-scm.org curl.se sqlite.org' - name: Use cached node_modules uses: actions/cache@v5 with: path: node_modules key: ${{ runner.os }}-node-modules-${{ hashFiles('**/bun.lock') }} - name: Install Dependencies run: bun install --frozen-lockfile - name: Build run: bun run build - name: Publish Commit run: ./storage/framework/scripts/publish-commit