Repository navigation
test(core): a touch component's import carries its gesture code, and nothing else does #27368
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
| # Copyright (c) Meta Platforms, Inc. and affiliates. | |
| # PR CI: test, build, analyze, a11y audit, and comment | |
| # Everything runs in parallel where possible | |
| # | |
| # Merge queue: test + build also run on merge_group events so the | |
| # merge queue can gate on them before landing a PR. | |
| name: CI | |
| on: | |
| pull_request: | |
| branches: ['main', 'release/**'] | |
| merge_group: | |
| # Explicit release checks and baseline capture share the canonical owners. | |
| # Reviewed captures are committed through a normal pull request. | |
| workflow_dispatch: | |
| inputs: | |
| operation: | |
| description: 'Run the canonical check on exact main or a marked release branch, or capture a main baseline candidate' | |
| type: choice | |
| options: [capture, release-check] | |
| default: capture | |
| required: true | |
| release-branch: | |
| description: 'Exact branch to check: main before a cut, or marked release/vX.Y.Z after the bump' | |
| type: string | |
| required: false | |
| release-version: | |
| description: 'Exact X.Y.Z version recorded by the active marker; required only for a marked release branch' | |
| type: string | |
| required: false | |
| expected-head: | |
| description: 'Exact full main or release branch SHA; required for release-check' | |
| type: string | |
| required: false | |
| plan-digest: | |
| description: 'Exact SHA-256 digest recorded by the active marker; required only for a marked release branch' | |
| type: string | |
| required: false | |
| permissions: {} | |
| # PR CI's budget is 15 minutes. Every job in this workflow that does work on a | |
| # pull request carries `timeout-minutes: 15` (release and maintenance | |
| # dispatches keep longer limits; macOS-only `test-native-swift` keeps 30), and | |
| # `ci-duration` reports each job's run time and the run's span. Split a job | |
| # that nears the limit (shard, scope, cache); do not raise it. | |
| # | |
| # One group per pull request (a fork's branch name can repeat across forks), | |
| # so a new push cancels the superseded run. Merge-queue entries and dispatches | |
| # get their own groups and are never cancelled by a pull request. | |
| concurrency: | |
| group: 'ci-${{ github.event.pull_request.number || github.event.merge_group.head_sha || github.run_id }}' | |
| cancel-in-progress: ${{ github.event_name != 'workflow_dispatch' }} | |
| jobs: | |
| maintenance-request: | |
| if: github.event_name == 'workflow_dispatch' && inputs.operation == 'capture' | |
| runs-on: ubuntu-slim | |
| steps: | |
| - name: Require explicit main-branch maintenance | |
| run: | | |
| set -eu | |
| if [ "$GITHUB_REF" != 'refs/heads/main' ]; then | |
| echo 'Baseline maintenance must be dispatched from main.' | |
| exit 1 | |
| fi | |
| # Detect lightweight changes. Missing merge-base data fails closed. | |
| check-scope: | |
| if: github.event_name != 'workflow_dispatch' || inputs.operation == 'release-check' | |
| runs-on: ubuntu-slim | |
| permissions: | |
| contents: read | |
| outputs: | |
| docsite_only: ${{ steps.scope.outputs.docsite_only }} | |
| spec_only: ${{ steps.scope.outputs.spec_only }} | |
| tooling_only: ${{ steps.scope.outputs.tooling_only }} | |
| # 'false' only for a pull request whose changes the import graph can | |
| # scope (components, shared modules, docs, records). Anything else, an | |
| # empty value included, runs the full suite: main, release branches, | |
| # the merge queue, release-check dispatches, and shared infrastructure | |
| # (build and test config, the test harness, tokens, themes, root | |
| # dependencies, CI itself). | |
| full_suite: ${{ steps.scope.outputs.full_suite }} | |
| release_bump: ${{ steps.scope.outputs.release_bump }} | |
| release_branch: ${{ steps.release-authority.outputs.branch || steps.main-authority.outputs.branch }} | |
| release_head: ${{ steps.release-authority.outputs.head || steps.main-authority.outputs.head }} | |
| release_plan_digest: ${{ steps.release-authority.outputs.planDigest }} | |
| steps: | |
| # Full history only where the release-branch validator reads it (tags, | |
| # the cut commit, release diffs). A PR's merge commit has the base tip | |
| # as a parent, and a main pre-cut check fetches current main on top, so | |
| # 50 commits are plenty there; the full clone took over a minute. | |
| - uses: actions/checkout@v7 | |
| with: | |
| ref: ${{ github.sha }} | |
| fetch-depth: ${{ ((github.event_name == 'workflow_dispatch' && inputs['release-branch'] != 'main') || (github.event_name == 'pull_request' && startsWith(github.base_ref, 'release/v'))) && '0' || '50' }} | |
| - name: Fetch active release refs | |
| if: >- | |
| (github.event_name == 'workflow_dispatch' && inputs.operation == 'release-check' && inputs['release-branch'] != 'main') || | |
| (github.event_name == 'pull_request' && startsWith(github.base_ref, 'release/v')) | |
| run: git fetch origin '+refs/heads/release/v*:refs/remotes/origin/release/v*' | |
| - name: Validate active release authority | |
| id: release-authority | |
| if: >- | |
| (github.event_name == 'workflow_dispatch' && inputs.operation == 'release-check' && inputs['release-branch'] != 'main') || | |
| (github.event_name == 'pull_request' && startsWith(github.base_ref, 'release/v')) | |
| env: | |
| RELEASE_BRANCH: ${{ github.event_name == 'workflow_dispatch' && inputs['release-branch'] || github.base_ref }} | |
| RELEASE_VERSION: ${{ github.event_name == 'workflow_dispatch' && inputs['release-version'] || '' }} | |
| EXPECTED_HEAD: ${{ github.event_name == 'workflow_dispatch' && inputs['expected-head'] || github.event.pull_request.head.sha }} | |
| PLAN_DIGEST: ${{ github.event_name == 'workflow_dispatch' && inputs['plan-digest'] || '' }} | |
| RECEIPT_HEAD: ${{ github.event_name == 'workflow_dispatch' && github.sha || github.event.pull_request.head.sha }} | |
| REF_NAME: ${{ github.event_name == 'workflow_dispatch' && github.ref_name || github.base_ref }} | |
| MODE: ${{ github.event_name == 'workflow_dispatch' && 'check' || 'pr' }} | |
| run: | | |
| set -eu | |
| TRUSTED_POLICY="$RUNNER_TEMP/release-policy" | |
| mkdir -p "$TRUSTED_POLICY/scripts/release" "$TRUSTED_POLICY/scripts/lib" | |
| git show "origin/$RELEASE_BRANCH:scripts/release/active-release.mjs" \ | |
| > "$TRUSTED_POLICY/scripts/release/active-release.mjs" | |
| git show "origin/$RELEASE_BRANCH:scripts/lib/workspace-globs.mjs" \ | |
| > "$TRUSTED_POLICY/scripts/lib/workspace-globs.mjs" | |
| VALIDATOR="$TRUSTED_POLICY/scripts/release/active-release.mjs" | |
| ACTIVE_BRANCHES=$(node "$VALIDATOR" list-active --root "$GITHUB_WORKSPACE") | |
| ARGS=( | |
| validate | |
| --root "$GITHUB_WORKSPACE" | |
| --mode "$MODE" | |
| --release-branch "$RELEASE_BRANCH" | |
| --expected-head "$EXPECTED_HEAD" | |
| --checkout-sha "$RECEIPT_HEAD" | |
| --ref-name "$REF_NAME" | |
| --active-branches "$ACTIVE_BRANCHES" | |
| ) | |
| if [ "$MODE" = check ]; then | |
| ARGS+=(--release-version "$RELEASE_VERSION" --plan-digest "$PLAN_DIGEST") | |
| REMOTE_HEAD=$(git ls-remote origin "refs/heads/$RELEASE_BRANCH" | awk '{print $1}') | |
| ARGS+=(--remote-head "$REMOTE_HEAD") | |
| fi | |
| node "$VALIDATOR" "${ARGS[@]}" | |
| - name: Validate exact main pre-cut authority | |
| id: main-authority | |
| if: >- | |
| github.event_name == 'workflow_dispatch' && | |
| inputs.operation == 'release-check' && | |
| inputs['release-branch'] == 'main' | |
| env: | |
| EXPECTED_HEAD: ${{ inputs['expected-head'] }} | |
| run: | | |
| set -eu | |
| if [ "$GITHUB_REF" != 'refs/heads/main' ]; then | |
| echo 'Main pre-cut checks must be dispatched from main.' | |
| exit 1 | |
| fi | |
| if ! [[ "$EXPECTED_HEAD" =~ ^[0-9a-f]{40}$ ]]; then | |
| echo 'Main pre-cut checks require an exact full expected head.' | |
| exit 1 | |
| fi | |
| if [ "$GITHUB_SHA" != "$EXPECTED_HEAD" ]; then | |
| echo 'Checked-out main commit does not match expected head.' | |
| exit 1 | |
| fi | |
| REMOTE_HEAD=$(git ls-remote origin refs/heads/main | awk '{print $1}') | |
| if [ -z "$REMOTE_HEAD" ]; then | |
| echo 'Current main head is unavailable.' | |
| exit 1 | |
| fi | |
| git fetch --no-tags origin "$REMOTE_HEAD" | |
| if ! git merge-base --is-ancestor "$EXPECTED_HEAD" "$REMOTE_HEAD"; then | |
| echo 'Checked main commit is not an ancestor of current main.' | |
| exit 1 | |
| fi | |
| printf 'branch=main\nhead=%s\n' "$EXPECTED_HEAD" >> "$GITHUB_OUTPUT" | |
| - name: Fetch base branch | |
| if: github.event_name == 'pull_request' | |
| run: git fetch origin ${{ github.base_ref }} --depth=50 | |
| - name: Determine change scope | |
| id: scope | |
| env: | |
| EVENT_NAME: ${{ github.event_name }} | |
| BASE_REF: ${{ github.base_ref }} | |
| run: | | |
| if [ "$EVENT_NAME" != pull_request ]; then | |
| printf 'docsite_only=false\nspec_only=false\ntooling_only=false\nfull_suite=true\nrelease_bump=false\n' >> "$GITHUB_OUTPUT" | |
| exit 0 | |
| fi | |
| if [[ "$BASE_REF" == release/v* ]]; then | |
| # Release bump PRs contain generated bookkeeping only. The final | |
| # branch head receives one full visual/a11y/RTL release-check. | |
| printf 'docsite_only=false\nspec_only=true\ntooling_only=true\nfull_suite=true\nrelease_bump=true\n' >> "$GITHUB_OUTPUT" | |
| exit 0 | |
| fi | |
| MERGE_BASE=$(git merge-base HEAD origin/${{ github.base_ref }} 2>/dev/null || echo "") | |
| if [ -z "$MERGE_BASE" ]; then | |
| printf 'docsite_only=false\nspec_only=false\ntooling_only=false\nfull_suite=true\nrelease_bump=false\n' >> "$GITHUB_OUTPUT" | |
| exit 0 | |
| fi | |
| echo 'release_bump=false' >> "$GITHUB_OUTPUT" | |
| CLASSIFIER_ROOT="$RUNNER_TEMP/change-scope" | |
| CLASSIFIER_DIR="$CLASSIFIER_ROOT/.github/scripts" | |
| REGISTRY_DIR="$CLASSIFIER_ROOT/scripts" | |
| mkdir -p "$CLASSIFIER_DIR" "$REGISTRY_DIR" | |
| CLASSIFIER="$CLASSIFIER_DIR/change-scope.cjs" | |
| MATCHER="$CLASSIFIER_DIR/knowledge-paths.cjs" | |
| REGISTRY="$REGISTRY_DIR/component-packages.cjs" | |
| if git show "origin/${{ github.base_ref }}:.github/scripts/change-scope.cjs" > "$CLASSIFIER" 2>/dev/null \ | |
| && git show "origin/${{ github.base_ref }}:.github/scripts/knowledge-paths.cjs" > "$MATCHER" 2>/dev/null \ | |
| && git show "origin/${{ github.base_ref }}:scripts/component-packages.cjs" > "$REGISTRY" 2>/dev/null; then | |
| git diff --name-status "$MERGE_BASE"...HEAD \ | |
| | node "$CLASSIFIER" --github-output | |
| else | |
| # Missing trusted policy or dependencies cannot grant a specialized | |
| # lane. Run broad CI until the base branch supplies the full classifier. | |
| printf 'docsite_only=false\nspec_only=false\ntooling_only=false\nfull_suite=true\n' \ | |
| >> "$GITHUB_OUTPUT" | |
| fi | |
| # Generated-only version PR lane. It validates release bookkeeping in a few | |
| # minutes; the merged branch head receives one full visual/a11y/RTL projection. | |
| release-bump: | |
| needs: [check-scope] | |
| if: ${{ github.event_name == 'pull_request' && needs.check-scope.outputs.release_bump == 'true' }} | |
| runs-on: 2-core-ubuntu-arm | |
| timeout-minutes: 15 | |
| permissions: | |
| contents: read | |
| steps: | |
| - uses: actions/checkout@v7 | |
| with: | |
| ref: ${{ github.event.pull_request.head.sha }} | |
| fetch-depth: 0 | |
| - name: Fetch release refs, base, and trusted release policy | |
| run: | | |
| git fetch origin '+refs/heads/release/v*:refs/remotes/origin/release/v*' | |
| git fetch origin "${{ github.base_ref }}" --depth=50 | |
| TRUSTED_POLICY="$RUNNER_TEMP/release-policy" | |
| mkdir -p "$TRUSTED_POLICY/scripts/release" "$TRUSTED_POLICY/scripts/lib" | |
| git show "origin/${{ github.base_ref }}:scripts/release/active-release.mjs" \ | |
| > "$TRUSTED_POLICY/scripts/release/active-release.mjs" | |
| git show "origin/${{ github.base_ref }}:scripts/lib/workspace-globs.mjs" \ | |
| > "$TRUSTED_POLICY/scripts/lib/workspace-globs.mjs" | |
| - name: Setup Node and pnpm | |
| uses: ./.github/actions/setup | |
| - name: Require generated-only release bookkeeping | |
| run: | | |
| node "$RUNNER_TEMP/release-policy/scripts/release/active-release.mjs" validate-diff \ | |
| --root "$GITHUB_WORKSPACE" \ | |
| --base "origin/${{ github.base_ref }}" \ | |
| --head "${{ github.event.pull_request.head.sha }}" | |
| - name: Validate branch, head, plan, versions, and Changeset consumption | |
| run: | | |
| set -eu | |
| VALIDATOR="$RUNNER_TEMP/release-policy/scripts/release/active-release.mjs" | |
| ACTIVE_BRANCHES=$(node "$VALIDATOR" list-active --root "$GITHUB_WORKSPACE") | |
| node "$VALIDATOR" validate \ | |
| --root "$GITHUB_WORKSPACE" \ | |
| --mode pr \ | |
| --release-branch "${{ github.base_ref }}" \ | |
| --expected-head "${{ github.event.pull_request.head.sha }}" \ | |
| --checkout-sha "${{ github.event.pull_request.head.sha }}" \ | |
| --ref-name "${{ github.base_ref }}" \ | |
| --active-branches "$ACTIVE_BRANCHES" \ | |
| | tee release-bump-receipt.json | |
| - name: Validate generated changelogs and codemods | |
| run: | | |
| pnpm check:changesets | |
| node scripts/format-changelogs.mjs --check | |
| VERSION=$(node -p "require('./.release/active.json').version") | |
| pnpm exec vitest run \ | |
| "packages/cli/assets/codemods/transforms/v${VERSION}/__tests__" \ | |
| packages/cli/assets/codemods/__tests__/registry.test.mjs | |
| - name: Upload exact-head release bump receipt | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: release-bump-receipt-${{ github.event.pull_request.head.sha }} | |
| path: release-bump-receipt.json | |
| retention-days: 30 | |
| release-merge-back: | |
| name: release-merge-back | |
| if: ${{ github.event_name == 'pull_request' && github.base_ref == 'main' }} | |
| # Match the stable publisher so byte parity covers the same packed manifest. | |
| runs-on: 4-core-ubuntu | |
| timeout-minutes: 15 | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: Checkout merge-back candidate | |
| uses: actions/checkout@v7 | |
| with: | |
| fetch-depth: 0 | |
| - name: Detect the release-merge-back branch contract | |
| id: release-merge-back-scope | |
| env: | |
| MERGE_BRANCH: ${{ github.head_ref }} | |
| run: | | |
| set -eu | |
| case "$MERGE_BRANCH" in | |
| chore/merge-v*-to-main) | |
| VERSION=${MERGE_BRANCH#chore/merge-v} | |
| VERSION=${VERSION%-to-main} | |
| printf '%s' "$VERSION" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+$' | |
| echo 'required=true' >> "$GITHUB_OUTPUT" | |
| ;; | |
| *) | |
| echo 'required=false' >> "$GITHUB_OUTPUT" | |
| ;; | |
| esac | |
| - name: Fetch release authority and trusted validator | |
| if: steps.release-merge-back-scope.outputs.required == 'true' | |
| run: | | |
| set -eu | |
| git fetch origin main 'refs/tags/v*:refs/tags/v*' '+refs/heads/release/v*:refs/remotes/origin/release/v*' | |
| TRUSTED_POLICY="$RUNNER_TEMP/release-policy" | |
| mkdir -p "$TRUSTED_POLICY/scripts/release" "$TRUSTED_POLICY/scripts/lib" | |
| git show origin/main:scripts/release/active-release.mjs \ | |
| > "$TRUSTED_POLICY/scripts/release/active-release.mjs" | |
| git show origin/main:scripts/lib/workspace-globs.mjs \ | |
| > "$TRUSTED_POLICY/scripts/lib/workspace-globs.mjs" | |
| - name: Validate published bytes and consumed-only Changeset merge-back | |
| if: steps.release-merge-back-scope.outputs.required == 'true' | |
| env: | |
| MERGE_BRANCH: ${{ github.head_ref }} | |
| run: | | |
| set -eu | |
| VERSION=${MERGE_BRANCH#chore/merge-v} | |
| VERSION=${VERSION%-to-main} | |
| printf '%s' "$VERSION" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+$' | |
| VALIDATOR="$RUNNER_TEMP/release-policy/scripts/release/active-release.mjs" | |
| ACTIVE_BRANCHES=$(node "$VALIDATOR" list-active --root "$GITHUB_WORKSPACE") | |
| node "$VALIDATOR" validate-merge-back \ | |
| --root "$GITHUB_WORKSPACE" \ | |
| --base origin/main \ | |
| --release-ref "v$VERSION" \ | |
| --active-branches "$ACTIVE_BRANCHES" | |
| - name: Setup Node and pnpm for published-byte verification | |
| if: steps.release-merge-back-scope.outputs.required == 'true' | |
| uses: ./.github/actions/setup | |
| with: | |
| install: 'false' | |
| - name: Verify immutable tag package bytes match npm | |
| if: steps.release-merge-back-scope.outputs.required == 'true' | |
| env: | |
| MERGE_BRANCH: ${{ github.head_ref }} | |
| run: | | |
| set -eu | |
| VERSION=${MERGE_BRANCH#chore/merge-v} | |
| VERSION=${VERSION%-to-main} | |
| TAG_ROOT="$RUNNER_TEMP/release-tag" | |
| git worktree add --detach "$TAG_ROOT" "v$VERSION" | |
| cd "$TAG_ROOT" | |
| pnpm install --frozen-lockfile | |
| pnpm build | |
| node scripts/release/verify-published.mjs --version "$VERSION" | |
| # Required docsite owner: data tests plus the production browser contract. | |
| # Historical required check name (AST-030 FR7). It joins the two docsite | |
| # owners, which run side by side: the browser contract (~10 minutes) used to | |
| # be followed by this job's own generation and tests (~2.5 minutes). The | |
| # spec-only lane validates spec records here, where it always has. | |
| docsite-test: | |
| needs: [check-scope, docsite-browser, docsite-data] | |
| if: ${{ github.event_name != 'workflow_dispatch' && needs.check-scope.outputs.release_bump != 'true' && always() && !cancelled() }} | |
| runs-on: 2-core-ubuntu-arm | |
| timeout-minutes: 15 | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: Require successful scope classification | |
| if: needs.check-scope.result != 'success' | |
| run: | | |
| echo "Change scope could not be classified; refusing to skip required work." | |
| exit 1 | |
| - name: Require successful docsite browser contract | |
| if: needs.check-scope.outputs.spec_only != 'true' && needs.check-scope.outputs.tooling_only != 'true' | |
| env: | |
| DOCSITE_BROWSER_RESULT: ${{ needs.docsite-browser.result }} | |
| run: test "$DOCSITE_BROWSER_RESULT" = 'success' | |
| - name: Require successful docsite data generation and tests | |
| if: needs.check-scope.outputs.spec_only != 'true' && needs.check-scope.outputs.tooling_only != 'true' | |
| env: | |
| DOCSITE_DATA_RESULT: ${{ needs.docsite-data.result }} | |
| run: test "$DOCSITE_DATA_RESULT" = 'success' | |
| - name: Skip docsite work for Node tooling | |
| if: needs.check-scope.outputs.tooling_only == 'true' | |
| run: echo "Node-tooling PR — docsite generation is not an owned check" | |
| - uses: actions/checkout@v7 | |
| if: needs.check-scope.outputs.spec_only == 'true' | |
| # Spec validation imports the canonical CLI discovery path, so the | |
| # lightweight docs path needs workspace dependencies too. | |
| - uses: ./.github/actions/setup | |
| if: needs.check-scope.outputs.spec_only == 'true' | |
| - name: Validate spec records | |
| if: needs.check-scope.outputs.spec_only == 'true' | |
| run: node scripts/check-knowledge.mjs | |
| # Docsite data generation and tests. Its outcome feeds docsite-test. | |
| docsite-data: | |
| needs: [check-scope] | |
| if: github.event_name != 'workflow_dispatch' && needs.check-scope.outputs.spec_only != 'true' && needs.check-scope.outputs.tooling_only != 'true' | |
| runs-on: 2-core-ubuntu-arm | |
| timeout-minutes: 15 | |
| permissions: | |
| contents: read | |
| steps: | |
| - uses: actions/checkout@v7 | |
| - uses: ./.github/actions/setup | |
| # Docsite `generate` runs `astryx theme build`, which imports the compiled | |
| # @astryxdesign/core/theme entry (dist/theme/index.js). Build core first so that | |
| # entry exists — otherwise generate fails with "Cannot find module". | |
| - name: Build core package | |
| if: needs.check-scope.outputs.spec_only != 'true' && needs.check-scope.outputs.tooling_only != 'true' | |
| run: pnpm -F @astryxdesign/core build | |
| # The generated preview registry imports every configured canary component | |
| # package. Build those exports so Vitest exercises the same graph as the | |
| # canary deployment. | |
| - name: Build canary component packages | |
| if: needs.check-scope.outputs.spec_only != 'true' && needs.check-scope.outputs.tooling_only != 'true' | |
| run: | | |
| pnpm -F @astryxdesign/lab build | |
| pnpm -F @astryxdesign/charts build | |
| pnpm -F @astryxdesign/richtext build | |
| pnpm -F @astryxdesign/vega build | |
| - name: Generate and test docsite data | |
| if: needs.check-scope.outputs.spec_only != 'true' && needs.check-scope.outputs.tooling_only != 'true' | |
| run: pnpm -F @astryxdesign/docsite generate && pnpm -F @astryxdesign/docsite test | |
| # Docsite browser contracts. The playground preview runs user-authored code | |
| # in a sandboxed iframe whose only tie to the page is a nonce-attested | |
| # MessagePort handshake (apps/docsite/src/app/playground/previewChannel.ts). | |
| # jsdom can drive that state machine but cannot prove the integration: that | |
| # the frame's real `load` event reaches it, that a replaced document is torn | |
| # down and the current code and theme reach its successor, and that a | |
| # document previewed code navigated the frame to receives nothing. Only the | |
| # production build has the opaque-origin sandbox at all, so this job builds | |
| # the docsite and drives `next start` in Chromium. Its outcome feeds the | |
| # existing required docsite-test context; it is not another required lane. | |
| docsite-browser: | |
| needs: [check-scope] | |
| if: github.event_name != 'workflow_dispatch' && needs.check-scope.outputs.spec_only != 'true' && needs.check-scope.outputs.tooling_only != 'true' | |
| # The longest docsite owner; the Next.js production build uses every core | |
| # it gets. | |
| runs-on: 4-core-ubuntu | |
| timeout-minutes: 15 | |
| permissions: | |
| contents: read | |
| steps: | |
| - uses: actions/checkout@v7 | |
| - uses: ./.github/actions/setup | |
| - name: Install Playwright | |
| run: npx playwright install chromium | |
| # The production build imports every theme package's built entry and the | |
| # canary component packages, on top of core. Core builds first; the rest | |
| # depend on it and not on each other, so they build side by side. | |
| - name: Build docsite workspace dependencies | |
| run: | | |
| pnpm -F @astryxdesign/core build | |
| pnpm --workspace-concurrency=4 \ | |
| -F @astryxdesign/lab \ | |
| -F @astryxdesign/charts \ | |
| -F @astryxdesign/richtext \ | |
| -F @astryxdesign/vega \ | |
| -F @astryxdesign/theme-neutral \ | |
| -F @astryxdesign/theme-matcha \ | |
| -F @astryxdesign/theme-stone \ | |
| -F @astryxdesign/theme-gothic \ | |
| -F @astryxdesign/theme-chocolate \ | |
| -F @astryxdesign/theme-y2k \ | |
| -F @astryxdesign/theme-butter \ | |
| build | |
| - name: Build the docsite | |
| run: pnpm -F @astryxdesign/docsite build | |
| - name: Run docsite browser contracts | |
| run: pnpm test:docsite-browser | |
| - name: Upload docsite browser evidence | |
| if: always() | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: docsite-browser-evidence | |
| path: test-results/docsite/ | |
| if-no-files-found: error | |
| retention-days: 7 | |
| # Lightweight check — does the PR touch any published components? | |
| # Gates pr-a11y and pr-rtl to avoid unnecessary work. | |
| # | |
| # `scripts/component-packages.cjs` owns the component source roots used here | |
| # and by the RTL roster. `analyze-pr.js` still decides which changed components | |
| # each downstream audit receives. When those projections disagree the audits | |
| # silently no-op, so harness/registry changes also exercise the RTL smoke scope. | |
| # Spec-only changes keep only the trusted scope classifier and the | |
| # knowledge validator below. Unrelated component discovery must not take a | |
| # runner or fan out into visual, accessibility, or RTL work. | |
| check-components: | |
| needs: [check-scope] | |
| if: (github.event_name == 'pull_request' && needs.check-scope.outputs.spec_only != 'true') || (github.event_name == 'workflow_dispatch' && inputs.operation == 'release-check') | |
| runs-on: ubuntu-slim | |
| permissions: | |
| contents: read | |
| outputs: | |
| has_components: ${{ steps.check.outputs.has_components }} | |
| has_rtl_components: ${{ steps.check.outputs.has_rtl_components }} | |
| has_rtl_harness: ${{ steps.check.outputs.has_rtl_harness }} | |
| force_full_component_audits: ${{ steps.check.outputs.force_full_component_audits }} | |
| # Stable visual scope is separate from component scope: Core and the | |
| # non-private shipped themes participate; canaryOnly packages do not. | |
| has_stable_visual: ${{ steps.check.outputs.has_stable_visual }} | |
| broad_stable_visual: ${{ steps.check.outputs.broad_stable_visual }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v7 | |
| with: | |
| # Depth 50 (same as check-scope) so the three-dot diff below can find | |
| # a merge base. With the default depth of 1 the diff fails with | |
| # "no merge base", the error is swallowed by the pipeline, and | |
| # has_components silently becomes false — skipping pr-a11y entirely. | |
| fetch-depth: 50 | |
| - name: Fetch base branch | |
| if: github.event_name == 'pull_request' | |
| run: git fetch origin ${{ github.base_ref }} --depth=50 | |
| - name: Check for component changes | |
| id: check | |
| env: | |
| SCOPED: ${{ github.event_name == 'pull_request' && needs.check-scope.outputs.full_suite == 'false' }} | |
| run: | | |
| if [ "${{ github.event_name }}" = 'workflow_dispatch' ]; then | |
| printf 'has_components=true\nhas_rtl_components=true\nhas_rtl_harness=true\nforce_full_component_audits=true\nhas_stable_visual=true\nbroad_stable_visual=true\n' >> "$GITHUB_OUTPUT" | |
| exit 0 | |
| fi | |
| if [ "${{ needs.check-scope.outputs.docsite_only }}" = "true" ] \ | |
| || [ "${{ needs.check-scope.outputs.spec_only }}" = "true" ] \ | |
| || [ "${{ needs.check-scope.outputs.tooling_only }}" = "true" ]; then | |
| printf 'has_components=false\nhas_rtl_components=false\nhas_rtl_harness=false\nforce_full_component_audits=false\nhas_stable_visual=false\n' >> "$GITHUB_OUTPUT" | |
| echo "Trusted specialized lane — component audits explicitly not applicable." | |
| exit 0 | |
| fi | |
| if ! MERGE_BASE=$(git merge-base HEAD origin/${{ github.base_ref }} 2>/dev/null); then | |
| echo "::warning::No merge base between HEAD and origin/${{ github.base_ref }} — running full component audits" | |
| printf 'has_components=true\nhas_rtl_components=true\nhas_rtl_harness=true\nforce_full_component_audits=true\n' >> "$GITHUB_OUTPUT" | |
| echo "has_stable_visual=true" >> "$GITHUB_OUTPUT" | |
| echo "broad_stable_visual=true" >> "$GITHUB_OUTPUT" | |
| exit 0 | |
| fi | |
| POLICY_ROOT="$RUNNER_TEMP/component-audit-scope" | |
| mkdir -p "$POLICY_ROOT/.github/scripts" "$POLICY_ROOT/scripts" | |
| SCOPE="$POLICY_ROOT/.github/scripts/component-audit-scope.cjs" | |
| REGISTRY="$POLICY_ROOT/scripts/component-packages.cjs" | |
| if git show "origin/${{ github.base_ref }}:.github/scripts/component-audit-scope.cjs" > "$SCOPE" 2>/dev/null \ | |
| && git show "origin/${{ github.base_ref }}:.github/scripts/knowledge-paths.cjs" > "$POLICY_ROOT/.github/scripts/knowledge-paths.cjs" 2>/dev/null \ | |
| && git show "origin/${{ github.base_ref }}:scripts/component-packages.cjs" > "$REGISTRY" 2>/dev/null; then | |
| git diff --name-status "$MERGE_BASE"...HEAD \ | |
| | node "$SCOPE" --registry "$REGISTRY" --github-output | |
| else | |
| echo "::warning::Trusted component audit policy is unavailable — running full component audits" | |
| printf 'has_components=true\nhas_rtl_components=true\nhas_rtl_harness=true\nforce_full_component_audits=true\n' >> "$GITHUB_OUTPUT" | |
| fi | |
| FILES=$(git diff --name-only "$MERGE_BASE"...HEAD) | |
| # One classifier owns the release-channel rule. It reads each | |
| # package's `astryx.canaryOnly` metadata rather than hard-coding | |
| # today's Lab/charts/richtext/vega list. | |
| # A pull request that runs what it reaches audits a shared Core | |
| # module through its reverse dependents (spec:AST-030 FR13). | |
| VISUAL_ARGS=() | |
| if [ "$SCOPED" = true ]; then VISUAL_ARGS=(--scoped); fi | |
| printf '%s\n' "$FILES" \ | |
| | node .github/scripts/visual-scope.mjs --github-output "$GITHUB_OUTPUT" "${VISUAL_ARGS[@]}" | |
| # Tests run as two parallel lanes joined by `test` below. | |
| # | |
| # They used to be one `pnpm test` on a 2-core runner, which ran both Vitest | |
| # projects back to back and was terminated around 20 minutes with no summary | |
| # — no assertion output, so nothing said which suite was at fault. `main` was | |
| # already at ~19m15, so the budget, not any one test, was the defect. | |
| # | |
| # The projects are independent by construction (see vitest.config.ts: `ui` is | |
| # jsdom + StyleX, `node` is everything else), so running them as two jobs | |
| # costs no duplicate execution. They do NOT carry half the work each: on this | |
| # CI, `ui` is ~5x the heavier lane, so it takes the larger runner. | |
| # | |
| # The earlier local figure that put `node` ahead (570s vs 244s) was not a | |
| # comparable measurement — only the node run was bounded to a small worker | |
| # pool, and node is the project whose cost is per-assertion CLI subprocesses. | |
| # | |
| # The repo-wide guardrail steps ride `test-ui` (~18s of it). | |
| # | |
| # `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. | |
| test-ui: | |
| name: test-ui (${{ matrix.shard }}/${{ strategy.job-total }}) | |
| needs: [check-scope] | |
| if: ${{ github.event_name != 'workflow_dispatch' && always() && !cancelled() && needs.check-scope.outputs.spec_only != 'true' }} | |
| # One runner ran the whole UI project in ~16 minutes and set the PR's wall | |
| # time. Vitest's --shard gives each leg an equal share of the files; the | |
| # two slowest files (~3.5 minutes each) bound a leg, so more legs stop | |
| # paying. `test` joins the legs: the job result is success only when | |
| # every leg passed. | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| shard: [1, 2, 3, 4] | |
| runs-on: 4-core-ubuntu | |
| timeout-minutes: 15 | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: Require successful scope classification | |
| if: needs.check-scope.result != 'success' | |
| run: | | |
| echo "Change scope could not be classified; refusing to skip required work." | |
| exit 1 | |
| - name: Skip heavy work for a specialized lane | |
| if: needs.check-scope.outputs.docsite_only == 'true' || needs.check-scope.outputs.spec_only == 'true' || needs.check-scope.outputs.tooling_only == 'true' | |
| run: echo "Specialized PR lane — skipping unrelated test suite" | |
| # Two commits: a pull request's merge commit and its base parent, the | |
| # diff a scoped run follows. | |
| - uses: actions/checkout@v7 | |
| if: needs.check-scope.outputs.docsite_only != 'true' && needs.check-scope.outputs.spec_only != 'true' && needs.check-scope.outputs.tooling_only != 'true' | |
| with: | |
| fetch-depth: 2 | |
| - uses: ./.github/actions/setup | |
| if: needs.check-scope.outputs.docsite_only != 'true' && needs.check-scope.outputs.spec_only != 'true' && needs.check-scope.outputs.tooling_only != 'true' | |
| - name: Check knowledge schema history | |
| if: >- | |
| matrix.shard == 1 && | |
| 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' | |
| run: | | |
| git fetch origin "${{ github.event.pull_request.base.sha }}" --depth=1 | |
| node scripts/check-knowledge.mjs --base "${{ github.event.pull_request.base.sha }}" | |
| - name: Check copyright headers | |
| if: matrix.shard == 1 && needs.check-scope.outputs.docsite_only != 'true' && needs.check-scope.outputs.spec_only != 'true' && needs.check-scope.outputs.tooling_only != 'true' | |
| run: ./scripts/add-copyright.sh --check | |
| - name: Check package.json exports are in sync | |
| if: matrix.shard == 1 && needs.check-scope.outputs.docsite_only != 'true' && needs.check-scope.outputs.spec_only != 'true' && needs.check-scope.outputs.tooling_only != 'true' | |
| run: node scripts/sync-exports.js --check | |
| - name: Verify the published CLI ./api type surface | |
| if: matrix.shard == 1 && needs.check-scope.outputs.docsite_only != 'true' && needs.check-scope.outputs.spec_only != 'true' && needs.check-scope.outputs.tooling_only != 'true' | |
| run: node .github/scripts/cli-api-types-verify.mjs | |
| - name: Check token docs are in sync | |
| if: matrix.shard == 1 && needs.check-scope.outputs.docsite_only != 'true' && needs.check-scope.outputs.spec_only != 'true' && needs.check-scope.outputs.tooling_only != 'true' | |
| run: node scripts/generate-token-docs.mjs --check | |
| # Fails when the lab readiness manifest claims a check the source tree | |
| # contradicts — the report is derived, never hand-maintained. | |
| - name: Check lab readiness manifest is current | |
| if: matrix.shard == 1 && needs.check-scope.outputs.docsite_only != 'true' && needs.check-scope.outputs.spec_only != 'true' && needs.check-scope.outputs.tooling_only != 'true' | |
| run: pnpm lab:readiness:check | |
| # A scoped pull request runs the tests Vitest's module graph relates to | |
| # its diff against the base (`--changed`): the changed tests, and every | |
| # test that imports a changed module, however indirectly. Anything else | |
| # runs every test. | |
| - name: Run this shard of the UI tests | |
| env: | |
| SCOPED: ${{ github.event_name == 'pull_request' && needs.check-scope.outputs.full_suite == 'false' }} | |
| run: | | |
| if [ "$SCOPED" = true ]; then | |
| pnpm test:ui --changed=HEAD^1 --passWithNoTests --shard=${{ matrix.shard }}/${{ strategy.job-total }} | |
| # Tests no module graph relates to the change run too: guards | |
| # that read sources, and tests that load a changed package from | |
| # its build (by name or its dist/). | |
| # The list goes through a file so a failing lister fails the step. | |
| node .github/scripts/fs-guard-tests.mjs --changed HEAD^1 > "$RUNNER_TEMP/fs-guards.txt" | |
| mapfile -t GUARDS < "$RUNNER_TEMP/fs-guards.txt" | |
| if [ "${#GUARDS[@]}" -gt 0 ]; then | |
| pnpm test:ui --passWithNoTests --shard=${{ matrix.shard }}/${{ strategy.job-total }} "${GUARDS[@]}" | |
| fi | |
| else | |
| pnpm test:ui --shard=${{ matrix.shard }}/${{ strategy.job-total }} | |
| fi | |
| if: needs.check-scope.outputs.docsite_only != 'true' && needs.check-scope.outputs.spec_only != 'true' && needs.check-scope.outputs.tooling_only != 'true' | |
| # A child process isolates engine state, not CPU or memory contention. | |
| # FR23 must wait until this runner's other UI workers have exited | |
| # (AST-036); the other shards run on other machines. | |
| - name: Run the isolated Markdown benchmark | |
| run: pnpm test:ui:isolated | |
| if: matrix.shard == 1 && needs.check-scope.outputs.docsite_only != 'true' && needs.check-scope.outputs.spec_only != 'true' && needs.check-scope.outputs.tooling_only != 'true' | |
| test-node: | |
| name: test-node (${{ matrix.shard }}/${{ strategy.job-total }}) | |
| needs: [check-scope] | |
| if: ${{ github.event_name != 'workflow_dispatch' && always() && !cancelled() && needs.check-scope.outputs.spec_only != 'true' }} | |
| # One runner ran the Node project in ~12 minutes. Vitest's --shard splits | |
| # the files across the legs; `test` joins them. | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| shard: [1, 2, 3, 4] | |
| # Vitest runs one test file per CPU beyond the first, so the 2-core runner | |
| # ran this suite one file at a time (~23 min). Four cores give it three. | |
| runs-on: 4-core-ubuntu | |
| timeout-minutes: 15 | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: Require successful scope classification | |
| if: needs.check-scope.result != 'success' | |
| run: | | |
| echo "Change scope could not be classified; refusing to skip required work." | |
| exit 1 | |
| - name: Skip heavy work for a specialized lane | |
| if: needs.check-scope.outputs.docsite_only == 'true' || needs.check-scope.outputs.spec_only == 'true' | |
| run: echo "Specialized PR lane — skipping unrelated test suite" | |
| - uses: actions/checkout@v7 | |
| if: needs.check-scope.outputs.docsite_only != 'true' && needs.check-scope.outputs.spec_only != 'true' | |
| with: | |
| fetch-depth: 2 | |
| - uses: ./.github/actions/setup | |
| if: needs.check-scope.outputs.docsite_only != 'true' && needs.check-scope.outputs.spec_only != 'true' | |
| # Before Vitest starts. A scoped run's `--changed` walks the tests' | |
| # import graphs before the global setup builds Core, and Vite answers an | |
| # unresolvable Core, an optional peer of the CLI, with a stub it caches | |
| # for the run: every theme-build test then fails with "Could not resolve | |
| # "@astryxdesign/core/theme" imported by "@astryxdesign/cli"". The global | |
| # setup then finds Core built and skips its own build. | |
| - name: Build core package | |
| if: needs.check-scope.outputs.docsite_only != 'true' && needs.check-scope.outputs.spec_only != 'true' | |
| run: pnpm -F @astryxdesign/core build | |
| # Scoped like test-ui's run. | |
| - name: Run this shard of the Node tests | |
| env: | |
| SCOPED: ${{ github.event_name == 'pull_request' && needs.check-scope.outputs.full_suite == 'false' }} | |
| run: | | |
| if [ "$SCOPED" = true ]; then | |
| pnpm test:node --changed=HEAD^1 --passWithNoTests --shard=${{ matrix.shard }}/${{ strategy.job-total }} | |
| # Tests no module graph relates to the change run too: guards | |
| # that read sources, and tests that load a changed package from | |
| # its build (by name or its dist/). | |
| # The list goes through a file so a failing lister fails the step. | |
| node .github/scripts/fs-guard-tests.mjs --changed HEAD^1 > "$RUNNER_TEMP/fs-guards.txt" | |
| mapfile -t GUARDS < "$RUNNER_TEMP/fs-guards.txt" | |
| if [ "${#GUARDS[@]}" -gt 0 ]; then | |
| pnpm test:node --passWithNoTests --shard=${{ matrix.shard }}/${{ strategy.job-total }} "${GUARDS[@]}" | |
| fi | |
| else | |
| pnpm test:node --shard=${{ matrix.shard }}/${{ strategy.job-total }} | |
| fi | |
| if: needs.check-scope.outputs.docsite_only != 'true' && needs.check-scope.outputs.spec_only != 'true' | |
| # Theme-family compilation is owned by `theme-build`, not Build. Until | |
| # that surface has an admitted dedicated lane, broad CI keeps its browser | |
| # contract inside the existing Node test owner rather than `test-build`. | |
| # One leg runs it. | |
| - name: Install Playwright for theme-family contract | |
| if: matrix.shard == 1 && needs.check-scope.outputs.docsite_only != 'true' && needs.check-scope.outputs.spec_only != 'true' && needs.check-scope.outputs.tooling_only != 'true' | |
| run: npx playwright install chromium | |
| - name: Run the theme-family contract | |
| if: matrix.shard == 1 && needs.check-scope.outputs.docsite_only != 'true' && needs.check-scope.outputs.spec_only != 'true' && needs.check-scope.outputs.tooling_only != 'true' | |
| run: pnpm test:theme-family | |
| # Native Swift: the Swift packages of the experimental, canary-only | |
| # @astryxdesign/native (AST-082) build and test only on macOS. They are | |
| # coverage inside the shared surface (AST-030 FR11), so `test` joins | |
| # test-native-swift. A Linux job first decides whether the change touches | |
| # Swift under packages/native or the lane's own script; only then does | |
| # test-native-swift take a macOS runner, and otherwise it passes on Linux | |
| # without work. | |
| native-swift-scope: | |
| needs: [check-scope] | |
| if: ${{ github.event_name != 'workflow_dispatch' && always() && !cancelled() && needs.check-scope.outputs.spec_only != 'true' }} | |
| runs-on: ubuntu-slim | |
| permissions: | |
| contents: read | |
| outputs: | |
| applies: ${{ steps.scope.outputs.applies }} | |
| steps: | |
| - name: Require successful scope classification | |
| if: needs.check-scope.result != 'success' | |
| run: | | |
| echo "Change scope could not be classified; refusing to skip required work." | |
| exit 1 | |
| # The merge commit and its parents (see interaction-scope). | |
| - uses: actions/checkout@v7 | |
| if: needs.check-scope.outputs.docsite_only != 'true' && needs.check-scope.outputs.tooling_only != 'true' | |
| with: | |
| fetch-depth: 2 | |
| # The helper comes from the base, since an older head lacks it. Exit 1 | |
| # means out of scope; 0 in scope; 2 unknown, so the Swift work runs. | |
| - name: Decide whether native Swift changed | |
| id: scope | |
| env: | |
| EVENT_NAME: ${{ github.event_name }} | |
| DOCSITE_ONLY: ${{ needs.check-scope.outputs.docsite_only }} | |
| TOOLING_ONLY: ${{ needs.check-scope.outputs.tooling_only }} | |
| BASE_SHA: ${{ github.event.pull_request.base.sha || github.event.merge_group.base_sha }} | |
| run: | | |
| if [ "$DOCSITE_ONLY" = true ] || [ "$TOOLING_ONLY" = true ]; then | |
| echo 'Specialized lane; no native Swift work.' | |
| echo 'applies=false' >> "$GITHUB_OUTPUT" | |
| exit 0 | |
| fi | |
| # A pull request diffs against its merge commit's first parent, as | |
| # interaction-scope does; the merge queue keeps its base. | |
| if [ "$EVENT_NAME" = pull_request ] \ | |
| && [ "$(git rev-list --parents -n 1 HEAD 2>/dev/null | wc -w)" -eq 3 ]; then | |
| BASE_SHA="$(git rev-parse HEAD^1)" | |
| fi | |
| scope=2 | |
| helper="$(mktemp)" | |
| if [ -n "$BASE_SHA" ] \ | |
| && git fetch --quiet --no-tags --depth=1 origin "$BASE_SHA" \ | |
| && git show "$BASE_SHA:.github/scripts/pr-scope-touches.sh" > "$helper"; then | |
| scope=0 | |
| bash "$helper" "$BASE_SHA" '^packages/native/.*(\.swift|/Package\.swift)$|^\.github/scripts/native-swift\.sh$' || scope=$? | |
| fi | |
| if [ "$scope" = 1 ]; then | |
| echo 'No native Swift change; nothing to build.' | |
| echo 'applies=false' >> "$GITHUB_OUTPUT" | |
| else | |
| echo 'applies=true' >> "$GITHUB_OUTPUT" | |
| fi | |
| test-native-swift: | |
| needs: [check-scope, native-swift-scope] | |
| if: ${{ github.event_name != 'workflow_dispatch' && always() && !cancelled() && needs.check-scope.outputs.spec_only != 'true' }} | |
| runs-on: ${{ needs.native-swift-scope.outputs.applies == 'true' && 'macos-15' || 'ubuntu-slim' }} | |
| timeout-minutes: 30 | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: Require a decided Swift scope | |
| if: needs.native-swift-scope.result != 'success' | |
| run: | | |
| echo "Native Swift scope could not be decided; refusing to skip required work." | |
| exit 1 | |
| - name: Skip Swift work outside its scope | |
| if: needs.native-swift-scope.outputs.applies != 'true' | |
| run: echo "No native Swift change in this scope." | |
| - uses: actions/checkout@v7 | |
| if: needs.native-swift-scope.outputs.applies == 'true' | |
| # The steps live in native-swift.sh, which is in the native Swift scope, | |
| # so a change to them runs on its own pull request. | |
| - name: Build and test each native Swift package | |
| if: needs.native-swift-scope.outputs.applies == 'true' | |
| run: bash .github/scripts/native-swift.sh | |
| # Public registry contract. Generation proves schema, dependency, route-lock, | |
| # alias, and release-gating invariants; the final step drives every canonical | |
| # item through the exact pinned ShadCN client and compiles every written source. | |
| registry-contract: | |
| name: registry-contract (${{ matrix.leg }}) | |
| needs: [check-scope] | |
| if: ${{ github.event_name != 'workflow_dispatch' && always() && !cancelled() && needs.check-scope.outputs.spec_only != 'true' }} | |
| # The preview and hidden production registries are generated and verified | |
| # independently, so each gets its own leg (~9 minutes in one job). `test` | |
| # joins them: the job result is success only when both passed. | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| leg: [preview, production] | |
| runs-on: 4-core-ubuntu | |
| timeout-minutes: 15 | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: Require successful scope classification | |
| if: needs.check-scope.result != 'success' | |
| run: | | |
| echo "Change scope could not be classified; refusing to skip required work." | |
| exit 1 | |
| - name: Skip registry work for spec-only changes | |
| if: needs.check-scope.outputs.spec_only == 'true' | |
| run: echo "Spec-only PR — public registry output cannot change" | |
| - uses: actions/checkout@v7 | |
| if: needs.check-scope.outputs.spec_only != 'true' | |
| - uses: ./.github/actions/setup | |
| if: needs.check-scope.outputs.spec_only != 'true' | |
| - name: Build registry package exports | |
| if: needs.check-scope.outputs.spec_only != 'true' | |
| run: pnpm build | |
| - name: Verify hidden production registry contract | |
| if: matrix.leg == 'production' && needs.check-scope.outputs.spec_only != 'true' | |
| run: node internal/shadcn-registry/verify-production-gate.mjs | |
| - name: Generate and validate the complete preview registry | |
| if: matrix.leg == 'preview' && needs.check-scope.outputs.spec_only != 'true' | |
| env: | |
| DOCSITE_TARGET: canary | |
| run: node apps/docsite/scripts/generate-data.mjs | |
| - name: Install and build every preview registry item | |
| if: matrix.leg == 'preview' && needs.check-scope.outputs.spec_only != 'true' | |
| run: node internal/shadcn-registry/verify-full-catalog.mjs | |
| - name: Generate the hidden production registry | |
| if: matrix.leg == 'production' && needs.check-scope.outputs.spec_only != 'true' | |
| env: | |
| DOCSITE_TARGET: latest | |
| run: node apps/docsite/scripts/generate-data.mjs | |
| - name: Verify hidden production discovery surfaces | |
| if: matrix.leg == 'production' && needs.check-scope.outputs.spec_only != 'true' | |
| env: | |
| ASTRYX_VERIFY_HIDDEN_PRODUCTION: '1' | |
| NEXT_PUBLIC_DOCS_TARGET: latest | |
| run: pnpm -F @astryxdesign/docsite exec vitest run src/__tests__/hidden-shadcn-production.test.ts | |
| - name: Install and build every hidden production registry item | |
| if: matrix.leg == 'production' && needs.check-scope.outputs.spec_only != 'true' | |
| env: | |
| ASTRYX_SHADCN_USE_PUBLISHED_PACKAGES: '1' | |
| run: node internal/shadcn-registry/verify-full-catalog.mjs | |
| # Historical required check name. The Vitest lanes, Build test owner, | |
| # public registry contract, native Swift and interaction proofs always report | |
| # or explicitly skip, so this join projects their combined result without | |
| # creating another surface lane. | |
| test: | |
| needs: | |
| [ | |
| check-scope, | |
| test-ui, | |
| test-node, | |
| test-build, | |
| registry-contract, | |
| test-native-swift, | |
| pr-interaction, | |
| ] | |
| if: ${{ github.event_name != 'workflow_dispatch' && always() && !cancelled() && needs.check-scope.outputs.spec_only != 'true' }} | |
| runs-on: ubuntu-slim | |
| permissions: | |
| contents: read | |
| steps: | |
| - uses: actions/checkout@v7 | |
| - name: Require expected test-owner outcomes | |
| env: | |
| CHECK_SCOPE_RESULT: ${{ needs.check-scope.result }} | |
| DOCSITE_ONLY: ${{ needs.check-scope.outputs.docsite_only }} | |
| SPEC_ONLY: ${{ needs.check-scope.outputs.spec_only }} | |
| TOOLING_ONLY: ${{ needs.check-scope.outputs.tooling_only }} | |
| TEST_UI_RESULT: ${{ needs.test-ui.result }} | |
| TEST_NODE_RESULT: ${{ needs.test-node.result }} | |
| TEST_BUILD_RESULT: ${{ needs.test-build.result }} | |
| REGISTRY_CONTRACT_RESULT: ${{ needs.registry-contract.result }} | |
| TEST_NATIVE_SWIFT_RESULT: ${{ needs.test-native-swift.result }} | |
| 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-storybook: | |
| needs: [check-scope] | |
| if: ${{ (github.event_name != 'workflow_dispatch' || inputs.operation == 'release-check') && always() && !cancelled() && needs.check-scope.outputs.spec_only != 'true' }} | |
| # Every browser lane waits for this job, and the package builds and the | |
| # Storybook build run side by side (build-packages-and-storybook.mjs). | |
| runs-on: 4-core-ubuntu | |
| timeout-minutes: ${{ github.event_name == 'workflow_dispatch' && 360 || 15 }} | |
| permissions: | |
| 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 | |
| if: needs.check-scope.result != 'success' | |
| run: | | |
| echo "Change scope could not be classified; refusing to skip required work." | |
| exit 1 | |
| - name: Skip heavy work for a specialized lane | |
| if: needs.check-scope.outputs.docsite_only == 'true' || needs.check-scope.outputs.spec_only == 'true' || needs.check-scope.outputs.tooling_only == 'true' | |
| run: echo "Specialized PR lane — skipping unrelated build" | |
| - name: Checkout | |
| if: needs.check-scope.outputs.docsite_only != 'true' && needs.check-scope.outputs.spec_only != 'true' && needs.check-scope.outputs.tooling_only != 'true' | |
| uses: actions/checkout@v7 | |
| with: | |
| # Component evidence artifacts are named for and reviewed at the PR | |
| # head, so build their Storybook bytes from that exact tree rather | |
| # than GitHub's synthetic merge checkout. | |
| ref: ${{ github.event.pull_request.head.sha || github.sha }} | |
| # Depth 50 (same as check-scope) so analyze-pr.js's three-dot diff | |
| # can find a merge base — depth 1 breaks it ("no merge base") and | |
| # the analysis silently reported zero changed components. | |
| fetch-depth: 50 | |
| - name: Verify Storybook source checkout | |
| 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' | |
| env: | |
| EXPECTED_HEAD_SHA: ${{ github.event.pull_request.head.sha }} | |
| run: test "$(git rev-parse HEAD)" = "$EXPECTED_HEAD_SHA" | |
| - name: Fetch base branch for PR analysis | |
| 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: git fetch origin ${{ github.base_ref }} --depth=50 | |
| - name: Setup Node and pnpm | |
| if: needs.check-scope.outputs.docsite_only != 'true' && needs.check-scope.outputs.spec_only != 'true' && needs.check-scope.outputs.tooling_only != 'true' | |
| uses: ./.github/actions/setup | |
| # The same steps as `pnpm build` and the Storybook build, overlapped: a | |
| # package builds once its workspace dependencies have, and Storybook once | |
| # the packages its story index records are built. | |
| - name: Build packages and Storybook | |
| if: needs.check-scope.outputs.docsite_only != 'true' && needs.check-scope.outputs.spec_only != 'true' && needs.check-scope.outputs.tooling_only != 'true' | |
| run: node .github/scripts/build-packages-and-storybook.mjs | |
| - name: Verify package exports | |
| if: needs.check-scope.outputs.docsite_only != 'true' && needs.check-scope.outputs.spec_only != 'true' && needs.check-scope.outputs.tooling_only != 'true' | |
| run: node scripts/verify-exports.mjs | |
| - name: Stamp Storybook source revision | |
| if: needs.check-scope.outputs.docsite_only != 'true' && needs.check-scope.outputs.spec_only != 'true' && needs.check-scope.outputs.tooling_only != 'true' | |
| run: git rev-parse HEAD > apps/storybook/dist/astryx-build-sha.txt | |
| - name: Compute PR preview path | |
| 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' | |
| 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 }}" | |
| 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' | |
| id: release | |
| run: | | |
| test "$(git rev-parse HEAD)" = "$GITHUB_SHA" | |
| echo "short_hash=${GITHUB_SHA:0:7}" >> "$GITHUB_OUTPUT" | |
| printf '{"forceFullComponentAudits":true}\n' > analysis.json | |
| - name: Upload Storybook artifact | |
| 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' || inputs.operation == 'release-check') | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: storybook-${{ steps.release.outputs.short_hash || steps.urls.outputs.short_hash }} | |
| path: apps/storybook/dist/ | |
| retention-days: 30 | |
| # pr-visual reads each theme's built source to learn which targets that | |
| # theme styles — a theme's component map is what defineTheme returns, not | |
| # a literal in its source. This job has already built them; shipping the | |
| # artifact keeps that job on a download instead of a second full build. | |
| # | |
| # core's dist ships with them because importing a built theme executes | |
| # `import {defineTheme} from '@astryxdesign/core/theme'`, which pnpm | |
| # resolves through the workspace link into packages/core/dist. | |
| # | |
| # Two paths, so the artifact is rooted at their common ancestor | |
| # (packages/) — the download below unpacks it there. | |
| - name: Upload built themes and core | |
| 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' || inputs.operation == 'release-check') | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: dists-${{ steps.release.outputs.short_hash || steps.urls.outputs.short_hash }} | |
| path: | | |
| packages/themes/*/dist/ | |
| packages/core/dist/ | |
| retention-days: 1 | |
| - name: Analyze components | |
| 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' | |
| env: | |
| FULL_SUITE: ${{ needs.check-scope.outputs.full_suite }} | |
| run: | | |
| # Browser audits follow the changed components and their reverse | |
| # dependents, unless the change touches shared infrastructure. | |
| FORCE_FULL=() | |
| if [ "$FULL_SUITE" != false ]; then FORCE_FULL=(--force-full); fi | |
| node .github/scripts/analyze-pr.js \ | |
| --base origin/${{ github.base_ref }} \ | |
| --head HEAD \ | |
| --output analysis.json \ | |
| "${FORCE_FULL[@]}" | |
| - 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. | |
| cat > pr-meta.json <<EOF | |
| { | |
| "prNumber": "${{ steps.urls.outputs.pr_number }}", | |
| "shortHash": "${{ steps.urls.outputs.short_hash }}", | |
| "headSha": "${{ github.event.pull_request.head.sha }}", | |
| "headRepository": "${{ github.event.pull_request.head.repo.full_name }}", | |
| "baseRepository": "${{ github.event.pull_request.base.repo.full_name }}", | |
| "runId": "${{ github.run_id }}", | |
| "runAttempt": "${{ github.run_attempt }}", | |
| "runUrl": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" | |
| } | |
| EOF | |
| - name: Upload analysis artifact | |
| 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' || inputs.operation == 'release-check') | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: pr-analysis | |
| path: | | |
| analysis.json | |
| pr-meta.json | |
| retention-days: 1 | |
| # Measures the PR's merge base so the PR comment can show component and | |
| # package sizes before and after. It runs beside build-storybook rather than | |
| # inside it, so no browser lane waits for the second build; the head sizes | |
| # still come from build-storybook's analysis. | |
| size-base: | |
| needs: [check-scope] | |
| if: github.event_name == 'pull_request' && needs.check-scope.result == 'success' && needs.check-scope.outputs.docsite_only != 'true' && needs.check-scope.outputs.spec_only != 'true' && needs.check-scope.outputs.tooling_only != 'true' | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 15 | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v7 | |
| with: | |
| ref: ${{ github.event.pull_request.head.sha }} | |
| fetch-depth: 50 | |
| - name: Fetch base branch | |
| run: git fetch origin ${{ github.base_ref }} --depth=50 | |
| - name: Setup Node and pnpm | |
| uses: ./.github/actions/setup | |
| # A branch far behind main may have no merge base within the fetched | |
| # history even after deepening. The report then keeps Before and Delta | |
| # as N/A rather than failing the run. | |
| - name: Check out the merge base | |
| id: merge-base | |
| env: | |
| BASE_REF: ${{ github.base_ref }} | |
| run: | | |
| if ! BASE_SHA=$(git merge-base "origin/$BASE_REF" HEAD); then | |
| git fetch --deepen=200 origin "$BASE_REF:refs/remotes/origin/$BASE_REF" || true | |
| if ! BASE_SHA=$(git merge-base "origin/$BASE_REF" HEAD); then | |
| echo "::warning::no merge base within the fetched history; skipping base size measurement" | |
| echo "found=false" >> "$GITHUB_OUTPUT" | |
| exit 0 | |
| fi | |
| fi | |
| git worktree add --detach .size-base "$BASE_SHA" | |
| echo "sha=$BASE_SHA" >> "$GITHUB_OUTPUT" | |
| echo "found=true" >> "$GITHUB_OUTPUT" | |
| # Core and its build tooling always build, because the other component | |
| # packages depend on them; another package builds only when the PR | |
| # changes its source. | |
| - name: Build the merge base's component packages | |
| if: steps.merge-base.outputs.found == 'true' | |
| working-directory: .size-base | |
| env: | |
| BASE_SHA: ${{ steps.merge-base.outputs.sha }} | |
| HEAD_SHA: ${{ github.event.pull_request.head.sha }} | |
| run: | | |
| pnpm install --frozen-lockfile | |
| pnpm -F @astryxdesign/build build | |
| pnpm -F @astryxdesign/core build | |
| for pkg in lab charts richtext vega; do | |
| if git diff --quiet "$BASE_SHA" "$HEAD_SHA" -- "packages/$pkg/src"; then | |
| continue | |
| fi | |
| pnpm -F "@astryxdesign/$pkg" build | |
| done | |
| - name: Measure the merge base | |
| if: steps.merge-base.outputs.found == 'true' | |
| run: | | |
| node .github/scripts/analyze-pr.js \ | |
| --base origin/${{ github.base_ref }} \ | |
| --head HEAD \ | |
| --base-root .size-base \ | |
| --base-only \ | |
| --output size-base.json | |
| - name: Upload base size stats | |
| if: steps.merge-base.outputs.found == 'true' | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: pr-size-base | |
| path: size-base.json | |
| retention-days: 1 | |
| # Typechecks run beside build-storybook instead of before its Storybook | |
| # build, so the browser checks that wait on the Storybook artifact start | |
| # ~1.5 minutes sooner. The build and release-check joins require this job, | |
| # so a type error still fails both. | |
| typecheck: | |
| needs: [check-scope] | |
| if: ${{ (github.event_name != 'workflow_dispatch' || inputs.operation == 'release-check') && always() && !cancelled() && needs.check-scope.outputs.spec_only != 'true' }} | |
| runs-on: 2-core-ubuntu-arm | |
| timeout-minutes: ${{ github.event_name == 'workflow_dispatch' && 360 || 15 }} | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: Require successful scope classification | |
| if: needs.check-scope.result != 'success' | |
| run: | | |
| echo "Change scope could not be classified; refusing to skip required work." | |
| exit 1 | |
| - name: Skip typechecks for a specialized lane | |
| if: needs.check-scope.outputs.docsite_only == 'true' || needs.check-scope.outputs.spec_only == 'true' || needs.check-scope.outputs.tooling_only == 'true' | |
| run: echo "Specialized PR lane — skipping typechecks" | |
| - name: Checkout | |
| if: needs.check-scope.outputs.docsite_only != 'true' && needs.check-scope.outputs.spec_only != 'true' && needs.check-scope.outputs.tooling_only != 'true' | |
| uses: actions/checkout@v7 | |
| with: | |
| ref: ${{ github.event.pull_request.head.sha || github.sha }} | |
| - name: Setup Node and pnpm | |
| if: needs.check-scope.outputs.docsite_only != 'true' && needs.check-scope.outputs.spec_only != 'true' && needs.check-scope.outputs.tooling_only != 'true' | |
| uses: ./.github/actions/setup | |
| # The doc, template and CLI typechecks resolve the built package types. | |
| - name: Build packages | |
| if: needs.check-scope.outputs.docsite_only != 'true' && needs.check-scope.outputs.spec_only != 'true' && needs.check-scope.outputs.tooling_only != 'true' | |
| run: pnpm build | |
| # Every workspace package's own `typecheck` script: its sources and | |
| # tests, its doc examples, and any declarations it emits. A new package | |
| # or tsconfig joins by defining or extending that script, not this job. | |
| # A PR head cut before `pnpm typecheck` existed runs the previous list, | |
| # loaded from the merge commit these steps come from. | |
| - name: Typecheck every package | |
| if: needs.check-scope.outputs.docsite_only != 'true' && needs.check-scope.outputs.spec_only != 'true' && needs.check-scope.outputs.tooling_only != 'true' | |
| env: | |
| WORKFLOW_SHA: ${{ github.sha }} | |
| run: | | |
| if node -e "process.exit(require('./package.json').scripts?.typecheck ? 0 : 1)"; then | |
| pnpm typecheck | |
| else | |
| echo "::notice title=Head predates pnpm typecheck::Running the previous typecheck list; merge main to use pnpm typecheck." | |
| legacy="$RUNNER_TEMP/typecheck-predating-head.sh" | |
| git fetch --quiet --no-tags --depth=1 origin "$WORKFLOW_SHA" | |
| git show "$WORKFLOW_SHA:.github/scripts/typecheck-predating-head.sh" > "$legacy" | |
| 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: 2-core-ubuntu-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. | |
| build: | |
| needs: [build-storybook, build-sandbox, typecheck] | |
| if: ${{ github.event_name != 'workflow_dispatch' && !cancelled() && needs.build-storybook.result != 'skipped' }} | |
| runs-on: ubuntu-slim | |
| permissions: {} | |
| steps: | |
| - 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 | |
| # Storybook and Sandbox previews; no branch-backed preview is published. | |
| # 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. | |
| # 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 | |
| # pr-a11y itself, so neither runs there. | |
| pr-a11y-shard: | |
| name: pr-a11y (${{ matrix.shard }}/${{ strategy.job-total }}) | |
| needs: [build-storybook, check-components] | |
| if: github.event_name == 'workflow_dispatch' && inputs.operation == 'release-check' && needs.check-components.outputs.has_components == 'true' | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| shard: [1, 2, 3] | |
| # Four pages on four cores: on 2-core ARM runners each shard's scan took | |
| # 11.5 minutes, the release check's slowest lane after the contracts. | |
| runs-on: 4-core-ubuntu | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v7 | |
| with: | |
| ref: ${{ github.event.pull_request.head.sha || github.sha }} | |
| - name: Setup Node and pnpm | |
| uses: ./.github/actions/setup | |
| with: | |
| install: 'false' | |
| - name: Download Storybook artifact | |
| uses: actions/download-artifact@v8 | |
| with: | |
| name: storybook-${{ needs.build-storybook.outputs.short_hash }} | |
| path: apps/storybook/dist | |
| - name: Install Playwright | |
| run: pnpm install --frozen-lockfile && npx playwright install chromium | |
| - name: Run accessibility audit shard | |
| run: | | |
| node .github/scripts/accessibility-audit.js \ | |
| --storybook-dir apps/storybook/dist \ | |
| --concurrency 4 \ | |
| --shard "${{ matrix.shard }}/${{ strategy.job-total }}" \ | |
| --shard-output "a11y-shard-${{ matrix.shard }}.json" | |
| - name: Upload accessibility audit shard | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: a11y-shard-${{ needs.build-storybook.outputs.short_hash }}-${{ matrix.shard }} | |
| path: a11y-shard-${{ matrix.shard }}.json | |
| retention-days: 1 | |
| if-no-files-found: error | |
| pr-a11y-audit: | |
| name: pr-a11y (full audit) | |
| needs: [build-storybook, check-components, pr-a11y-shard] | |
| if: ${{ always() && github.event_name == 'workflow_dispatch' && inputs.operation == 'release-check' && needs.check-components.outputs.has_components == 'true' }} | |
| runs-on: 2-core-ubuntu-arm | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: Require every audit shard | |
| env: | |
| SHARD_RESULT: ${{ needs.pr-a11y-shard.result }} | |
| run: | | |
| if [ "$SHARD_RESULT" != success ]; then | |
| echo "Accessibility audit shards did not all succeed: $SHARD_RESULT" | |
| exit 1 | |
| fi | |
| - name: Checkout | |
| uses: actions/checkout@v7 | |
| with: | |
| ref: ${{ github.event.pull_request.head.sha || github.sha }} | |
| - name: Setup Node and pnpm | |
| uses: ./.github/actions/setup | |
| - name: Download Storybook artifact | |
| uses: actions/download-artifact@v8 | |
| with: | |
| name: storybook-${{ needs.build-storybook.outputs.short_hash }} | |
| path: apps/storybook/dist | |
| - name: Download accessibility audit shards | |
| uses: actions/download-artifact@v8 | |
| with: | |
| pattern: a11y-shard-${{ needs.build-storybook.outputs.short_hash }}-* | |
| path: a11y-shards | |
| merge-multiple: true | |
| # Builds the report a single full run would write from the complete | |
| # shard set (or fails), then applies the checked-in baseline. | |
| - name: Run accessibility audit | |
| run: | | |
| node .github/scripts/accessibility-audit.js \ | |
| --storybook-dir apps/storybook/dist \ | |
| --output a11y-report.json \ | |
| --merge-shards a11y-shards \ | |
| --baseline .github/a11y-baseline.json \ | |
| --fail-on-new | |
| - name: Upload a11y artifact | |
| if: always() | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: a11y-report | |
| path: a11y-report.json | |
| retention-days: 1 | |
| pr-a11y-guards: | |
| name: pr-a11y (audit and guards) | |
| needs: [build-storybook, check-components] | |
| if: (github.event_name == 'pull_request' || (github.event_name == 'workflow_dispatch' && inputs.operation == 'release-check')) && needs.check-components.outputs.has_components == 'true' | |
| runs-on: 2-core-ubuntu-arm | |
| timeout-minutes: ${{ github.event_name == 'workflow_dispatch' && 360 || 15 }} | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v7 | |
| with: | |
| ref: ${{ github.event.pull_request.head.sha || github.sha }} | |
| - name: Verify evidence checkout | |
| if: github.event_name == 'pull_request' | |
| env: | |
| EXPECTED_HEAD_SHA: ${{ github.event.pull_request.head.sha }} | |
| run: test "$(git rev-parse HEAD)" = "$EXPECTED_HEAD_SHA" | |
| # Dependencies are installed later, together with the Playwright browser, | |
| # because the analysis artifact has to be downloaded first. | |
| - name: Setup Node and pnpm | |
| uses: ./.github/actions/setup | |
| with: | |
| install: 'false' | |
| - name: Download analysis artifact | |
| uses: actions/download-artifact@v8 | |
| with: | |
| name: pr-analysis | |
| - name: Download Storybook artifact | |
| uses: actions/download-artifact@v8 | |
| with: | |
| name: storybook-${{ needs.build-storybook.outputs.short_hash }} | |
| path: apps/storybook/dist | |
| - name: Install Playwright | |
| run: pnpm install --frozen-lockfile && npx playwright install chromium | |
| # Fails on axe violations not present in the checked-in baseline | |
| # (.github/a11y-baseline.json). See CONTRIBUTING.md "Accessibility | |
| # audits" for the baseline workflow. | |
| # Release checks scan the full roster in pr-a11y-shard and gate it in | |
| # pr-a11y-audit; this job keeps the scoped PR audit and the guards. | |
| - name: Run accessibility audit | |
| if: github.event_name == 'pull_request' | |
| run: | | |
| SCOPE_ARGS=() | |
| if [ "${{ github.event_name }}" = 'pull_request' ]; then | |
| COMPONENTS=$(node .github/scripts/a11y-pr-scope.mjs analysis.json) | |
| # An explicit empty filter means no changed components, never all | |
| # stories. Shared-surface full sweeps belong to release-check. | |
| SCOPE_ARGS=(--components "$COMPONENTS") | |
| echo "PR accessibility scope: ${COMPONENTS:-no changed components; fast browser guards still run}" | |
| fi | |
| node .github/scripts/accessibility-audit.js \ | |
| --storybook-dir apps/storybook/dist \ | |
| --output a11y-report.json \ | |
| --concurrency 4 \ | |
| "${SCOPE_ARGS[@]}" \ | |
| --baseline .github/a11y-baseline.json \ | |
| --fail-on-new | |
| # if: always() so the report artifact (and the PR comment built from it) | |
| # still exists when the gate above fails. | |
| - name: Upload a11y artifact | |
| if: always() && github.event_name == 'pull_request' | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: a11y-report | |
| path: a11y-report.json | |
| retention-days: 1 | |
| # A modal <dialog> hidden before close() blocks the whole page in Safari | |
| # 26.1 and leaves no trace (#4290). The ordering is produced by a CSS | |
| # transition, which jsdom does not run — so the unit suite cannot see it | |
| # and this Chromium probe is the guard. Runs after the upload above so an | |
| # a11y failure still publishes its report. | |
| - name: Run modal close visibility guard | |
| run: node .github/scripts/modal-close-visibility.js --storybook-dir apps/storybook/dist | |
| # A public component var can be documented, read, and emitted into the | |
| # theme CSS and still be unreachable — an inline write or an unlayered | |
| # declaration outranks `@layer astryx-theme` (#4530). jsdom resolves no | |
| # cascade, so the unit suites assert on the generated CSS text, which | |
| # proves emission and not effect. Chromium is where the promise is | |
| # checkable. The source-side wiring half lives in | |
| # packages/cli/foundation/discovery/theming-targets.test.mjs. | |
| - name: Run theme var reachability guard | |
| run: node .github/scripts/theme-var-reachability.js --storybook-dir apps/storybook/dist | |
| # A story play function is where geometry assertions live (they need | |
| # getBoundingClientRect, so jsdom is out), but nothing else observes the | |
| # result: Vitest never collects stories, and pr-visual loads stories | |
| # without awaiting `play` — and is soft while it earns trust. This guard | |
| # loads each listed story in Chromium and fails when its play assertions | |
| # throw. Hosted here with the sibling Chromium guards because pr-a11y is | |
| # the blocking job that runs whenever components change. | |
| - name: Run story play guard | |
| run: node .github/scripts/story-play-guard.js --storybook-dir apps/storybook/dist | |
| # Browser accessibility specs get their own budget. The scoped axe sweep and | |
| # the always-on Chromium guards consume most of a pull request's 15-minute | |
| # job budget before these specs start; running beside them keeps both owners | |
| # inside the budget without weakening the stable pr-a11y join. | |
| pr-a11y-specs: | |
| name: pr-a11y (browser specs) | |
| needs: [build-storybook, check-components] | |
| if: (github.event_name == 'pull_request' || (github.event_name == 'workflow_dispatch' && inputs.operation == 'release-check')) && needs.check-components.outputs.has_components == 'true' | |
| runs-on: 2-core-ubuntu-arm | |
| timeout-minutes: ${{ github.event_name == 'workflow_dispatch' && 360 || 15 }} | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v7 | |
| with: | |
| ref: ${{ github.event.pull_request.head.sha || github.sha }} | |
| - name: Verify evidence checkout | |
| if: github.event_name == 'pull_request' | |
| env: | |
| EXPECTED_HEAD_SHA: ${{ github.event.pull_request.head.sha }} | |
| run: test "$(git rev-parse HEAD)" = "$EXPECTED_HEAD_SHA" | |
| - name: Setup Node and pnpm | |
| uses: ./.github/actions/setup | |
| with: | |
| install: 'false' | |
| - name: Download analysis artifact | |
| uses: actions/download-artifact@v8 | |
| with: | |
| name: pr-analysis | |
| - name: Download Storybook artifact | |
| uses: actions/download-artifact@v8 | |
| with: | |
| name: storybook-${{ needs.build-storybook.outputs.short_hash }} | |
| path: apps/storybook/dist | |
| - name: Install Playwright | |
| run: pnpm install --frozen-lockfile && npx playwright install chromium | |
| # The runner runs every spec playwright.config.ts matches whose own | |
| # `@pr-a11y` routing lines select it for this pull request. The runner and | |
| # routing lines come from the merge commit these steps come from, so an | |
| # older PR head is routed by current policy while specs run at that head. | |
| - name: Run browser accessibility specs | |
| if: ${{ !cancelled() }} | |
| env: | |
| ASTRYX_HEAD_SHA: ${{ github.event.pull_request.head.sha || github.sha }} | |
| BASE_SHA: ${{ github.event.pull_request.base.sha }} | |
| PR_TITLE: ${{ github.event.pull_request.title }} | |
| WORKFLOW_SHA: ${{ github.sha }} | |
| run: | | |
| runner="$RUNNER_TEMP/a11y-pr-contracts.mjs" | |
| git fetch --quiet --no-tags --depth=1 origin "$WORKFLOW_SHA" | |
| git show "$WORKFLOW_SHA:.github/scripts/a11y-pr-contracts.mjs" > "$runner" | |
| node "$runner" | |
| - name: Upload browser accessibility evidence | |
| if: ${{ !cancelled() }} | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: pr-a11y-evidence-${{ needs.build-storybook.outputs.short_hash }} | |
| path: | | |
| pr-a11y-evidence/ | |
| pr-a11y-output/ | |
| test-results/ | |
| *-audit-evidence/ | |
| retention-days: 30 | |
| if-no-files-found: ignore | |
| # Stable required context joining the scoped audit/guards and browser specs. | |
| pr-a11y: | |
| needs: [check-components, pr-a11y-guards, pr-a11y-specs] | |
| if: ${{ always() && (github.event_name == 'pull_request' || (github.event_name == 'workflow_dispatch' && inputs.operation == 'release-check')) && needs.check-components.outputs.has_components == 'true' }} | |
| runs-on: ubuntu-slim | |
| timeout-minutes: 5 | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: Require every accessibility owner | |
| env: | |
| GUARDS_RESULT: ${{ needs.pr-a11y-guards.result }} | |
| SPECS_RESULT: ${{ needs.pr-a11y-specs.result }} | |
| run: | | |
| if [ "$GUARDS_RESULT" != success ] || [ "$SPECS_RESULT" != success ]; then | |
| echo "Accessibility owners did not all succeed: guards=$GUARDS_RESULT specs=$SPECS_RESULT" | |
| exit 1 | |
| fi | |
| # Release-only accessibility contracts run beside pr-a11y instead of after | |
| # its full axe sweep, so the release check waits for the longer of the two | |
| # rather than their sum. release-check requires this job as it requires | |
| # pr-a11y. | |
| a11y-contracts-shard: | |
| name: Accessibility spec-test contracts (${{ matrix.shard }}/${{ strategy.job-total }}) | |
| needs: [build-storybook, check-components] | |
| if: github.event_name == 'workflow_dispatch' && inputs.operation == 'release-check' && needs.check-components.outputs.has_components == 'true' | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| shard: [1, 2, 3] | |
| # One core per worker: on two cores, four workers starved the CPU-bound | |
| # "every expectation" specs past their timeouts. | |
| runs-on: 4-core-ubuntu | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v7 | |
| with: | |
| ref: ${{ github.event.pull_request.head.sha || github.sha }} | |
| - name: Setup Node and pnpm | |
| uses: ./.github/actions/setup | |
| with: | |
| install: 'false' | |
| - name: Download Storybook artifact | |
| uses: actions/download-artifact@v8 | |
| with: | |
| name: storybook-${{ needs.build-storybook.outputs.short_hash }} | |
| path: apps/storybook/dist | |
| - name: Install Playwright | |
| run: pnpm install --frozen-lockfile && npx playwright install chromium | |
| # The exhaustive contract/fixture matrix. PRs retain scoped axe | |
| # validation and the fast interaction guards in pr-a11y; they must not | |
| # pay for every component's browser bindings on every change. | |
| - name: Run accessibility spec-test contracts | |
| if: github.event_name == 'workflow_dispatch' && inputs.operation == 'release-check' | |
| env: | |
| ASTRYX_HEAD_SHA: ${{ github.event.pull_request.head.sha || github.sha }} | |
| A11Y_CONTRACT_WORKERS: 4 | |
| # Files are split by recorded duration (a11y-contract-shard.mjs), not | |
| # Playwright's count-based --shard; every listed file runs in one leg. | |
| run: | | |
| set -euo pipefail | |
| node .github/scripts/a11y-contract-shard.mjs --shard "${{ matrix.shard }}/${{ strategy.job-total }}" > contract-files.txt | |
| mapfile -t FILES < contract-files.txt | |
| # The filters come before the options: `--project` takes every | |
| # value after it, so filters placed after it read as project names. | |
| pnpm exec playwright test "${FILES[@]}" --config playwright.config.ts --project chromium | |
| - name: Upload pressed-state pixel evidence | |
| if: always() && github.event_name == 'workflow_dispatch' && inputs.operation == 'release-check' | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: pressed-state-evidence-${{ needs.build-storybook.outputs.short_hash }}-${{ matrix.shard }} | |
| path: test-results/pressed-state-evidence/ | |
| # A failing run keeps its evidence here (the join merges only after | |
| # every leg passed, then deletes these copies). | |
| retention-days: 30 | |
| # Only the shard that ran the spec has frames; the join requires them. | |
| if-no-files-found: ignore | |
| # Component-audit browser evidence. A whole-component audit has to show | |
| # the states it graded, and the audit node cannot always run a browser — | |
| # so the frames and their sensor receipts are produced here, bound to the | |
| # same exact head as every other check in this job. | |
| - name: Upload component-audit browser evidence | |
| if: always() && github.event_name == 'workflow_dispatch' && inputs.operation == 'release-check' | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: component-audit-evidence-${{ needs.build-storybook.outputs.short_hash }}-${{ matrix.shard }} | |
| path: test-results/chat-layout-audit-evidence/ | |
| retention-days: 30 | |
| if-no-files-found: ignore | |
| # Joins the contract shards for release-check: every shard must pass, and | |
| # each evidence set is rebuilt under its usual artifact name. A set no shard | |
| # produced fails the merge, as the single job's upload used to fail. | |
| a11y-contracts: | |
| name: Accessibility spec-test contracts | |
| needs: [build-storybook, check-components, a11y-contracts-shard] | |
| if: ${{ always() && github.event_name == 'workflow_dispatch' && inputs.operation == 'release-check' && needs.check-components.outputs.has_components == 'true' }} | |
| runs-on: ubuntu-slim | |
| permissions: {} | |
| steps: | |
| - name: Require every contract shard | |
| env: | |
| SHARD_RESULT: ${{ needs.a11y-contracts-shard.result }} | |
| run: | | |
| if [ "$SHARD_RESULT" != success ]; then | |
| echo "Accessibility contract shards did not all succeed: $SHARD_RESULT" | |
| exit 1 | |
| fi | |
| - name: Join pressed-state pixel evidence | |
| uses: actions/upload-artifact/merge@v7 | |
| with: | |
| name: pressed-state-evidence-${{ needs.build-storybook.outputs.short_hash }} | |
| pattern: pressed-state-evidence-${{ needs.build-storybook.outputs.short_hash }}-* | |
| retention-days: 30 | |
| delete-merged: true | |
| - name: Join component-audit browser evidence | |
| uses: actions/upload-artifact/merge@v7 | |
| with: | |
| name: component-audit-evidence-${{ needs.build-storybook.outputs.short_hash }} | |
| pattern: component-audit-evidence-${{ needs.build-storybook.outputs.short_hash }}-* | |
| retention-days: 30 | |
| delete-merged: true | |
| # Touch interaction and animation proofs: the harness in | |
| # internal/interaction-harness and every *.interaction.browser.spec.ts. | |
| # Real touch input, composited frames, rendering traces and presented | |
| # animation values only exist in a real engine, and the specs read stories | |
| # from this PR's own Storybook build. The harness's self-test runs with them, | |
| # so a change to an instrument is proven by its own checks before a component | |
| # spec relies on it. Chromium only on these runners; see the harness README | |
| # for running WebKit. | |
| # | |
| # The proofs are coverage inside the shared surface (AST-030 FR11), so `test` | |
| # joins pr-interaction. A Linux job first decides whether the change touches | |
| # the harness, a component, Storybook, or the proofs' own setup; only then | |
| # does pr-interaction take a 4-core runner, and otherwise it passes on Linux | |
| # without work. Like pr-a11y, the proofs run on pull requests; a merge group | |
| # passes without them. | |
| interaction-scope: | |
| needs: [check-scope] | |
| if: ${{ github.event_name != 'workflow_dispatch' && always() && !cancelled() && needs.check-scope.outputs.spec_only != 'true' }} | |
| runs-on: ubuntu-slim | |
| timeout-minutes: 5 | |
| permissions: | |
| contents: read | |
| outputs: | |
| applies: ${{ steps.scope.outputs.applies }} | |
| steps: | |
| - name: Require successful scope classification | |
| if: needs.check-scope.result != 'success' | |
| run: | | |
| echo "Change scope could not be classified; refusing to skip required work." | |
| exit 1 | |
| # The PR merge commit and its parents: the first parent is the base it | |
| # merged into, so the PR's own change is one diff away (see below). | |
| - uses: actions/checkout@v7 | |
| if: github.event_name == 'pull_request' && needs.check-scope.outputs.docsite_only != 'true' && needs.check-scope.outputs.tooling_only != 'true' | |
| with: | |
| fetch-depth: 2 | |
| # The helper comes from the base, since an older head lacks it. Exit 1 | |
| # means out of scope; 0 in scope; 2 unknown, so the proofs run. | |
| # pr-interaction runs the proofs on the PR head. A head cut before they | |
| # existed has no playwright.interaction.config.ts and passes with a | |
| # notice; a PR that deletes the config (its diff changes it) still runs | |
| # them, and fails. Anything undecided runs them. | |
| - name: Decide whether the interaction proofs apply | |
| id: scope | |
| env: | |
| EVENT_NAME: ${{ github.event_name }} | |
| DOCSITE_ONLY: ${{ needs.check-scope.outputs.docsite_only }} | |
| TOOLING_ONLY: ${{ needs.check-scope.outputs.tooling_only }} | |
| BASE_SHA: ${{ github.event.pull_request.base.sha }} | |
| HEAD_SHA: ${{ github.event.pull_request.head.sha }} | |
| run: | | |
| if [ "$DOCSITE_ONLY" = true ] || [ "$TOOLING_ONLY" = true ]; then | |
| echo 'Specialized lane; no interaction proofs.' | |
| echo 'applies=false' >> "$GITHUB_OUTPUT" | |
| exit 0 | |
| fi | |
| if [ "$EVENT_NAME" != pull_request ]; then | |
| echo 'Not a pull request; the proofs ran on the pull request itself.' | |
| echo 'applies=false' >> "$GITHUB_OUTPUT" | |
| exit 0 | |
| fi | |
| # Diff against the merge commit's first parent, not the PR's | |
| # recorded base: from an old base the diff would count main's own | |
| # changes since as the PR's, and from the PR head the helper would | |
| # deepen history back to an old fork point. | |
| if [ "$(git rev-list --parents -n 1 HEAD 2>/dev/null | wc -w)" -eq 3 ]; then | |
| BASE_SHA="$(git rev-parse HEAD^1)" | |
| fi | |
| scope=2 | |
| helper="$(mktemp)" | |
| if [ -n "$BASE_SHA" ] \ | |
| && git fetch --quiet --no-tags --depth=1 origin "$BASE_SHA" \ | |
| && git show "$BASE_SHA:.github/scripts/pr-scope-touches.sh" > "$helper"; then | |
| scope=0 | |
| bash "$helper" "$BASE_SHA" '^(internal/interaction-harness/|internal/a11y-spec/|playwright\.interaction\.config\.ts$|packages/[^/]+/src/|packages/themes/[^/]+/src/|apps/storybook/|\.github/workflows/ci\.yml$|package\.json$|pnpm-lock\.yaml$)' || scope=$? | |
| fi | |
| if [ "$scope" = 1 ]; then | |
| echo 'No harness, component, Storybook or proof-setup change; skipping the interaction proofs.' | |
| echo 'applies=false' >> "$GITHUB_OUTPUT" | |
| exit 0 | |
| fi | |
| if [ "$scope" = 0 ] && [ -n "$HEAD_SHA" ] \ | |
| && git fetch --quiet --no-tags --depth=1 origin "$HEAD_SHA" \ | |
| && ! git cat-file -e "$HEAD_SHA:playwright.interaction.config.ts" 2>/dev/null; then | |
| touches=0 | |
| bash "$helper" "$BASE_SHA" '^playwright\.interaction\.config\.ts$' || touches=$? | |
| if [ "$touches" = 1 ]; then | |
| echo "::notice title=Interaction proofs predate this branch::This pull request's head has no playwright.interaction.config.ts; merge main to run the interaction proofs." | |
| echo 'applies=false' >> "$GITHUB_OUTPUT" | |
| exit 0 | |
| fi | |
| fi | |
| echo 'applies=true' >> "$GITHUB_OUTPUT" | |
| pr-interaction: | |
| needs: [check-scope, interaction-scope, build-storybook] | |
| if: ${{ github.event_name != 'workflow_dispatch' && always() && !cancelled() && needs.check-scope.outputs.spec_only != 'true' }} | |
| # Frame evidence measures timing: four cores, one Playwright worker. | |
| runs-on: ${{ needs.interaction-scope.outputs.applies == 'true' && '4-core-ubuntu' || 'ubuntu-slim' }} | |
| timeout-minutes: 15 | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: Require a decided interaction scope | |
| if: needs.interaction-scope.result != 'success' | |
| run: | | |
| echo "Interaction scope could not be decided; refusing to skip required work." | |
| exit 1 | |
| - name: Require this pull request's Storybook build | |
| if: needs.interaction-scope.outputs.applies == 'true' && needs.build-storybook.result != 'success' | |
| run: | | |
| echo "The proofs read this pull request's Storybook build, which did not succeed." | |
| exit 1 | |
| - name: Skip the proofs outside their scope | |
| if: needs.interaction-scope.outputs.applies != 'true' | |
| run: echo "No interaction proofs for this change." | |
| - name: Checkout | |
| if: needs.interaction-scope.outputs.applies == 'true' | |
| uses: actions/checkout@v7 | |
| with: | |
| ref: ${{ github.event.pull_request.head.sha }} | |
| - name: Verify evidence checkout | |
| if: needs.interaction-scope.outputs.applies == 'true' | |
| env: | |
| EXPECTED_HEAD_SHA: ${{ github.event.pull_request.head.sha }} | |
| run: test "$(git rev-parse HEAD)" = "$EXPECTED_HEAD_SHA" | |
| - name: Setup Node and pnpm | |
| if: needs.interaction-scope.outputs.applies == 'true' | |
| uses: ./.github/actions/setup | |
| with: | |
| install: 'false' | |
| - name: Download Storybook artifact | |
| if: needs.interaction-scope.outputs.applies == 'true' | |
| uses: actions/download-artifact@v8 | |
| with: | |
| name: storybook-${{ needs.build-storybook.outputs.short_hash }} | |
| path: apps/storybook/dist | |
| - name: Install Playwright | |
| if: needs.interaction-scope.outputs.applies == 'true' | |
| run: pnpm install --frozen-lockfile && npx playwright install chromium | |
| - name: Run interaction proofs | |
| if: needs.interaction-scope.outputs.applies == 'true' | |
| run: | | |
| pnpm exec playwright test \ | |
| --config playwright.interaction.config.ts \ | |
| --project chromium \ | |
| --output interaction-proof-output | |
| # Storyboards (PNG contact sheets) and curve traces, for review. | |
| - name: Upload interaction evidence | |
| if: always() && needs.interaction-scope.outputs.applies == 'true' | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: interaction-evidence | |
| path: test-results/interaction-evidence | |
| if-no-files-found: ignore | |
| retention-days: 7 | |
| # Build package test owner. The plugin's production CSS partition is a Build | |
| # integration contract: source inspection cannot prove which declaration | |
| # paints after Vite emits the final bundle. The `test-build` name makes that | |
| # package ownership explicit; the historical `test` join above projects its | |
| # result. Until runtime:build has a specialized route, broad CI dispatches it. | |
| test-build: | |
| needs: [check-scope] | |
| if: github.event_name != 'workflow_dispatch' && needs.check-scope.outputs.docsite_only != 'true' && needs.check-scope.outputs.spec_only != 'true' && needs.check-scope.outputs.tooling_only != 'true' | |
| runs-on: 2-core-ubuntu-arm | |
| timeout-minutes: 15 | |
| permissions: | |
| contents: read | |
| steps: | |
| - uses: actions/checkout@v7 | |
| - uses: ./.github/actions/setup | |
| - name: Install Playwright | |
| run: npx playwright install chromium | |
| # The Build package's contracts: the packed consumer's dependencies, the | |
| # production CSS-layer cascade, and cross-package StyleX markers in a | |
| # real browser. `pnpm test:build` owns the list. | |
| - name: Run Build package contracts | |
| run: pnpm test:build | |
| # Guest token boundaries cross portals and the host light/dark cascade. This | |
| # requires a production browser render; source and jsdom checks cannot prove | |
| # which custom properties paint the portaled surfaces. | |
| fixture-contrast: | |
| needs: [check-scope] | |
| if: github.event_name != 'workflow_dispatch' && needs.check-scope.outputs.docsite_only != 'true' && needs.check-scope.outputs.spec_only != 'true' && needs.check-scope.outputs.tooling_only != 'true' | |
| runs-on: 2-core-ubuntu-arm | |
| timeout-minutes: 15 | |
| permissions: | |
| contents: read | |
| steps: | |
| - uses: actions/checkout@v7 | |
| - uses: ./.github/actions/setup | |
| - name: Install Playwright | |
| run: npx playwright install chromium | |
| - name: Verify canonical setup compositions | |
| env: | |
| ASTRYX_CANONICAL_SETUP_BROWSER: '1' | |
| run: pnpm vitest run internal/vibe-tests/setup-test/setup-canonical.test.ts --project node --maxWorkers=1 | |
| - name: Verify guest fixture contrast | |
| run: pnpm -F @astryxdesign/vibe-tests fixtures:contrast | |
| # The full visual plan first loads every Core story to learn which theming | |
| # targets it renders, and that scout is most of the job's time. It runs here | |
| # as parallel shards over exactly the release plan's story list; pr-visual | |
| # joins them only when every shard succeeded, and otherwise scouts inline. | |
| visual-scout: | |
| name: Stable visual scout (${{ matrix.shard }}/${{ strategy.job-total }}) | |
| needs: [build-storybook, check-components] | |
| if: >- | |
| !cancelled() && | |
| needs.build-storybook.result == 'success' && | |
| needs.check-components.result == 'success' && | |
| ((github.event_name == 'pull_request' && | |
| needs.check-components.outputs.has_stable_visual == 'true' && | |
| needs.check-components.outputs.broad_stable_visual == 'true') || | |
| (github.event_name == 'workflow_dispatch' && inputs.operation == 'release-check')) | |
| # Five legs: at three, each leg's scout took ~4.5 minutes and the visual | |
| # regression waited for the slowest one. | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| shard: [1, 2, 3, 4, 5] | |
| # Four pages on four cores: the scout is page-load bound, and on the rig | |
| # this cut a shard's scout by a quarter against two pages on two cores. | |
| runs-on: 4-core-ubuntu | |
| timeout-minutes: ${{ github.event_name == 'workflow_dispatch' && 360 || 15 }} | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v7 | |
| - name: Setup Node and pnpm | |
| uses: ./.github/actions/setup | |
| with: | |
| install: 'false' | |
| - name: Download Storybook artifact | |
| uses: actions/download-artifact@v8 | |
| with: | |
| name: storybook-${{ needs.build-storybook.outputs.short_hash }} | |
| path: apps/storybook/dist | |
| # The artifact carries the themes and the Core dist they import, built | |
| # at this commit. If it is missing, the gate builds Core and the themes. | |
| - name: Download built themes and core | |
| continue-on-error: true | |
| uses: actions/download-artifact@v8 | |
| with: | |
| name: dists-${{ needs.build-storybook.outputs.short_hash }} | |
| path: packages | |
| - name: Install Playwright | |
| run: pnpm install --frozen-lockfile && npx playwright install chromium | |
| - name: Scout this shard of the release plan | |
| run: | | |
| node .github/scripts/visual-gate/gate.mjs scout \ | |
| --storybook-dir apps/storybook/dist \ | |
| --baseline .github/visual-baseline \ | |
| --shard "${{ matrix.shard }}/${{ strategy.job-total }}" \ | |
| --concurrency 4 \ | |
| --observations-out ".visual-scout/observations-${{ matrix.shard }}.json" | |
| - name: Upload scout shard | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: visual-scout-${{ needs.build-storybook.outputs.short_hash }}-${{ matrix.shard }} | |
| path: .visual-scout/observations-${{ matrix.shard }}.json | |
| retention-days: 1 | |
| if-no-files-found: error | |
| # Stable-package visual regression and explicit baseline capture share this | |
| # owner. Focused PRs compare the checked-in baseline; broad PRs use the full | |
| # canonical plan. Maintenance captures candidates on the same runner, and a | |
| # normal reviewed pull request updates the versioned baseline. | |
| # Audit and interaction fixtures stay with their existing browser checks. | |
| pr-visual: | |
| name: Stable visual regression | |
| needs: | |
| [build-storybook, check-components, maintenance-request, visual-scout] | |
| if: >- | |
| !cancelled() && | |
| ((github.event_name == 'pull_request' && | |
| needs.build-storybook.result == 'success' && | |
| needs.check-components.result == 'success' && | |
| needs.check-components.outputs.has_stable_visual == 'true') || | |
| (github.event_name == 'workflow_dispatch' && | |
| ((inputs.operation == 'release-check' && | |
| needs.build-storybook.result == 'success' && | |
| needs.check-components.result == 'success') || | |
| (needs.maintenance-request.result == 'success' && inputs.operation == 'capture')))) | |
| runs-on: 2-core-ubuntu-arm | |
| timeout-minutes: ${{ github.event_name == 'workflow_dispatch' && 360 || 15 }} | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v7 | |
| - name: Setup Node and pnpm | |
| uses: ./.github/actions/setup | |
| with: | |
| install: 'false' | |
| - name: Download analysis artifact | |
| if: github.event_name == 'pull_request' | |
| uses: actions/download-artifact@v8 | |
| with: | |
| name: pr-analysis | |
| - name: Download Storybook artifact | |
| if: github.event_name == 'pull_request' || inputs.operation == 'release-check' | |
| uses: actions/download-artifact@v8 | |
| with: | |
| name: storybook-${{ needs.build-storybook.outputs.short_hash }} | |
| path: apps/storybook/dist | |
| # The artifact carries the themes and the Core dist they import, built | |
| # at this commit. If it is missing, the gate builds Core and the themes. | |
| - name: Download built themes and core | |
| if: github.event_name == 'pull_request' || inputs.operation == 'release-check' | |
| continue-on-error: true | |
| uses: actions/download-artifact@v8 | |
| with: | |
| name: dists-${{ needs.build-storybook.outputs.short_hash }} | |
| path: packages | |
| # Only a complete set: the gate refuses a partial or mismatched one, and | |
| # without any it scouts inline as before. | |
| - name: Download scout shards | |
| if: (github.event_name == 'pull_request' || inputs.operation == 'release-check') && needs.visual-scout.result == 'success' | |
| uses: actions/download-artifact@v8 | |
| with: | |
| pattern: visual-scout-${{ needs.build-storybook.outputs.short_hash }}-* | |
| path: .visual-scout | |
| merge-multiple: true | |
| - name: Install Playwright | |
| run: pnpm install --frozen-lockfile && npx playwright install chromium | |
| - name: Build canonical maintenance Storybook | |
| if: github.event_name == 'workflow_dispatch' && inputs.operation == 'capture' | |
| run: pnpm build && pnpm -F @astryxdesign/storybook build | |
| # The reviewed baseline is versioned with the code so CI never depends on | |
| # mutable website storage. Baseline refreshes remain separate reviewable PRs. | |
| - name: Run the visual gate for the touched components | |
| id: visual | |
| if: github.event_name == 'pull_request' | |
| env: | |
| BROAD_STABLE_VISUAL: ${{ needs.check-components.outputs.broad_stable_visual }} | |
| ASTRYX_PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }} | |
| ASTRYX_PR_BASE_SHA: ${{ github.event.pull_request.base.sha }} | |
| run: | | |
| set -eu | |
| # Component names are not globally unique; use their package identity. | |
| TOUCHED=$(jq -r '. as $root | [(.newComponents + .modifiedComponents)[] | select($root.componentStats[.].package == "@astryxdesign/core")] | unique | join(",")' analysis.json) | |
| # Reverse dependents by folder: the folders of the components RTL | |
| # audits (spec:AST-030 FR13). | |
| DEPENDENTS=$(jq -r '[(.dependentComponentFolders // [])[] | select(startswith("core/")) | ltrimstr("core/")] | unique | join(",")' analysis.json) | |
| COMPONENTS="$TOUCHED" | |
| DEPENDENT_ARGS=() | |
| if [ -n "$DEPENDENTS" ]; then DEPENDENT_ARGS=(--dependents "$DEPENDENTS"); fi | |
| THEMES=$(jq -r '(.changedStableThemes // []) | join(",")' analysis.json) | |
| COMMAND=check | |
| # Sources no build decided, or a full-suite change, audit the whole | |
| # plan (spec:AST-030 FR13). | |
| FORCE_FULL_AUDITS=$(jq -r '.forceFullComponentAudits == true' analysis.json) | |
| if [ "$BROAD_STABLE_VISUAL" = 'true' ] || [ "$FORCE_FULL_AUDITS" = 'true' ]; then | |
| COMMAND=release | |
| SCOPE_ARGS=() | |
| elif [ -n "$COMPONENTS$DEPENDENTS" ] && [ -n "$THEMES" ]; then | |
| SCOPE_ARGS=(--tiers 'component,theme-matrix' --components "$COMPONENTS" "${DEPENDENT_ARGS[@]}" --themes "$THEMES") | |
| elif [ -n "$COMPONENTS$DEPENDENTS" ]; then | |
| SCOPE_ARGS=(--tiers component --components "$COMPONENTS" "${DEPENDENT_ARGS[@]}" --no-scout) | |
| elif [ -n "$THEMES" ]; then | |
| SCOPE_ARGS=(--tiers theme-matrix --themes "$THEMES") | |
| else | |
| # Broad changes stay with this owner: the canonical full plan has | |
| # no focused-component review ceiling and no deferred backup gate. | |
| COMMAND=release | |
| SCOPE_ARGS=() | |
| fi | |
| echo "Stable Core components: ${COMPONENTS:-none}" | |
| echo "Stable Core reverse dependents: ${DEPENDENTS:-none}" | |
| echo "Stable themes: ${THEMES:-none}" | |
| OBS_ARGS=() | |
| if [ -d .visual-scout ]; then OBS_ARGS=(--observation-shards .visual-scout); fi | |
| run_gate() { | |
| node .github/scripts/visual-gate/gate.mjs "$COMMAND" \ | |
| --storybook-dir apps/storybook/dist \ | |
| --baseline .github/visual-baseline \ | |
| --out .visual-run \ | |
| "${SCOPE_ARGS[@]}" \ | |
| "${OBS_ARGS[@]}" \ | |
| --summary-output visual-summary.md | |
| } | |
| set +e | |
| run_gate | |
| code=$? | |
| if [ "$code" = 3 ]; then | |
| # Nothing the scope reaches has a stable story: the whole plan | |
| # runs instead (spec:AST-030 FR13). An over-budget focused plan | |
| # writes the skipped verdict, answered below the same way. | |
| COMMAND=release | |
| SCOPE_ARGS=() | |
| run_gate | |
| code=$? | |
| fi | |
| set -e | |
| # Exit 2 is a visual change for review; every other nonzero exit is | |
| # an infrastructure failure, not a successful evidence receipt. | |
| case "$code" in 0|2) ;; *) exit "$code" ;; esac | |
| STATUS=$(jq -er '.status' .visual-run/verdict.json) | |
| if [ "$STATUS" = 'skipped' ]; then | |
| # The focused budget refused before capture. The same owner now | |
| # captures its bounded canonical full plan rather than leaving a gap. | |
| set +e | |
| node .github/scripts/visual-gate/gate.mjs release \ | |
| --storybook-dir apps/storybook/dist \ | |
| --baseline .github/visual-baseline \ | |
| --out .visual-run \ | |
| "${OBS_ARGS[@]}" \ | |
| --summary-output visual-summary.md | |
| code=$? | |
| set -e | |
| case "$code" in 0|2) ;; *) exit "$code" ;; esac | |
| STATUS=$(jq -er '.status' .visual-run/verdict.json) | |
| fi | |
| [ -f visual-summary.md ] && cat visual-summary.md >> "$GITHUB_STEP_SUMMARY" | |
| case "$STATUS" in | |
| pass|changed) ;; | |
| *) echo "Visual evidence is incomplete: $STATUS"; exit 1 ;; | |
| esac | |
| - name: Upload visual verdict and report | |
| if: always() && github.event_name == 'pull_request' | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: visual-pr-report | |
| path: | | |
| .visual-run/verdict.json | |
| .visual-run/manifest.json | |
| .visual-run/shots/ | |
| .visual-run/report/ | |
| retention-days: 30 | |
| if-no-files-found: ignore | |
| - name: Run full release visual check | |
| if: github.event_name == 'workflow_dispatch' && inputs.operation == 'release-check' | |
| run: | | |
| set -eu | |
| OBS_ARGS=() | |
| if [ -d .visual-scout ]; then OBS_ARGS=(--observation-shards .visual-scout); fi | |
| set +e | |
| node .github/scripts/visual-gate/gate.mjs release \ | |
| --storybook-dir apps/storybook/dist \ | |
| --baseline .github/visual-baseline \ | |
| --out .visual-run \ | |
| "${OBS_ARGS[@]}" \ | |
| --summary-output visual-summary.md | |
| code=$? | |
| set -e | |
| case "$code" in 0|2) ;; *) exit "$code" ;; esac | |
| STATUS=$(jq -er '.status' .visual-run/verdict.json) | |
| case "$STATUS" in | |
| pass|changed) ;; | |
| *) echo "Visual evidence is incomplete: $STATUS"; exit 1 ;; | |
| esac | |
| cat visual-summary.md >> "$GITHUB_STEP_SUMMARY" | |
| - name: Upload release visual verdict and report | |
| if: always() && github.event_name == 'workflow_dispatch' && inputs.operation == 'release-check' | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: visual-release-report | |
| path: | | |
| .visual-run/verdict.json | |
| .visual-run/manifest.json | |
| .visual-run/shots/ | |
| .visual-run/report/ | |
| retention-days: 14 | |
| if-no-files-found: error | |
| - name: Capture canonical visual baseline | |
| id: maintenance-capture | |
| if: github.event_name == 'workflow_dispatch' && inputs.operation == 'capture' | |
| # A complete browser-refresh capture can be incomparable with the old | |
| # baseline. The next step requires full capture, not a clean comparison. | |
| continue-on-error: true | |
| run: | | |
| node .github/scripts/visual-gate/gate.mjs release \ | |
| --storybook-dir apps/storybook/dist \ | |
| --baseline .github/visual-baseline \ | |
| --out .visual-run \ | |
| --summary-output visual-summary.md | |
| - name: Validate canonical baseline capture | |
| id: maintenance-validation | |
| if: >- | |
| always() && github.event_name == 'workflow_dispatch' && inputs.operation == 'capture' && | |
| steps.maintenance-capture.outcome != 'skipped' | |
| env: | |
| CAPTURE_SHA: ${{ github.sha }} | |
| CAPTURE_RUN_ID: ${{ github.run_id }} | |
| CAPTURE_RUN_ATTEMPT: ${{ github.run_attempt }} | |
| run: | | |
| node --input-type=module - <<'NODE' | |
| import fs from 'node:fs'; | |
| import {validateVisualMaintenanceCapture} from './.github/scripts/visual-maintenance-source.mjs'; | |
| validateVisualMaintenanceCapture({ | |
| manifest: JSON.parse(fs.readFileSync('.visual-run/manifest.json', 'utf8')), | |
| verdict: JSON.parse(fs.readFileSync('.visual-run/verdict.json', 'utf8')), | |
| sha: process.env.CAPTURE_SHA, | |
| runId: process.env.CAPTURE_RUN_ID, | |
| runAttempt: process.env.CAPTURE_RUN_ATTEMPT, | |
| }); | |
| NODE | |
| cat visual-summary.md >> "$GITHUB_STEP_SUMMARY" | |
| - name: Upload canonical baseline candidate | |
| if: always() && steps.maintenance-validation.outcome == 'success' | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: visual-baseline-capture-${{ github.run_id }}-${{ github.run_attempt }} | |
| path: | | |
| .visual-run/shots/ | |
| .visual-run/manifest.json | |
| .visual-run/verdict.json | |
| .visual-run/report/ | |
| retention-days: 14 | |
| if-no-files-found: error | |
| # RTL semantic audit. Sibling to pr-a11y: same build-storybook artifact, same | |
| # analysis.json scoping, so ordinary PRs only pay for the components they | |
| # touched. A harness-only PR runs the fixed Chart/ChartLegend smoke scope so | |
| # routing and target changes prove themselves instead of skipping their own | |
| # check. A policy-sensitive full run spans ~2,000 stories and exceeded the | |
| # single-job budget, so CI partitions it by canonical package; each shard runs | |
| # eight browser pages on its four cores (the audit waits on page loads), and | |
| # the stable pr-rtl join requires all five scope manifests plus a report from | |
| # every applicable package. | |
| # The scheduled full sweep also runs in rtl-weekly.yml. | |
| # | |
| # Three auto dimensions: D1 icon-mirror, D5 positional-mirror, and D6 | |
| # contextual directional decorations. Curated D2/D3/D4/D7/D8/D9 add | |
| # behavior and geometry that need selectors. The applicability rollup treats unexplained all-N/A as a | |
| # coverage gap for both new and existing components. | |
| # | |
| # Audit findings remain SOFT while the stability window is observed: the audit | |
| # step may fail after writing a report. Missing/canceled/incomplete shards are | |
| # HARD failures, and the pr-rtl join cannot pass without every package scope | |
| # manifest and every applicable report. | |
| # To promote findings too, remove the audit step's continue-on-error. | |
| pr-rtl-shard: | |
| name: pr-rtl (${{ matrix.package }}${{ matrix.parts > 1 && format(' {0}/{1}', matrix.part, matrix.parts) || '' }}) | |
| needs: [build-storybook, check-components] | |
| if: >- | |
| (github.event_name == 'pull_request' || | |
| (github.event_name == 'workflow_dispatch' && inputs.operation == 'release-check')) && | |
| (needs.check-components.outputs.has_rtl_components == 'true' || | |
| needs.check-components.outputs.has_rtl_harness == 'true' || | |
| needs.check-components.outputs.force_full_component_audits == 'true') | |
| # Core is the largest package, so its audit is split three ways | |
| # (`--shard`) and joined by pr-rtl-merge; every other package runs whole. | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - {package: core, part: 1, parts: 3} | |
| - {package: core, part: 2, parts: 3} | |
| - {package: core, part: 3, parts: 3} | |
| - {package: lab, part: 1, parts: 1} | |
| - {package: charts, part: 1, parts: 1} | |
| - {package: richtext, part: 1, parts: 1} | |
| - {package: vega, part: 1, parts: 1} | |
| runs-on: 4-core-ubuntu | |
| timeout-minutes: ${{ github.event_name == 'workflow_dispatch' && 30 || 15 }} | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v7 | |
| with: | |
| ref: ${{ github.event.pull_request.head.sha || github.sha }} | |
| - name: Verify RTL checkout | |
| if: github.event_name == 'pull_request' | |
| env: | |
| EXPECTED_HEAD_SHA: ${{ github.event.pull_request.head.sha }} | |
| run: test "$(git rev-parse HEAD)" = "$EXPECTED_HEAD_SHA" | |
| - name: Setup Node and pnpm | |
| uses: ./.github/actions/setup | |
| with: | |
| install: 'false' | |
| - name: Download analysis artifact | |
| uses: actions/download-artifact@v8 | |
| with: | |
| name: pr-analysis | |
| - name: Download Storybook artifact | |
| uses: actions/download-artifact@v8 | |
| with: | |
| name: storybook-${{ needs.build-storybook.outputs.short_hash }} | |
| path: apps/storybook/dist | |
| - name: Install Playwright | |
| run: pnpm install --frozen-lockfile && npx playwright install chromium | |
| # The D7 native-size regression test lives on the PR head. A head cut | |
| # before it has no native-size enforcement for the test to check (its | |
| # audit still checks D7's centering and hit-testing), so the step says | |
| # so and passes; a head that has the file always runs it, and a failure | |
| # fails. ci-rtl-d7.test.mjs keeps the path pointing at a real file. | |
| - name: Verify D7 native target regression | |
| if: matrix.package == 'core' && matrix.part == 1 | |
| env: | |
| ASTRYX_RTL_BROWSER: '1' | |
| run: | | |
| D7_TEST=.github/scripts/rtl-audit-coarse-hit.browser.test.mjs | |
| if [ ! -f "$D7_TEST" ]; then | |
| echo '::notice title=D7 regression skipped::skipped: head predates D7 native-size enforcement; its D7 results cover centering and hit-testing only' | |
| exit 0 | |
| fi | |
| pnpm exec vitest run --project node "$D7_TEST" --maxWorkers=1 | |
| # A registry/classifier mutation runs the full audit from the PR checkout, | |
| # while eligibility itself came from trusted base policy. Scope resolution | |
| # is strict: malformed or missing analysis fails before the soft findings | |
| # step can run. An ordinary harness-only change uses the bounded routing | |
| # smoke scope. | |
| - name: Resolve RTL shard scope | |
| id: rtl-scope | |
| run: | | |
| node .github/scripts/rtl-shard-scope.mjs \ | |
| --analysis analysis.json \ | |
| --package "${{ matrix.package }}" \ | |
| --force-full "${{ needs.check-components.outputs.force_full_component_audits }}" \ | |
| --has-components "${{ needs.check-components.outputs.has_rtl_components }}" \ | |
| --has-harness "${{ needs.check-components.outputs.has_rtl_harness }}" \ | |
| --manifest rtl-shard-scope.json \ | |
| --github-output "$GITHUB_OUTPUT" | |
| - name: Run RTL audit | |
| id: rtl | |
| if: steps.rtl-scope.outputs.should_run == 'true' | |
| continue-on-error: true | |
| run: | | |
| PACKAGE=${{ matrix.package }} | |
| COMPONENTS="${{ steps.rtl-scope.outputs.components }}" | |
| FILTER="${{ steps.rtl-scope.outputs.filter }}" | |
| FILTER_ARGS=() | |
| if [ -n "$FILTER" ]; then | |
| FILTER_ARGS=(--filter "$FILTER") | |
| fi | |
| SHARD_ARGS=() | |
| if [ "${{ matrix.parts }}" -gt 1 ]; then | |
| SHARD_ARGS=(--shard "${{ matrix.part }}/${{ matrix.parts }}" --shard-output "rtl-shard-${{ matrix.part }}.json") | |
| fi | |
| echo "Auditing $PACKAGE components: $COMPONENTS" | |
| node apps/storybook/rtl-audit/rtl-audit.mjs \ | |
| --storybook-dir apps/storybook/dist \ | |
| --output rtl-audit-report.json \ | |
| --packages "$PACKAGE" \ | |
| "${SHARD_ARGS[@]}" \ | |
| --concurrency 8 \ | |
| "${FILTER_ARGS[@]}" | |
| - name: Require completed RTL shard report | |
| if: always() | |
| run: | | |
| SCOPE_OUTCOME="${{ steps.rtl-scope.outcome }}" | |
| SHOULD_RUN="${{ steps.rtl-scope.outputs.should_run }}" | |
| AUDIT_OUTCOME="${{ steps.rtl.outcome }}" | |
| if [ "$SCOPE_OUTCOME" != "success" ]; then | |
| echo "RTL shard scope did not resolve successfully: $SCOPE_OUTCOME" | |
| exit 1 | |
| fi | |
| if [ "$SHOULD_RUN" = "true" ]; then | |
| if [ "$AUDIT_OUTCOME" != "success" ] && [ "$AUDIT_OUTCOME" != "failure" ]; then | |
| echo "Applicable RTL audit did not run: $AUDIT_OUTCOME" | |
| exit 1 | |
| fi | |
| if [ "${{ matrix.parts }}" -gt 1 ]; then | |
| # A part writes cards only; pr-rtl-merge checks the joined report. | |
| test -s "rtl-shard-${{ matrix.part }}.json" | |
| else | |
| node .github/scripts/rtl-report-completion.mjs \ | |
| --report rtl-audit-report.json \ | |
| --package "${{ matrix.package }}" \ | |
| --filter "${{ steps.rtl-scope.outputs.filter }}" | |
| fi | |
| elif [ "$SHOULD_RUN" = "false" ]; then | |
| if [ "$AUDIT_OUTCOME" != "skipped" ]; then | |
| echo "Out-of-scope RTL audit unexpectedly ran: $AUDIT_OUTCOME" | |
| exit 1 | |
| fi | |
| else | |
| echo "RTL shard scope produced no explicit should_run decision." | |
| exit 1 | |
| fi | |
| - name: Write scorecard summary | |
| if: always() && steps.rtl-scope.outputs.should_run == 'true' && matrix.parts == 1 | |
| run: | | |
| node .github/scripts/rtl-scorecard-summary.mjs \ | |
| --report rtl-audit-report.json \ | |
| --scope "${{ steps.rtl-scope.outputs.components }}" >> "$GITHUB_STEP_SUMMARY" | |
| - name: Upload RTL shard evidence | |
| if: always() && matrix.parts == 1 | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: rtl-audit-report-${{ matrix.package }} | |
| path: | | |
| rtl-shard-scope.json | |
| rtl-audit-report.json | |
| if-no-files-found: error | |
| retention-days: 1 | |
| - name: Upload RTL part | |
| if: always() && matrix.parts > 1 | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: rtl-audit-part-${{ matrix.package }}-${{ matrix.part }} | |
| path: | | |
| rtl-shard-scope.json | |
| rtl-shard-${{ matrix.part }}.json | |
| if-no-files-found: error | |
| retention-days: 1 | |
| # Joins the Core parts into the one report a whole Core leg would have | |
| # written (the same scope manifest, report and completion check), uploaded | |
| # under the same artifact name for the pr-rtl join. A missing or mismatched | |
| # part fails here. | |
| pr-rtl-merge: | |
| name: pr-rtl (core) | |
| needs: [build-storybook, check-components, pr-rtl-shard] | |
| if: >- | |
| always() && !cancelled() && | |
| (github.event_name == 'pull_request' || | |
| (github.event_name == 'workflow_dispatch' && inputs.operation == 'release-check')) && | |
| (needs.check-components.outputs.has_rtl_components == 'true' || | |
| needs.check-components.outputs.has_rtl_harness == 'true' || | |
| needs.check-components.outputs.force_full_component_audits == 'true') | |
| runs-on: 2-core-ubuntu-arm | |
| timeout-minutes: 15 | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v7 | |
| with: | |
| ref: ${{ github.event.pull_request.head.sha || github.sha }} | |
| - name: Setup Node and pnpm | |
| uses: ./.github/actions/setup | |
| - name: Download Storybook artifact | |
| uses: actions/download-artifact@v8 | |
| with: | |
| name: storybook-${{ needs.build-storybook.outputs.short_hash }} | |
| path: apps/storybook/dist | |
| - name: Download Core RTL parts | |
| uses: actions/download-artifact@v8 | |
| with: | |
| pattern: rtl-audit-part-core-* | |
| path: rtl-parts | |
| - name: Join Core RTL parts | |
| id: join | |
| run: | | |
| set -eu | |
| manifests=(rtl-parts/*/rtl-shard-scope.json) | |
| if [ "${#manifests[@]}" -ne 3 ]; then | |
| echo "Expected 3 Core RTL parts, found ${#manifests[@]}." | |
| exit 1 | |
| fi | |
| for manifest in "${manifests[@]}"; do | |
| cmp -s "$manifest" "${manifests[0]}" || { echo "Core RTL parts disagree on scope: $manifest"; exit 1; } | |
| done | |
| cp "${manifests[0]}" rtl-shard-scope.json | |
| FILTER=$(jq -r '.filter' rtl-shard-scope.json) | |
| echo "components=${FILTER:-full core roster}" >> "$GITHUB_OUTPUT" | |
| if [ "$(jq -r '.shouldRun' rtl-shard-scope.json)" != true ]; then | |
| echo "Core RTL audit not applicable." | |
| exit 0 | |
| fi | |
| FILTER_ARGS=() | |
| if [ -n "$FILTER" ]; then FILTER_ARGS=(--filter "$FILTER"); fi | |
| set +e | |
| node apps/storybook/rtl-audit/rtl-audit.mjs \ | |
| --storybook-dir apps/storybook/dist \ | |
| --output rtl-audit-report.json \ | |
| --packages core \ | |
| --merge-shards rtl-parts \ | |
| "${FILTER_ARGS[@]}" | |
| code=$? | |
| set -e | |
| # 1 is the soft findings signal; anything else is a failed join. | |
| case "$code" in 0|1) ;; *) exit "$code" ;; esac | |
| node .github/scripts/rtl-report-completion.mjs \ | |
| --report rtl-audit-report.json \ | |
| --package core \ | |
| --filter "$FILTER" | |
| - name: Write scorecard summary | |
| if: always() && hashFiles('rtl-audit-report.json') != '' | |
| run: | | |
| node .github/scripts/rtl-scorecard-summary.mjs \ | |
| --report rtl-audit-report.json \ | |
| --scope "${{ steps.join.outputs.components }}" >> "$GITHUB_STEP_SUMMARY" | |
| - name: Upload RTL shard evidence | |
| if: always() | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: rtl-audit-report-core | |
| path: | | |
| rtl-shard-scope.json | |
| rtl-audit-report.json | |
| if-no-files-found: error | |
| retention-days: 1 | |
| # Stable required context joining the five package shards above. | |
| pr-rtl: | |
| needs: [check-scope, check-components, pr-rtl-shard, pr-rtl-merge] | |
| if: ${{ always() && !cancelled() && ((github.event_name == 'pull_request' && needs.check-scope.outputs.spec_only != 'true') || (github.event_name == 'workflow_dispatch' && inputs.operation == 'release-check')) }} | |
| runs-on: ubuntu-slim | |
| timeout-minutes: 5 | |
| steps: | |
| - uses: actions/checkout@v7 | |
| - name: Download applicable RTL shard reports | |
| if: ${{ needs.check-components.result == 'success' && (needs.check-components.outputs.has_rtl_components == 'true' || needs.check-components.outputs.has_rtl_harness == 'true' || needs.check-components.outputs.force_full_component_audits == 'true') }} | |
| continue-on-error: true | |
| uses: actions/download-artifact@v8 | |
| with: | |
| pattern: rtl-audit-report-* | |
| path: rtl-shard-reports | |
| - name: Require every applicable RTL shard | |
| if: always() | |
| run: | | |
| node .github/scripts/rtl-join.mjs \ | |
| --check-components "${{ needs.check-components.result }}" \ | |
| --shards "${{ needs.pr-rtl-shard.result == needs.pr-rtl-merge.result && needs.pr-rtl-shard.result || format('{0}/{1}', needs.pr-rtl-shard.result, needs.pr-rtl-merge.result) }}" \ | |
| --should-run "${{ needs.check-components.outputs.has_rtl_components == 'true' || needs.check-components.outputs.has_rtl_harness == 'true' || needs.check-components.outputs.force_full_component_audits == 'true' }}" \ | |
| --force-full "${{ needs.check-components.outputs.force_full_component_audits }}" \ | |
| --reports-dir rtl-shard-reports | |
| # Report-only: after every pull-request job finishes, each job's run time | |
| # (start to finish, no queue) and the run's span go to the job summary, with | |
| # a warning for any job past 12 minutes, so a lane growing toward its | |
| # 15-minute limit shows before it fails. It never fails and is not required. | |
| ci-duration: | |
| needs: | |
| [ | |
| check-scope, | |
| release-bump, | |
| release-merge-back, | |
| docsite-data, | |
| docsite-browser, | |
| docsite-test, | |
| check-components, | |
| test-ui, | |
| test-node, | |
| native-swift-scope, | |
| test-native-swift, | |
| registry-contract, | |
| test, | |
| build-storybook, | |
| size-base, | |
| typecheck, | |
| build-sandbox, | |
| build, | |
| pr-a11y-guards, | |
| pr-a11y-specs, | |
| pr-a11y, | |
| interaction-scope, | |
| pr-interaction, | |
| test-build, | |
| fixture-contrast, | |
| visual-scout, | |
| pr-visual, | |
| pr-rtl-shard, | |
| pr-rtl-merge, | |
| pr-rtl, | |
| ] | |
| if: ${{ always() && github.event_name == 'pull_request' }} | |
| runs-on: ubuntu-slim | |
| timeout-minutes: 5 | |
| continue-on-error: true | |
| permissions: | |
| actions: read | |
| steps: | |
| - name: Report job durations | |
| uses: actions/github-script@v9 | |
| with: | |
| # The listing is one request for every job of the run with its | |
| # steps, and GitHub can answer it 502 at its gateway limit: retry a | |
| # server error. The action's exempt client errors stay final. | |
| retries: 3 | |
| script: | | |
| const jobs = await github.paginate( | |
| github.rest.actions.listJobsForWorkflowRunAttempt, | |
| {...context.repo, run_id: context.runId, attempt_number: Number(process.env.GITHUB_RUN_ATTEMPT), per_page: 100}, | |
| ); | |
| const done = jobs.filter(job => job.started_at && job.completed_at && job.conclusion !== 'skipped' && job.name !== 'ci-duration'); | |
| const rows = done | |
| .map(job => ({name: job.name, minutes: (Date.parse(job.completed_at) - Date.parse(job.started_at)) / 60000})) | |
| .sort((a, b) => b.minutes - a.minutes); | |
| for (const row of rows.filter(row => row.minutes > 12)) { | |
| core.warning(`${row.name} ran ${row.minutes.toFixed(1)} min; PR jobs stop at 15. Split it (shard, scope, cache).`); | |
| } | |
| const span = done.length | |
| ? (Math.max(...done.map(job => Date.parse(job.completed_at))) - Math.min(...done.map(job => Date.parse(job.started_at)))) / 60000 | |
| : 0; | |
| await core.summary | |
| .addHeading('Job durations (run time, no queue)', 3) | |
| .addRaw(`Run span, first job start to last job end (includes waits between jobs): ${span.toFixed(1)} min\n\n`) | |
| .addTable([[{data: 'Job', header: true}, {data: 'Minutes', header: true}], ...rows.map(row => [row.name, row.minutes.toFixed(1)])]) | |
| .write(); | |
| # Release-time projection only: the existing owners above do all measurement. | |
| # A skipped owner or main drift must never look like passing release evidence. | |
| release-check: | |
| needs: | |
| [ | |
| check-scope, | |
| check-components, | |
| build-storybook, | |
| typecheck, | |
| pr-visual, | |
| pr-a11y, | |
| a11y-contracts, | |
| pr-a11y-audit, | |
| pr-rtl, | |
| ] | |
| if: ${{ always() && github.event_name == 'workflow_dispatch' && inputs.operation == 'release-check' }} | |
| runs-on: ubuntu-slim | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: Require complete exact-head canonical checks | |
| uses: actions/github-script@v9 | |
| env: | |
| RELEASE_NEEDS: ${{ toJSON(needs) }} | |
| RELEASE_BRANCH: ${{ inputs['release-branch'] }} | |
| EXPECTED_HEAD: ${{ inputs['expected-head'] }} | |
| CHECKED_HEAD: ${{ needs.check-scope.outputs.release_head }} | |
| PLAN_DIGEST: ${{ needs.check-scope.outputs.release_plan_digest }} | |
| with: | |
| script: | | |
| const needs = JSON.parse(process.env.RELEASE_NEEDS); | |
| for (const name of ['check-scope', 'check-components', 'build-storybook', 'typecheck', 'pr-visual', 'pr-a11y', 'a11y-contracts', 'pr-a11y-audit', 'pr-rtl']) { | |
| if (needs[name]?.result !== 'success') { | |
| throw new Error(`Required release job ${name} did not succeed: ${needs[name]?.result}`); | |
| } | |
| } | |
| const branch = process.env.RELEASE_BRANCH; | |
| const expectedHead = process.env.EXPECTED_HEAD; | |
| if (context.ref !== `refs/heads/${branch}`) { | |
| throw new Error('Canonical release checks must run from the requested branch.'); | |
| } | |
| if (context.sha !== expectedHead) { | |
| throw new Error('Checked-out commit does not match expected head.'); | |
| } | |
| const {data} = await github.rest.git.getRef({...context.repo, ref: `heads/${branch}`}); | |
| if (branch === 'main') { | |
| if (process.env.CHECKED_HEAD !== expectedHead) { | |
| throw new Error('Main authority check did not bind the expected head.'); | |
| } | |
| const comparison = await github.rest.repos.compareCommitsWithBasehead({ | |
| ...context.repo, | |
| basehead: `${expectedHead}...${data.object.sha}`, | |
| }); | |
| if (!['identical', 'ahead'].includes(comparison.data.status)) { | |
| throw new Error('Checked main commit is not an ancestor of current main.'); | |
| } | |
| await core.summary | |
| .addHeading('Main pre-cut checks complete') | |
| .addRaw(`Exact head: ${expectedHead}\n\n`) | |
| .addRaw('Canonical visual, accessibility, and RTL checks completed with full scope. This exact checked commit may be used as the cut SHA while it remains in current main history; later main commits are next-release input.') | |
| .write(); | |
| return; | |
| } | |
| if (data.object.sha !== expectedHead) { | |
| throw new Error(`${branch} moved during checks; dispatch release-check again for its new head.`); | |
| } | |
| if (!branch.startsWith('release/v')) { | |
| throw new Error('Post-bump release checks require a marked release branch.'); | |
| } | |
| if (!/^[0-9a-f]{64}$/.test(process.env.PLAN_DIGEST)) { | |
| throw new Error('Post-bump release checks require the active plan digest.'); | |
| } | |
| await core.summary | |
| .addHeading('Release checks complete') | |
| .addRaw(`Branch: ${branch}\n\n`) | |
| .addRaw(`Exact head: ${expectedHead}\n\n`) | |
| .addRaw(`Plan digest: ${process.env.PLAN_DIGEST}\n\n`) | |
| .addRaw('Canonical visual, accessibility, and RTL checks completed with full scope. Main movement is not release input. This receipt is reusable only for this exact branch, head, and plan digest; any branch revision requires a new run.') | |
| .write(); |