Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

ci: drop build-sandbox and the Pages preview leftovers; Storybook is built once per run (#8887)

Cindy Zhanga23ce4e2ac0e
diff --git a/.github/scripts/ci-tooling-routing.test.mjs b/.github/scripts/ci-tooling-routing.test.mjs
index ec002723bc..e15f9c6f53 100644
--- a/.github/scripts/ci-tooling-routing.test.mjs
+++ b/.github/scripts/ci-tooling-routing.test.mjs
@@ -154,7 +154,6 @@ describe('Node-tooling CI routing', () => {
expect(step(ci.jobs['docsite-data'], name).if).toContain(TOOLING_FALSE);
}
- expect(ci.jobs['build-sandbox'].if).toContain(TOOLING_FALSE);
for (const candidate of [
...ci.jobs['build-storybook'].steps,
...ci.jobs.typecheck.steps,
@@ -184,11 +183,7 @@ describe('Node-tooling CI routing', () => {
'test-native-swift',
'pr-interaction',
]);
- expect(ci.jobs.build.needs).toEqual([
- 'build-storybook',
- 'build-sandbox',
- 'typecheck',
- ]);
+ expect(ci.jobs.build.needs).toEqual(['build-storybook', 'typecheck']);
const testJoin = step(ci.jobs.test, 'Require expected test-owner outcomes');
expect(testJoin.run).toBe('node .github/scripts/ci-test-join.mjs');
expect(ci.jobs.test.permissions).toEqual({contents: 'read'});
@@ -208,13 +203,34 @@ describe('Node-tooling CI routing', () => {
ci.jobs.build,
'Assert parallel builds succeeded',
).run;
- expect(buildJoin).toContain('needs.build-storybook.result');
- expect(buildJoin).toContain('needs.build-sandbox.result');
+ expect(buildJoin).toContain(
+ '[ "${{ needs.build-storybook.result }}" = "success" ] || exit 1',
+ );
+ expect(buildJoin).not.toContain('build-sandbox');
expect(buildJoin).toContain(
'[ "${{ needs.typecheck.result }}" = "success" ] || exit 1',
);
});
+ it('builds no Sandbox and builds Storybook once per pull-request run', () => {
+ // Vercel builds the Sandbox preview; nothing downloaded CI's copy.
+ expect(ci.jobs['build-sandbox']).toBeUndefined();
+ expect(ci.jobs['build-storybook'].outputs).not.toHaveProperty(
+ 'sandbox_url',
+ );
+ const storybookBuilders = Object.entries(ci.jobs).flatMap(([name, job]) =>
+ (job.steps ?? [])
+ .filter(s =>
+ /storybook build|build-packages-and-storybook/.test(s.run ?? ''),
+ )
+ .filter(
+ s => !/^github\.event_name == 'workflow_dispatch'/.test(s.if ?? ''),
+ )
+ .map(() => name),
+ );
+ expect(storybookBuilders).toEqual(['build-storybook']);
+ });
+
it('keeps removed preview publication out of the tooling lane', () => {
expect(prComment.jobs.resolve.outputs.tooling_only).toContain(
'steps.identity.outputs.tooling_only',
diff --git a/.github/scripts/spec-owner-workflow.test.mjs b/.github/scripts/spec-owner-workflow.test.mjs
index 02b6d22567..9160b309b8 100644
--- a/.github/scripts/spec-owner-workflow.test.mjs
+++ b/.github/scripts/spec-owner-workflow.test.mjs
@@ -211,7 +211,9 @@ describe('spec-only workflow contract', () => {
it('skips every Storybook build command for spec-only changes', () => {
const ci = read('.github/workflows/ci.yml');
const jobStart = ci.indexOf(' build-storybook:');
- const jobEnd = ci.indexOf('\n build-sandbox:', jobStart);
+ // The job ends where the next top-level job begins.
+ const jobEnd =
+ jobStart + 1 + ci.slice(jobStart + 1).search(/\n {2}[a-z0-9-]+:\n/);
const buildJob = ci.slice(jobStart, jobEnd);
const steps = buildJob.split(/\n - name: /).slice(1);
const commandSteps = steps.filter(step =>
diff --git a/.github/scripts/visual-gate/workflow-concurrency.test.mjs b/.github/scripts/visual-gate/workflow-concurrency.test.mjs
index be40ced61e..388d3d9eb7 100644
--- a/.github/scripts/visual-gate/workflow-concurrency.test.mjs
+++ b/.github/scripts/visual-gate/workflow-concurrency.test.mjs
@@ -160,9 +160,8 @@ describe('PR report and deployment workflow contracts', () => {
expect(value).not.toContain(
'storybook_url=https://${REPO_OWNER}.github.io',
);
- expect(value).toContain(
- 'name: sandbox-${{ steps.urls.outputs.short_hash }}',
- );
+ // Vercel builds the Sandbox preview; CI uploads no Sandbox of its own.
+ expect(value).not.toContain('name: sandbox-');
});
it('stages both static apps in Vercel preview and production', () => {
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 414d35ba3f..1a6dd8d963 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -647,7 +647,7 @@ jobs:
#
# `test` remains a job, so the required check of that name still exists and
# still reports for every PR. This mirrors the `build` join over
- # build-storybook + build-sandbox below.
+ # build-storybook + typecheck below.
test-ui:
name: test-ui (${{ matrix.shard }}/${{ strategy.job-total }})
needs: [check-scope]
@@ -1035,12 +1035,10 @@ jobs:
PR_INTERACTION_RESULT: ${{ needs.pr-interaction.result }}
run: node .github/scripts/ci-test-join.mjs
- # Build storybook + typecheck + analyze components (parallel with test and
- # build-sandbox). Uploads the storybook preview and analysis artifacts for
- # downstream jobs.
- # The sandbox preview build lives in build-sandbox: it alone takes ~4min
- # while everything here takes ~2min, so the two run in parallel and the
- # `build` join below folds their results into the historical check name.
+ # Build the packages and Storybook, and analyze components (parallel with
+ # test). Uploads the storybook preview and analysis artifacts for downstream
+ # jobs. Sandbox previews come from the exact-head Vercel deployment, so CI
+ # builds no Sandbox of its own.
build-storybook:
needs: [check-scope]
if: ${{ (github.event_name != 'workflow_dispatch' || inputs.operation == 'release-check') && always() && !cancelled() && needs.check-scope.outputs.spec_only != 'true' }}
@@ -1052,7 +1050,6 @@ jobs:
contents: read
outputs:
short_hash: ${{ steps.release.outputs.short_hash || steps.urls.outputs.short_hash }}
- sandbox_url: ${{ steps.urls.outputs.sandbox_url }}
pr_number: ${{ steps.urls.outputs.pr_number }}
steps:
- name: Require successful scope classification
@@ -1114,12 +1111,9 @@ jobs:
PR_NUMBER="${{ github.event.pull_request.number }}"
COMMIT_HASH="${{ github.event.pull_request.head.sha }}"
SHORT_HASH="${COMMIT_HASH:0:7}"
- REPO_NAME="${{ github.event.repository.name }}"
- REPO_OWNER="${{ github.repository_owner }}"
echo "short_hash=${SHORT_HASH}" >> $GITHUB_OUTPUT
echo "pr_number=${PR_NUMBER}" >> $GITHUB_OUTPUT
- echo "sandbox_url=https://${REPO_OWNER}.github.io/${REPO_NAME}/pr/${PR_NUMBER}/sandbox/" >> $GITHUB_OUTPUT
- name: Identify full release audit scope
if: github.event_name == 'workflow_dispatch' && needs.check-scope.outputs.tooling_only != 'true'
@@ -1176,9 +1170,8 @@ jobs:
- name: Write PR comment metadata
if: needs.check-scope.outputs.docsite_only != 'true' && needs.check-scope.outputs.spec_only != 'true' && needs.check-scope.outputs.tooling_only != 'true' && github.event_name == 'pull_request'
run: |
- # PR Comment reads this exact-run analysis. Storybook preview links
- # come from the exact-head Vercel deployment; the Sandbox artifact
- # remains on Pages until its separate migration.
+ # PR Comment reads this exact-run analysis. Storybook and Sandbox
+ # preview links come from the exact-head Vercel deployment.
cat > pr-meta.json <<EOF
{
"prNumber": "${{ steps.urls.outputs.pr_number }}",
@@ -1341,93 +1334,13 @@ jobs:
bash "$legacy"
fi
- # Sandbox preview build — the single slowest piece of PR CI (~4min), run as
- # its own job so it overlaps build-storybook instead of serializing after it.
- # PR-only: merge_group runs never deploy previews, and docsite-only PRs skip
- # preview builds entirely.
- build-sandbox:
- needs: [check-scope]
- if: github.event_name == 'pull_request' && needs.check-scope.outputs.docsite_only != 'true' && needs.check-scope.outputs.spec_only != 'true' && needs.check-scope.outputs.tooling_only != 'true'
- runs-on: ubuntu-24.04-arm
- timeout-minutes: 15
- permissions:
- contents: read
- outputs:
- short_hash: ${{ steps.urls.outputs.short_hash }}
- steps:
- - name: Checkout
- uses: actions/checkout@v7
-
- - name: Setup Node and pnpm
- uses: ./.github/actions/setup
-
- - name: Build core package
- run: pnpm build
-
- - name: Compute sandbox preview paths
- id: urls
- run: |
- PR_NUMBER="${{ github.event.pull_request.number }}"
- COMMIT_HASH="${{ github.event.pull_request.head.sha }}"
- SHORT_HASH="${COMMIT_HASH:0:7}"
- REPO_NAME="${{ github.event.repository.name }}"
-
- {
- echo "short_hash=${SHORT_HASH}"
- echo "sandbox_base_path=/${REPO_NAME}/pr/${PR_NUMBER}/sandbox"
- echo "template_assets_base_path=/${REPO_NAME}/sandbox/template-assets"
- } >> "$GITHUB_OUTPUT"
-
- - name: Cache Next.js build
- uses: actions/cache@v6
- with:
- path: apps/sandbox/.next/cache
- # No restore-keys fallback — see deploy.yml for the full rationale.
- # The Next.js module cache bakes in @astryxdesign/core's resolved export graph,
- # so a loose fallback can restore a cache built against a different
- # export shape and silently produce wrong builds (broke #2941's
- # post-merge deploy). A changed key yields a cold (safe) rebuild.
- #
- # Keyed by PR number so PRs never share a cache with main (deploy.yml)
- # or with other PRs: each PR builds with its own basePath
- # (SANDBOX_BASE_PATH=/<repo>/pr/<n>/sandbox vs /<repo>/sandbox on main),
- # and Next.js invalidates the webpack cache whenever the resolved config
- # changes — so a cache built under a different basePath always restores
- # as dead weight (download cost, zero reuse) and, because the shared key
- # "hit", the PR could never save a cache for its own basePath either.
- # Re-pushes to the same PR keep the same key and get real warm builds.
- # (This job only runs on pull_request events — see the job-level `if:`
- # above — so github.event.pull_request.number is always set here.)
- key: nextjs-sandbox-pr${{ github.event.pull_request.number }}-${{ hashFiles('pnpm-lock.yaml') }}-${{ hashFiles('packages/core/dist/**') }}
-
- - name: Build Sandbox
- run: pnpm -F @astryxdesign/sandbox build
- env:
- # Must match the deployed Pages path (<owner>.github.io/<repo>/pr/<n>/sandbox).
- # Built without the /<repo> prefix, the sandbox's root-absolute asset URLs
- # drop that segment and 404 — breaking all styles/JS on the preview.
- SANDBOX_BASE_PATH: ${{ steps.urls.outputs.sandbox_base_path }}
- SANDBOX_TEMPLATE_ASSETS_BASE_PATH: ${{ steps.urls.outputs.template_assets_base_path }}
- NODE_OPTIONS: '--max-old-space-size=8192'
-
- - name: Remove shared assets from preview artifact
- run: rm -rf apps/sandbox/out/template-assets
-
- - name: Upload Sandbox artifact
- uses: actions/upload-artifact@v7
- with:
- name: sandbox-${{ steps.urls.outputs.short_hash }}
- path: apps/sandbox/out/
- retention-days: 30
-
# Join gate that keeps the historical `build` check name: anything keyed on
# "build" being green (branch protection, tooling, habit) keeps working, and
- # it fails when either parallel build fails. build-sandbox is legitimately
- # skipped on docsite-only PRs; a skipped build-storybook (merge_group, or a
- # failed check-scope) skips this gate too — both match the old single-job
- # behavior.
+ # it fails when build-storybook or typecheck fails. A skipped
+ # build-storybook (a spec-only or release-bump pull request) skips this
+ # gate too.
build:
- needs: [build-storybook, build-sandbox, typecheck]
+ needs: [build-storybook, typecheck]
if: ${{ github.event_name != 'workflow_dispatch' && !cancelled() && needs.build-storybook.result != 'skipped' }}
runs-on: ubuntu-slim
permissions: {}
@@ -1435,14 +1348,9 @@ jobs:
- name: Assert parallel builds succeeded
run: |
echo "build-storybook: ${{ needs.build-storybook.result }}"
- echo "build-sandbox: ${{ needs.build-sandbox.result }}"
echo "typecheck: ${{ needs.typecheck.result }}"
[ "${{ needs.build-storybook.result }}" = "success" ] || exit 1
[ "${{ needs.typecheck.result }}" = "success" ] || exit 1
- case "${{ needs.build-sandbox.result }}" in
- success|skipped) ;;
- *) exit 1 ;;
- esac
# CI keeps Storybook's static artifact for visual, accessibility, and RTL
# checks. The exact-head Vercel deployment independently hosts both human
@@ -1450,8 +1358,7 @@ jobs:
# Accessibility audit
# Skipped when no components changed. Depends only on build-storybook, so it
- # starts as soon as the storybook artifact is up (~2min) instead of waiting
- # for the slower sandbox build.
+ # starts as soon as the storybook artifact is up (~2min).
# The release check's full axe roster is scanned by three shard jobs and
# joined, with the baseline gate, in pr-a11y-audit, while pr-a11y runs the
# browser guards beside them. Pull requests audit only their scoped owners in
@@ -2771,7 +2678,6 @@ jobs:
build-storybook,
size-base,
typecheck,
- build-sandbox,
build,
pr-a11y-guards,
pr-a11y-specs,
diff --git a/scripts/score-ledger.mjs b/scripts/score-ledger.mjs
index 6261fcc2e6..09f95766f4 100644
--- a/scripts/score-ledger.mjs
+++ b/scripts/score-ledger.mjs
@@ -1238,8 +1238,8 @@ export function applyScorecard(existing, scorecard, {component, pkg}) {
// naturally takes if you think of blocks as a list) reads as zero open
// BLOCKs to `openBlockCount`. Left unchecked it does three things at once:
// the open-BLOCK grade cap never applies, the ratchet sees no BLOCKs to
- // compare, and the sandbox inlines a literal tsc rejects, which reds
- // `build-sandbox` on every open pull request (#5033).
+ // compare, and the sandbox inlines a literal tsc rejects, which breaks
+ // every Sandbox build, each pull request's preview included (#5033).
if (!isBlocksShape(next.blocks)) {
throw new Error(
`${component}: blocks must be {count, open: [...]} — a bare array reads as ` +
@@ -1313,8 +1313,8 @@ export function applyScorecard(existing, scorecard, {component, pkg}) {
);
}
// The sandbox inlines this row into a typed literal at build time, so a bad
- // shape here is not one broken row: it reds `build-sandbox` on every open PR
- // at once, with no commit responsible (#4924).
+ // shape here is not one broken row: it breaks the Sandbox build for every
+ // open PR at once, with no commit responsible (#4924).
if (!Array.isArray(next.evidence) || !next.evidence.every(isEvidenceItem)) {
throw new Error(
`${component}: evidence must be an array of {label, path?, note?} objects — ` +