# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json name: Accessibility # ───────────────────────────────────────────────────────────────────────────── # Strict axe-core scan against the apps/docs site, run in both light and dark # color schemes across the four route archetypes (home, articles, docs # landing, rule page). # # Tag stack: WCAG 2 A/AA/AAA + WCAG 2.1 + WCAG 2.2 + axe best-practice + ACT. # # Blocks PR merges on any violation. See apps/docs/A11Y.md for the policy. # ───────────────────────────────────────────────────────────────────────────── on: pull_request: branches: [main] # `opened`/`reopened` so a PR created directly as non-draft (single push, # no later `synchronize`) still runs the axe scan — without them this # workflow can be required by branch protection yet never report. # quality-full.yml already carries this fix; a11y never got it. types: [opened, reopened, ready_for_review, labeled, synchronize] paths: - 'apps/docs/**' - 'packages/ui/**' - '.github/workflows/a11y.yml' push: branches: [main] # Same paths as the PR trigger above. Without them every merge ran a full # axe scan — including merges that touched only scripts, workflows or # plugin source, none of which can change a rendered page. The PR trigger # was already filtered; this one was not, which is where most of the 17 # runs in a 24h sample came from. paths: - 'apps/docs/**' - 'packages/ui/**' - '.github/workflows/a11y.yml' workflow_dispatch: concurrency: group: a11y-${{ github.ref }} cancel-in-progress: true env: # Turborepo Remote Cache (Vercel). Free on every plan, and off the 10 GB # Actions cache allowance that node_modules and Next.js compete for. # Absent -> empty -> the setup action falls back to the Actions-backed cache, # which is also what a fork PR gets, since forks receive no secrets. TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} TURBO_TEAM: ${{ vars.TURBO_TEAM }} permissions: contents: read # For the Turborepo Remote Cache OIDC exchange in ./.github/actions/setup. # The minted token grants Remote Cache access on the Vercel team and nothing # else. Deliberately NOT added to release.yml or supply-chain-attestation.yml # — `infra-metrics-lock` asserts those never enable the remote cache at all, # because a cache write is a path into what we publish. id-token: write jobs: gate: name: Gate runs-on: ubuntu-latest timeout-minutes: 1 outputs: run: ${{ steps.decide.outputs.run }} steps: - id: decide env: EVENT_NAME: ${{ github.event_name }} IS_DRAFT: ${{ github.event.pull_request.draft }} HAS_LABEL: ${{ contains(github.event.pull_request.labels.*.name, 'run-full-ci') }} run: | set -euo pipefail if [[ "$EVENT_NAME" != "pull_request" ]]; then echo "run=true" >> "$GITHUB_OUTPUT" exit 0 fi if [[ "$IS_DRAFT" == "false" ]] || [[ "$HAS_LABEL" == "true" ]]; then echo "run=true" >> "$GITHUB_OUTPUT" else echo "run=false" >> "$GITHUB_OUTPUT" echo "::notice::Draft PR without \`run-full-ci\` label — skipping a11y axe scan." fi axe: name: axe-core strict scan needs: gate if: needs.gate.outputs.run == 'true' runs-on: ubuntu-latest timeout-minutes: 15 steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - uses: ./.github/actions/setup with: playwright-cache: "true" # The docs production build below was 78s of a 202s run — the single # largest step here — rebuilt from scratch every time. Task-hash # addressing lets a run that did not change docs replay it instead. # Not a publishing workflow, so the supply-chain rule holds. turbo-cache: "false" turbo-remote-cache: "true" next-cache: "true" - name: Install Playwright browsers run: npx playwright install --with-deps chromium working-directory: apps/docs # Playwright's webServer runs `npm run start` in CI (next start), which # requires `.next/` from a production build. Build the docs app once # before invoking the spec so playwright doesn't crash with # "Could not find a production build in the '.next' directory". # # Go through turbo rather than two raw `npm run build --workspace=` calls # so the output lands in the shared Turbo cache and can replay the # `docs#build` that quality-full already produced for the same SHA # instead of rebuilding the site a second time. (Lighthouse used to be a # third producer here; it is weekly-cron-only now, so it never warms the # cache for a PR.) # # `--only` is load-bearing. Without it, `--filter=docs` expands via # `dependsOn: ["^build"]` to all 21 workspaces docs depends on, and a # cold cache measured 189s vs the ~120s the two npm calls took (a11y job # 3.0m -> 4.6m on this PR's first run). `--only` restricts execution to # exactly the two builds the old commands ran, so the cold path matches # the previous behaviour and the warm path replays from cache. - name: Build docs (production, via Turbo) run: npx turbo run build --filter=docs --filter=@interlace/ui --only env: NEXT_TELEMETRY_DISABLED: "1" - name: Run strict a11y scan (Playwright + axe) run: npm run test:a11y working-directory: apps/docs - name: Upload Playwright report on failure if: failure() uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7 with: name: playwright-a11y-report path: apps/docs/playwright-report/ retention-days: 14