# Game CI after the approved repository split; legacy Agent pipelines are archived. name: ci 'on': push: branches: - main pull_request: types: - opened - synchronize - reopened - edited - ready_for_review workflow_dispatch: {} permissions: contents: read concurrency: group: ci-${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: typecheck: runs-on: ubuntu-latest steps: - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 with: persist-credentials: false ref: ${{ github.event.pull_request.head.sha || github.sha }} - uses: ./.github/actions/setup-node-pnpm - run: pnpm install --frozen-lockfile - run: pnpm typecheck - run: pnpm typecheck:e2e lint: runs-on: ubuntu-latest steps: - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 with: persist-credentials: false ref: ${{ github.event.pull_request.head.sha || github.sha }} - uses: ./.github/actions/setup-node-pnpm - run: pnpm install --frozen-lockfile - run: pnpm lint - run: pnpm lint:docs test: runs-on: ubuntu-latest steps: - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 with: persist-credentials: false ref: ${{ github.event.pull_request.head.sha || github.sha }} - uses: ./.github/actions/setup-node-pnpm - uses: ./.github/actions/setup-python-uv - run: pnpm install --frozen-lockfile - run: pnpm test build: runs-on: ubuntu-latest steps: - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 with: persist-credentials: false ref: ${{ github.event.pull_request.head.sha || github.sha }} - uses: ./.github/actions/setup-node-pnpm - run: pnpm install --frozen-lockfile - run: pnpm build - run: pnpm dist:e2e-boundary --mode production --dist dist e2e-core: runs-on: ubuntu-24.04 defaults: run: shell: bash env: PLAYWRIGHT_VERSION: 1.60.0 PLAYWRIGHT_CONTAINER_IMAGE_DIGEST: sha256:9bd26ad900bb5e0f4dee75839e957a89ae89c2b7ab1e76050e559790e946b948 LOOP_E2E_LANE: core EXPECTED_PR_HEAD_SHA: ${{ github.event.pull_request.head.sha || github.sha }} container: image: mcr.microsoft.com/playwright@sha256:9bd26ad900bb5e0f4dee75839e957a89ae89c2b7ab1e76050e559790e946b948 options: --ipc=host steps: - uses: actions/checkout@v6 with: persist-credentials: false ref: ${{ github.event.pull_request.head.sha || github.sha }} - name: Enable pnpm via corepack run: | corepack enable pnpm corepack prepare pnpm@11.7.0 --activate - name: Install dependencies (timed) id: timed-pnpm-install run: | run_timed() { local step_id="$1"; shift local start_ms end_ms elapsed_ms status start_ms=$(date +%s%3N) set +e "$@" status=$? set -e end_ms=$(date +%s%3N) elapsed_ms=$((end_ms - start_ms)) printf '{"step_id":"%s","phase_id":"%s","status":%d,"elapsed_ms":%d}\n' \ "$step_id" "$step_id" "$status" "$elapsed_ms" \ >> measurements.jsonl return $status } run_timed pnpm_install pnpm install --frozen-lockfile - name: Verify resolved required-CI snapshot mode run: | CI=true pnpm exec playwright test --list --reporter=json > playwright-full-config.json python3 - <<'PY' import json from pathlib import Path config = json.loads(Path("playwright-full-config.json").read_text())["config"] assert config["updateSnapshots"] == "none", config["updateSnapshots"] print("PLAYWRIGHT_FULL_CONFIG_SNAPSHOT_POLICY_V1 status: pass") PY - name: Verify Playwright Docker image version run: | PW_VERSION="$(node -p "require('@playwright/test/package.json').version")" if [ "$PW_VERSION" != "$PLAYWRIGHT_VERSION" ]; then echo "::error::resolved @playwright/test=$PW_VERSION but Docker image expects v$PLAYWRIGHT_VERSION. Update PLAYWRIGHT_VERSION and container.image digest in ci.yml." exit 1 fi echo "playwright_version_match=ok resolved=$PW_VERSION expected=$PLAYWRIGHT_VERSION" - name: Build for E2E (timed) id: timed-build-e2e run: | run_timed() { local step_id="$1"; shift local start_ms end_ms elapsed_ms status start_ms=$(date +%s%3N) set +e "$@" status=$? set -e end_ms=$(date +%s%3N) elapsed_ms=$((end_ms - start_ms)) printf '{"step_id":"%s","phase_id":"%s","status":%d,"elapsed_ms":%d}\n' \ "$step_id" "$step_id" "$status" "$elapsed_ms" \ >> measurements.jsonl return $status } run_timed pnpm_build_e2e env VITE_E2E_MODE=true pnpm build - name: Verify E2E dist boundary run: pnpm dist:e2e-boundary --mode e2e --dist dist - name: Run E2E tests (timed) id: timed-e2e run: | run_timed() { local step_id="$1"; shift local start_ms end_ms elapsed_ms status start_ms=$(date +%s%3N) set +e "$@" status=$? set -e end_ms=$(date +%s%3N) elapsed_ms=$((end_ms - start_ms)) printf '{"step_id":"%s","phase_id":"%s","status":%d,"elapsed_ms":%d}\n' \ "$step_id" "$step_id" "$status" "$elapsed_ms" \ >> measurements.jsonl return $status } run_timed test_e2e_ci pnpm test:e2e:ci - name: Upload Playwright report id: upload-playwright-report if: ${{ !cancelled() }} uses: actions/upload-artifact@v6 with: name: playwright-report path: playwright-report/ if-no-files-found: warn retention-days: 30 - name: Upload test results id: upload-test-results if: ${{ !cancelled() }} uses: actions/upload-artifact@v6 with: name: test-results path: test-results/ if-no-files-found: warn retention-days: 30 - name: Resolve preview storage namespace (AC9 dedicated lane) id: preview-namespace run: | set -euo pipefail namespace="pr-${{ github.event.number || github.run_id }}" case "$namespace" in pr-[0-9]*) ;; *) echo "Invalid preview storage namespace: $namespace" >&2; exit 1 ;; esac echo "namespace=$namespace" >> "$GITHUB_OUTPUT" echo "expected_key=loop-protocol.preview.${namespace}.mvp.save" >> "$GITHUB_OUTPUT" # Issue #1283 (2026-08-03 OWNER review repair, AC9/AC15): deploy-pr # equivalent nested base -- matches deploy-pages.yml deploy-pr job # (Resolve Vite base path step). repo_name="${GITHUB_REPOSITORY#*/}" base_path="/${repo_name}/${namespace}/" case "$base_path" in /*/) ;; *) echo "Invalid preview base path: $base_path" >&2; exit 1 ;; esac echo "base_path=$base_path" >> "$GITHUB_OUTPUT" - name: Run AC9 preview-namespace lane via pnpm run test:e2e:preview-namespace (timed) id: timed-e2e-preview-namespace env: VITE_LOOP_STORAGE_NAMESPACE: ${{ steps.preview-namespace.outputs.namespace }} LOOP_EXPECTED_STORAGE_KEY: ${{ steps.preview-namespace.outputs.expected_key }} VITE_BASE_PATH: ${{ steps.preview-namespace.outputs.base_path }} run: | run_timed() { local step_id="$1"; shift local start_ms end_ms elapsed_ms status start_ms=$(date +%s%3N) set +e "$@" status=$? set -e end_ms=$(date +%s%3N) elapsed_ms=$((end_ms - start_ms)) printf '{"step_id":"%s","phase_id":"%s","status":%d,"elapsed_ms":%d}\n' \ "$step_id" "$step_id" "$status" "$elapsed_ms" \ >> measurements.jsonl return $status } run_timed test_e2e_preview_namespace pnpm run test:e2e:preview-namespace - name: Upload AC9 preview-namespace Playwright report id: upload-playwright-report-preview-namespace if: ${{ !cancelled() }} uses: actions/upload-artifact@v6 with: name: playwright-report-preview-namespace path: playwright-report-preview-namespace/ if-no-files-found: warn retention-days: 30 - name: Summarize visual regression evidence if: ${{ !cancelled() }} env: PLAYWRIGHT_REPORT_URL: ${{ steps.upload-playwright-report.outputs.artifact-url || 'N/A' }} TEST_RESULTS_URL: ${{ steps.upload-test-results.outputs.artifact-url || 'N/A' }} TEST_RESULTS_DIGEST: ${{ steps.upload-test-results.outputs.artifact-digest || 'sha256:none' }} PLAYWRIGHT_REPORT_DIGEST: ${{ steps.upload-playwright-report.outputs.artifact-digest || 'sha256:none' }} UPLOAD_PLAYWRIGHT_REPORT_OUTCOME: ${{ steps.upload-playwright-report.outcome }} UPLOAD_TEST_RESULTS_OUTCOME: ${{ steps.upload-test-results.outcome }} UPLOAD_PLAYWRIGHT_REPORT_ARTIFACT_ID: ${{ steps.upload-playwright-report.outputs.artifact-id }} UPLOAD_TEST_RESULTS_ARTIFACT_ID: ${{ steps.upload-test-results.outputs.artifact-id }} run: | PW_VERSION="$(node -p "require('@playwright/test/package.json').version" 2>/dev/null || echo 'unknown')" # Artifact absence-state classification (Issue #1387 AC7; PR #1813 # review fix, P1 Blocker 3): distinguish uploaded / no_files / # step_not_run / upload_failed from the upload step's own outcome + # artifact-id output — not a local directory scan. classify_artifact_status() { local outcome="$1" artifact_id="$2" if [ "$outcome" = "skipped" ]; then echo "step_not_run" elif [ "$outcome" = "failure" ]; then echo "upload_failed" elif [ "$outcome" = "success" ]; then if [ -n "$artifact_id" ]; then echo "uploaded" else echo "no_files" fi else echo "step_not_run" fi } TEST_RESULTS_STATE="$(classify_artifact_status "$UPLOAD_TEST_RESULTS_OUTCOME" "$UPLOAD_TEST_RESULTS_ARTIFACT_ID")" PLAYWRIGHT_REPORT_STATE="$(classify_artifact_status "$UPLOAD_PLAYWRIGHT_REPORT_OUTCOME" "$UPLOAD_PLAYWRIGHT_REPORT_ARTIFACT_ID")" { echo "## CI Runtime Baseline: ${{ github.job }}" echo "" echo "| step_id | elapsed_ms | status |" echo "|---|---|---|" python3 - <<'PY' import json, pathlib p = pathlib.Path("measurements.jsonl") if p.exists(): for line in p.read_text().splitlines(): line = line.strip() if line: m = json.loads(line) print(f"| {m['step_id']} | {m['elapsed_ms']} | {m['status']} |") PY echo "" echo "## Visual regression evidence" echo "" echo "Visual baseline 契約は docs/dev/visual-baseline-registry.md を参照。" echo "" echo "### Environment fingerprint" echo "- runner: ${RUNNER_OS} ${RUNNER_ARCH} (image ${ImageOS:-unknown} ${ImageVersion:-unknown})" echo "- node: $(node -p 'process.version')" echo "- Playwright: ${PW_VERSION}" echo "- browser: chromium" echo "- project: chromium (Desktop Chrome)" echo "- viewport: 1280x720" echo "- deviceScaleFactor: 1 (Desktop Chrome default; not overridden)" echo "- snapshotPathTemplate: {testDir}/__screenshots__/{testFilePath}/{arg}{ext}" echo "" echo "### Artifacts" echo "- playwright-report: ${PLAYWRIGHT_REPORT_URL} (status: ${PLAYWRIGHT_REPORT_STATE}, digest: ${PLAYWRIGHT_REPORT_DIGEST})" echo "- test-results: ${TEST_RESULTS_URL} (status: ${TEST_RESULTS_STATE}, digest: ${TEST_RESULTS_DIGEST})" echo "" echo "### actual / expected / diff" if [ -d test-results ] && find test-results -name '*-diff.png' -print -quit | grep -q .; then echo "- visual mismatch detected: see *-actual.png / *-expected.png / *-diff.png in the test-results artifact above" else echo "- N/A (no visual mismatch; expected/actual/diff are only emitted on toHaveScreenshot failure)" fi echo "" echo "### Active VRT captures" echo "" echo "Each row below is one active capture (an individual toHaveScreenshot() /" echo "expectDomOverlayScreenshot() / expectCanvasVisualCueScreenshot() call site) —" echo "not a suite. There is no separate suite-level fingerprint (PR #1813 review" echo "fix, P1 Blocker 2) — every field below is cross-validated against the real" echo "spec sources by scripts/check-visual-artifact-pipeline.py (Issue #1387)." echo "| capture_id | screenshot directory | browser | project | viewport | DPR | comparator | stylePath | artifact scope | artifact URL | digest | retention (days) |" echo "|---|---|---|---|---|---|---|---|---|---|---|---|" TEST_RESULTS_URL="$TEST_RESULTS_URL" TEST_RESULTS_DIGEST="$TEST_RESULTS_DIGEST" python3 - <<'PY' import os # ACTIVE_VRT_CAPTURES_BEGIN # Single source of truth for the per-capture fingerprint this # summary echoes (Issue #1387). scripts/check-visual-artifact-pipeline.py # parses this exact literal (between the BEGIN/END markers) and # cross-validates EVERY field against a fresh, independent # derivation from tests/e2e/*.spec.ts / playwright.config.ts / # tests/e2e/visual-utils.ts / docs/dev/visual-baseline-registry.md # (PR #1813 review fix, P1 Blocker 1) — so this list drifting from # the real spec sources in ANY field is a hard CI fail. CAPTURES = [ { "capture_id": "m2-combat-mvp.spec.ts::m2-timeout-overlay-baseline.png", "spec_file": "tests/e2e/m2-combat-mvp.spec.ts", "screenshot_name": "m2-timeout-overlay-baseline.png", "registry_id": "timeout-overlay", "directory": "tests/e2e/__screenshots__/m2-combat-mvp.spec.ts/", "browser": "chromium", "project": "chromium", "viewport": "1280x720", "device_scale_factor": 1, "comparator_kind": "maxDiffPixels", "comparator_value": "1", "style_path": False, "artifact_scope": "job", "digest_env": "TEST_RESULTS_DIGEST", "retention_days": 30, }, { "capture_id": "m2-combat-mvp.spec.ts::m2-running-hud-baseline.png", "spec_file": "tests/e2e/m2-combat-mvp.spec.ts", "screenshot_name": "m2-running-hud-baseline.png", "registry_id": "running-hud", "directory": "tests/e2e/__screenshots__/m2-combat-mvp.spec.ts/", "browser": "chromium", "project": "chromium", "viewport": "1280x720", "device_scale_factor": 1, "comparator_kind": "maxDiffPixels", "comparator_value": "150", "style_path": False, "artifact_scope": "job", "digest_env": "TEST_RESULTS_DIGEST", "retention_days": 30, }, { "capture_id": "visual-overlay.spec.ts::vrt-running-hud-overlay.png", "spec_file": "tests/e2e/visual-overlay.spec.ts", "screenshot_name": "vrt-running-hud-overlay.png", "registry_id": "running-hud-overlay-legacy-current", "directory": "tests/e2e/__screenshots__/visual-overlay.spec.ts/", "browser": "chromium", "project": "chromium", "viewport": "1280x720", "device_scale_factor": 1, "comparator_kind": "maxDiffPixels", "comparator_value": "100", "style_path": True, "artifact_scope": "job", "digest_env": "TEST_RESULTS_DIGEST", "retention_days": 30, }, { # Issue #1376 AC12: running-hud-paused promoted pending-baseline -> legacy-current. "capture_id": "visual-overlay.spec.ts::vrt-running-hud-paused-overlay.png", "spec_file": "tests/e2e/visual-overlay.spec.ts", "screenshot_name": "vrt-running-hud-paused-overlay.png", "registry_id": "running-hud-paused", "directory": "tests/e2e/__screenshots__/visual-overlay.spec.ts/", "browser": "chromium", "project": "chromium", "viewport": "1280x720", "device_scale_factor": 1, "comparator_kind": "maxDiffPixels", "comparator_value": "100", "style_path": True, "artifact_scope": "job", "digest_env": "TEST_RESULTS_DIGEST", "retention_days": 30, }, { # Issue #1376 AC12: result-timeout (registry id result-overlay-timeout) # promoted pending-baseline -> legacy-current. "capture_id": "visual-overlay.spec.ts::vrt-result-timeout-overlay.png", "spec_file": "tests/e2e/visual-overlay.spec.ts", "screenshot_name": "vrt-result-timeout-overlay.png", "registry_id": "result-overlay-timeout", "directory": "tests/e2e/__screenshots__/visual-overlay.spec.ts/", "browser": "chromium", "project": "chromium", "viewport": "1280x720", "device_scale_factor": 1, "comparator_kind": "maxDiffPixels", "comparator_value": "100", "style_path": True, "artifact_scope": "job", "digest_env": "TEST_RESULTS_DIGEST", "retention_days": 30, }, # Issue #1958 AC8 (owner decision #2): representative # boundary-cell VRT baselines. Each `test.describe()` block in # tests/e2e/visual-overlay.spec.ts overrides the run-wide # playwright.config.ts default viewport (and, for the # 1437x1365 cell, deviceScaleFactor) via `test.use()` -- # scripts/check-visual-artifact-pipeline.py's # `_resolve_viewport_context()` re-derives these per-capture # (not from the single run-wide config default) and # cross-validates every field below against that derivation. { "capture_id": "visual-overlay.spec.ts::vrt-running-hud-overlay-1366x768.png", "spec_file": "tests/e2e/visual-overlay.spec.ts", "screenshot_name": "vrt-running-hud-overlay-1366x768.png", "registry_id": "running-hud-overlay-legacy-current-1366x768", "directory": "tests/e2e/__screenshots__/visual-overlay.spec.ts/", "browser": "chromium", "project": "chromium", "viewport": "1366x768", "device_scale_factor": 1, "comparator_kind": "maxDiffPixels", "comparator_value": "100", "style_path": True, "artifact_scope": "job", "digest_env": "TEST_RESULTS_DIGEST", "retention_days": 30, }, { "capture_id": "visual-overlay.spec.ts::vrt-running-hud-overlay-1920x1080.png", "spec_file": "tests/e2e/visual-overlay.spec.ts", "screenshot_name": "vrt-running-hud-overlay-1920x1080.png", "registry_id": "running-hud-overlay-legacy-current-1920x1080", "directory": "tests/e2e/__screenshots__/visual-overlay.spec.ts/", "browser": "chromium", "project": "chromium", "viewport": "1920x1080", "device_scale_factor": 1, "comparator_kind": "maxDiffPixels", "comparator_value": "100", "style_path": True, "artifact_scope": "job", "digest_env": "TEST_RESULTS_DIGEST", "retention_days": 30, }, { # Low-DPR owner-playtest boundary. deviceScaleFactor 0.667 # (not the Desktop Chrome default 1) via test.use(). "capture_id": "visual-overlay.spec.ts::vrt-running-hud-overlay-1437x1365-dpr0667.png", "spec_file": "tests/e2e/visual-overlay.spec.ts", "screenshot_name": "vrt-running-hud-overlay-1437x1365-dpr0667.png", "registry_id": "running-hud-overlay-legacy-current-1437x1365-dpr0667", "directory": "tests/e2e/__screenshots__/visual-overlay.spec.ts/", "browser": "chromium", "project": "chromium", "viewport": "1437x1365", "device_scale_factor": 0.667, "comparator_kind": "maxDiffPixels", "comparator_value": "100", "style_path": True, "artifact_scope": "job", "digest_env": "TEST_RESULTS_DIGEST", "retention_days": 30, }, { # Minimum supported viewport boundary. "capture_id": "visual-overlay.spec.ts::vrt-running-hud-overlay-375x667.png", "spec_file": "tests/e2e/visual-overlay.spec.ts", "screenshot_name": "vrt-running-hud-overlay-375x667.png", "registry_id": "running-hud-overlay-legacy-current-375x667", "directory": "tests/e2e/__screenshots__/visual-overlay.spec.ts/", "browser": "chromium", "project": "chromium", "viewport": "375x667", "device_scale_factor": 1, "comparator_kind": "maxDiffPixels", "comparator_value": "100", "style_path": True, "artifact_scope": "job", "digest_env": "TEST_RESULTS_DIGEST", "retention_days": 30, }, { "capture_id": "phase-screens.spec.ts::title-menu.png", "spec_file": "tests/e2e/phase-screens.spec.ts", "screenshot_name": "title-menu.png", "registry_id": None, "directory": "tests/e2e/__screenshots__/phase-screens.spec.ts/", "browser": "chromium", "project": "chromium", "viewport": "1280x720", "device_scale_factor": 1, "comparator_kind": "maxDiffPixels", "comparator_value": "150", "style_path": False, "artifact_scope": "job", "digest_env": "TEST_RESULTS_DIGEST", "retention_days": 30, }, { "capture_id": "phase-screens.spec.ts::load-menu-empty.png", "spec_file": "tests/e2e/phase-screens.spec.ts", "screenshot_name": "load-menu-empty.png", "registry_id": None, "directory": "tests/e2e/__screenshots__/phase-screens.spec.ts/", "browser": "chromium", "project": "chromium", "viewport": "1280x720", "device_scale_factor": 1, "comparator_kind": "maxDiffPixels", "comparator_value": "150", "style_path": False, "artifact_scope": "job", "digest_env": "TEST_RESULTS_DIGEST", "retention_days": 30, }, { "capture_id": "phase-screens.spec.ts::load-menu-available.png", "spec_file": "tests/e2e/phase-screens.spec.ts", "screenshot_name": "load-menu-available.png", "registry_id": None, "directory": "tests/e2e/__screenshots__/phase-screens.spec.ts/", "browser": "chromium", "project": "chromium", "viewport": "1280x720", "device_scale_factor": 1, "comparator_kind": "maxDiffPixels", "comparator_value": "150", "style_path": False, "artifact_scope": "job", "digest_env": "TEST_RESULTS_DIGEST", "retention_days": 30, }, { "capture_id": "phase-screens.spec.ts::load-menu-failure.png", "spec_file": "tests/e2e/phase-screens.spec.ts", "screenshot_name": "load-menu-failure.png", "registry_id": None, "directory": "tests/e2e/__screenshots__/phase-screens.spec.ts/", "browser": "chromium", "project": "chromium", "viewport": "1280x720", "device_scale_factor": 1, "comparator_kind": "maxDiffPixels", "comparator_value": "150", "style_path": False, "artifact_scope": "job", "digest_env": "TEST_RESULTS_DIGEST", "retention_days": 30, }, { "capture_id": "phase-screens.spec.ts::preparation-default.png", "spec_file": "tests/e2e/phase-screens.spec.ts", "screenshot_name": "preparation-default.png", "registry_id": None, "directory": "tests/e2e/__screenshots__/phase-screens.spec.ts/", "browser": "chromium", "project": "chromium", "viewport": "1280x720", "device_scale_factor": 1, "comparator_kind": "maxDiffPixels", "comparator_value": "150", "style_path": False, "artifact_scope": "job", "digest_env": "TEST_RESULTS_DIGEST", "retention_days": 30, }, { "capture_id": "phase-screens.spec.ts::preparation-upgrade-available.png", "spec_file": "tests/e2e/phase-screens.spec.ts", "screenshot_name": "preparation-upgrade-available.png", "registry_id": None, "directory": "tests/e2e/__screenshots__/phase-screens.spec.ts/", "browser": "chromium", "project": "chromium", "viewport": "1280x720", "device_scale_factor": 1, "comparator_kind": "maxDiffPixels", "comparator_value": "150", "style_path": False, "artifact_scope": "job", "digest_env": "TEST_RESULTS_DIGEST", "retention_days": 30, }, { "capture_id": "phase-screens.spec.ts::running-minimal-hud.png", "spec_file": "tests/e2e/phase-screens.spec.ts", "screenshot_name": "running-minimal-hud.png", "registry_id": None, "directory": "tests/e2e/__screenshots__/phase-screens.spec.ts/", "browser": "chromium", "project": "chromium", "viewport": "1280x720", "device_scale_factor": 1, "comparator_kind": "maxDiffPixels", "comparator_value": "150", "style_path": False, "artifact_scope": "job", "digest_env": "TEST_RESULTS_DIGEST", "retention_days": 30, }, ] # ACTIVE_VRT_CAPTURES_END artifact_url = os.environ.get("TEST_RESULTS_URL", "N/A") for c in CAPTURES: digest = os.environ.get(c["digest_env"], "sha256:none") style = "yes" if c["style_path"] else "no" comparator = f"{c['comparator_kind']}={c['comparator_value']}" print( f"| {c['capture_id']} | {c['directory']} | {c['browser']} | {c['project']} | " f"{c['viewport']} | {c['device_scale_factor']} | {comparator} | {style} | " f"{c['artifact_scope']} | {artifact_url} | {digest} | {c['retention_days']} |" ) PY } >> "$GITHUB_STEP_SUMMARY" e2e-responsive-matrix: runs-on: ubuntu-24.04 defaults: run: shell: bash env: PLAYWRIGHT_VERSION: 1.60.0 PLAYWRIGHT_CONTAINER_IMAGE_DIGEST: sha256:9bd26ad900bb5e0f4dee75839e957a89ae89c2b7ab1e76050e559790e946b948 LOOP_E2E_LANE: responsive EXPECTED_PR_HEAD_SHA: ${{ github.event.pull_request.head.sha || github.sha }} container: image: mcr.microsoft.com/playwright@sha256:9bd26ad900bb5e0f4dee75839e957a89ae89c2b7ab1e76050e559790e946b948 options: --ipc=host steps: - uses: actions/checkout@v6 with: persist-credentials: false ref: ${{ github.event.pull_request.head.sha || github.sha }} - name: Enable pnpm via corepack run: | corepack enable pnpm corepack prepare pnpm@11.7.0 --activate - name: Install dependencies (timed) id: timed-pnpm-install run: | run_timed() { local step_id="$1"; shift local start_ms end_ms elapsed_ms status start_ms=$(date +%s%3N) set +e "$@" status=$? set -e end_ms=$(date +%s%3N) elapsed_ms=$((end_ms - start_ms)) printf '{"step_id":"%s","phase_id":"%s","status":%d,"elapsed_ms":%d}\n' \ "$step_id" "$step_id" "$status" "$elapsed_ms" \ >> measurements.jsonl return $status } run_timed pnpm_install pnpm install --frozen-lockfile - name: Verify Playwright Docker image version run: | PW_VERSION="$(node -p "require('@playwright/test/package.json').version")" if [ "$PW_VERSION" != "$PLAYWRIGHT_VERSION" ]; then echo "::error::resolved @playwright/test=$PW_VERSION but Docker image expects v$PLAYWRIGHT_VERSION. Update PLAYWRIGHT_VERSION and container.image digest in ci.yml." exit 1 fi echo "playwright_version_match=ok resolved=$PW_VERSION expected=$PLAYWRIGHT_VERSION" - name: Build for E2E (timed) id: timed-build-e2e run: | run_timed() { local step_id="$1"; shift local start_ms end_ms elapsed_ms status start_ms=$(date +%s%3N) set +e "$@" status=$? set -e end_ms=$(date +%s%3N) elapsed_ms=$((end_ms - start_ms)) printf '{"step_id":"%s","phase_id":"%s","status":%d,"elapsed_ms":%d}\n' \ "$step_id" "$step_id" "$status" "$elapsed_ms" \ >> measurements.jsonl return $status } run_timed pnpm_build_e2e env VITE_E2E_MODE=true pnpm build - name: Verify E2E dist boundary run: pnpm dist:e2e-boundary --mode e2e --dist dist - name: Run responsive-matrix E2E tests (timed) id: timed-e2e-responsive-matrix run: | run_timed() { local step_id="$1"; shift local start_ms end_ms elapsed_ms status start_ms=$(date +%s%3N) set +e "$@" status=$? set -e end_ms=$(date +%s%3N) elapsed_ms=$((end_ms - start_ms)) printf '{"step_id":"%s","phase_id":"%s","status":%d,"elapsed_ms":%d}\n' \ "$step_id" "$step_id" "$status" "$elapsed_ms" \ >> measurements.jsonl return $status } run_timed test_e2e_responsive_matrix pnpm exec playwright test tests/e2e/assist-player-affordance-responsive.spec.ts - name: Upload Playwright report (e2e-responsive-matrix) id: upload-playwright-report-responsive if: ${{ !cancelled() }} uses: actions/upload-artifact@v6 with: name: playwright-report-e2e-responsive-matrix path: playwright-report-e2e-responsive-matrix/ if-no-files-found: warn retention-days: 30 - name: Upload test results (e2e-responsive-matrix) id: upload-test-results-responsive if: ${{ !cancelled() }} uses: actions/upload-artifact@v6 with: name: test-results-e2e-responsive-matrix path: test-results-e2e-responsive-matrix/ if-no-files-found: warn retention-days: 30 - name: Locate responsive-canvas-runtime-evidence.json if: ${{ !cancelled() }} run: | set -euo pipefail mkdir -p responsive-canvas-runtime-evidence-artifact found="$(find test-results-e2e-responsive-matrix -name 'responsive-canvas-runtime-evidence.json' -print -quit || true)" if [ -z "$found" ]; then echo "::error::responsive-canvas-runtime-evidence.json not found under test-results-e2e-responsive-matrix/ — e2e-responsive-matrix did not produce the required RESPONSIVE_CANVAS_MATRIX_CONTRACT_V1 evidence." exit 1 fi cp "$found" responsive-canvas-runtime-evidence-artifact/responsive-canvas-runtime-evidence.json - name: Upload responsive-canvas-runtime-evidence artifact if: ${{ !cancelled() }} uses: actions/upload-artifact@v6 with: name: responsive-canvas-runtime-evidence-${{ github.run_attempt }} path: responsive-canvas-runtime-evidence-artifact/ if-no-files-found: error retention-days: 30 e2e: needs: - e2e-core - e2e-responsive-matrix if: always() runs-on: ubuntu-24.04 steps: - name: Require both game E2E lanes env: CORE_RESULT: ${{ needs.e2e-core.result }} RESPONSIVE_RESULT: ${{ needs.e2e-responsive-matrix.result }} run: | test "$CORE_RESULT" = success test "$RESPONSIVE_RESULT" = success component-vrt-report: runs-on: ubuntu-24.04 defaults: run: shell: bash env: PLAYWRIGHT_VERSION: 1.60.0 container: image: mcr.microsoft.com/playwright@sha256:9bd26ad900bb5e0f4dee75839e957a89ae89c2b7ab1e76050e559790e946b948 options: --ipc=host outputs: vrt_evidence_artifact_id: ${{ steps.vrt-evidence-artifact-digest.outputs.artifact_id }} vrt_evidence_artifact_digest: ${{ steps.vrt-evidence-artifact-digest.outputs.artifact_digest }} steps: - uses: actions/checkout@v6 with: persist-credentials: false ref: ${{ github.event.pull_request.head.sha || github.sha }} - uses: ./.github/actions/setup-python-uv - name: Enable pnpm via corepack run: | corepack enable pnpm corepack prepare pnpm@11.7.0 --activate - name: Install dependencies run: pnpm install --frozen-lockfile - name: Verify Playwright Docker image version run: | PW_VERSION="$(node -p "require('@playwright/test/package.json').version")" if [ "$PW_VERSION" != "$PLAYWRIGHT_VERSION" ]; then echo "::error::resolved @playwright/test=$PW_VERSION but Docker image expects v$PLAYWRIGHT_VERSION. Update PLAYWRIGHT_VERSION and container.image digest in ci.yml." exit 1 fi echo "playwright_version_match=ok resolved=$PW_VERSION expected=$PLAYWRIGHT_VERSION" - name: Typecheck component VRT id: typecheck-component-vrt run: pnpm typecheck:component-vrt - name: Run component VRT (Vitest Browser Mode, report-only) id: run-component-vrt run: pnpm test:vrt:component - name: Upload component VRT screenshots (baseline + actual/diff/expected on failure) id: upload-component-vrt-screenshots if: ${{ always() }} uses: actions/upload-artifact@v6 with: name: component-vrt-screenshots path: | tests/component/__screenshots__/ .vitest-attachments/tests/component/** if-no-files-found: warn retention-days: 30 include-hidden-files: true - name: Run hidden-attachment negative control (expected to mismatch) id: run-negative-control continue-on-error: true env: VITE_VRT_NEGATIVE_CONTROL: 'true' run: pnpm exec vitest run --config vitest.visual.config.ts tests/component/__negative_control__/hidden-attachment-negative-control.vrt.test.ts - name: Verify the negative control actually mismatched if: ${{ always() }} env: NEGATIVE_CONTROL_OUTCOME: ${{ steps.run-negative-control.outcome }} run: | if [ "${NEGATIVE_CONTROL_OUTCOME}" != "failure" ]; then echo "::error::hidden-attachment negative control outcome was '${NEGATIVE_CONTROL_OUTCOME}', expected 'failure' (the fixture is designed to ALWAYS mismatch). If it passed or was skipped, the fixture itself is broken and can no longer prove the actual/diff artifact pipeline works end to end." exit 1 fi echo "negative_control_outcome=ok (mismatched as expected)" - name: Upload negative control attachments id: upload-negative-control-attachments if: ${{ always() }} uses: actions/upload-artifact@v6 with: name: component-vrt-negative-control-attachments-${{ github.run_attempt }} path: .vitest-attachments/tests/component/__negative_control__/** if-no-files-found: error retention-days: 30 include-hidden-files: true - name: Download negative control attachments (round-trip proof) id: download-negative-control-1 continue-on-error: true if: ${{ always() && steps.upload-negative-control-attachments.outputs.artifact-id != '' }} uses: actions/download-artifact@v6 with: artifact-ids: ${{ steps.upload-negative-control-attachments.outputs.artifact-id }} path: negative-control-download - name: Wait before negative-control download retry 1 id: wait-negative-control-1 if: ${{ !cancelled() && steps.upload-negative-control-attachments.outputs.artifact-id != '' && steps.download-negative-control-1.outcome == 'failure' }} run: sleep 5 - name: Retry negative-control download 1 id: download-negative-control-2 continue-on-error: true if: ${{ !cancelled() && steps.upload-negative-control-attachments.outputs.artifact-id != '' && steps.download-negative-control-1.outcome == 'failure' }} uses: actions/download-artifact@v6 with: artifact-ids: ${{ steps.upload-negative-control-attachments.outputs.artifact-id }} path: negative-control-download - name: Wait before negative-control download retry 2 id: wait-negative-control-2 if: ${{ !cancelled() && steps.upload-negative-control-attachments.outputs.artifact-id != '' && steps.download-negative-control-2.outcome == 'failure' }} run: sleep 10 - name: Retry negative-control download 2 id: download-negative-control-3 if: ${{ !cancelled() && steps.upload-negative-control-attachments.outputs.artifact-id != '' && steps.download-negative-control-2.outcome == 'failure' }} uses: actions/download-artifact@v6 with: artifact-ids: ${{ steps.upload-negative-control-attachments.outputs.artifact-id }} path: negative-control-download - name: Assert actual/diff PNGs survived the hidden-file upload round trip if: ${{ always() }} id: verify-negative-control-attachments run: | shopt -s globstar nullglob actual_files=(negative-control-download/**/*-actual-*.png) diff_files=(negative-control-download/**/*-diff-*.png) if [ "${#actual_files[@]}" -eq 0 ]; then echo "::error::no *-actual-*.png found in the downloaded component-vrt-negative-control-attachments artifact — the hidden .vitest-attachments upload is NOT working end to end." find negative-control-download -type f exit 1 fi if [ "${#diff_files[@]}" -eq 0 ]; then echo "::error::no *-diff-*.png found in the downloaded component-vrt-negative-control-attachments artifact — the hidden .vitest-attachments upload is NOT working end to end." find negative-control-download -type f exit 1 fi echo "hidden_attachment_upload_proof=ok actual=${actual_files[*]} diff=${diff_files[*]}" - name: Run mutation negative control (HULL hidden, expected to mismatch) id: run-mutation-control-hull continue-on-error: true env: VITE_VRT_MUTATION_CONTROL_HULL: 'true' run: pnpm exec vitest run --config vitest.visual.config.ts -t "hull_hidden" tests/component/combat-hud-running.vrt.test.ts - name: Run mutation negative control (Pause hidden, expected to mismatch) id: run-mutation-control-pause continue-on-error: true env: VITE_VRT_MUTATION_CONTROL_PAUSE: 'true' run: pnpm exec vitest run --config vitest.visual.config.ts -t "pause_hidden" tests/component/combat-hud-running.vrt.test.ts - name: Run mutation negative control (elapsed hidden, expected to mismatch) id: run-mutation-control-elapsed continue-on-error: true env: VITE_VRT_MUTATION_CONTROL_ELAPSED: 'true' run: pnpm exec vitest run --config vitest.visual.config.ts -t "elapsed_hidden" tests/component/combat-hud-running.vrt.test.ts - name: Verify all three mutation controls actually mismatched if: ${{ always() }} env: HULL_OUTCOME: ${{ steps.run-mutation-control-hull.outcome }} PAUSE_OUTCOME: ${{ steps.run-mutation-control-pause.outcome }} ELAPSED_OUTCOME: ${{ steps.run-mutation-control-elapsed.outcome }} run: | fail=0 for pair in "hull_hidden:${HULL_OUTCOME}" "pause_hidden:${PAUSE_OUTCOME}" "elapsed_hidden:${ELAPSED_OUTCOME}"; do name="${pair%%:*}" outcome="${pair##*:}" if [ "${outcome}" != "success" ]; then echo "::error::mutation control '${name}' outcome was '${outcome}', expected 'success' (the guarded assertion \`await expect().rejects.toThrow()\` must itself PASS when hiding a critical HUD fragment is correctly detected as a mismatch). If it failed or was skipped, the comparator (or the control itself) has no real detection power for this fragment." fail=1 else echo "mutation_control ${name}=ok (mismatched as expected)" fi done if [ "${fail}" -eq 1 ]; then exit 1 fi - name: Capture triple-run render-determinism evidence (fresh browser process x3) id: evidence-triple-run run: pnpm run test:vrt:evidence:triple-run | tee /tmp/vrt-evidence-triple-run.log - name: Measure real mismatched-pixel count (zero-tolerance probe) id: zero-tolerance-probe continue-on-error: true run: | set -o pipefail # Scoped, never-committed override: the ONE real committed # `allowedMismatchedPixels: 48,` call site for # 'combat-hud-running.png' is temporarily tightened to 0 for this # single probe invocation only, then restored immediately after # (checked out fresh via git, never pushed/committed). This keeps # exactly one literal `toMatchScreenshot('combat-hud-running.png', # ...)` call site in the committed source at all times -- # `scripts/check-visual-artifact-pipeline.py`'s static validator # fails closed on duplicate/non-literal comparatorOptions call # sites for the same screenshot name otherwise (Issue #2014 AC1 # derivation comment in the spec file itself). cp tests/component/combat-hud-running.vrt.test.ts /tmp/combat-hud-running.vrt.test.ts.orig sed -i "0,/allowedMismatchedPixels: 48,/s//allowedMismatchedPixels: 0,/" tests/component/combat-hud-running.vrt.test.ts set +e pnpm exec vitest run --config vitest.visual.config.ts -t "combat-hud-running scenario" tests/component/combat-hud-running.vrt.test.ts 2>&1 | tee /tmp/vrt-zero-tolerance-probe.log probe_status="${PIPESTATUS[0]}" set -e cp /tmp/combat-hud-running.vrt.test.ts.orig tests/component/combat-hud-running.vrt.test.ts exit "${probe_status}" - name: Build VISUAL_BASELINE_REVIEW_EVIDENCE_V3 manifest id: build-evidence-manifest if: ${{ always() }} env: RUN_OUTCOME: ${{ steps.run-component-vrt.outcome }} PROBE_OUTCOME: ${{ steps.zero-tolerance-probe.outcome }} SCREENSHOTS_ARTIFACT_ID: ${{ steps.upload-component-vrt-screenshots.outputs.artifact-id || '' }} GH_HEAD_SHA: ${{ github.event.pull_request.head.sha || github.sha }} GH_RUN_ATTEMPT: ${{ github.run_attempt }} run: | set -o pipefail ACTUAL_1="$(grep -o 'actual_sha256_run_1=.*' /tmp/vrt-evidence-triple-run.log | tail -1 | cut -d= -f2)" ACTUAL_2="$(grep -o 'actual_sha256_run_2=.*' /tmp/vrt-evidence-triple-run.log | tail -1 | cut -d= -f2)" ACTUAL_3="$(grep -o 'actual_sha256_run_3=.*' /tmp/vrt-evidence-triple-run.log | tail -1 | cut -d= -f2)" if [ "${ACTUAL_1}" != "${ACTUAL_2}" ] || [ "${ACTUAL_2}" != "${ACTUAL_3}" ]; then echo "::error::triple-run actual PNG sha256 differs across runs (${ACTUAL_1} / ${ACTUAL_2} / ${ACTUAL_3}) -- refusing to build an evidence manifest on non-deterministic render output." exit 1 fi # AC1/AC8 (Issue #2014): `zero-tolerance-probe` re-runs the # running-scenario assertion with allowedMismatchedPixels forced to # 0. On a real 0px diff the probe PASSES (mismatched_pixels=0); on # any real diff Vitest's own error text reports the exact count # (" pixels (ratio ) differ."), which is parsed verbatim -- # never fabricated (Runtime Verification Applicability # fallback_policy). if [ "${PROBE_OUTCOME}" = "success" ]; then RUNNING_MISMATCHED=0 RUNNING_VERIFY_SUCCEEDED=true else RUNNING_MISMATCHED="$(grep -oP '^\d+(?= pixels \(ratio)' /tmp/vrt-zero-tolerance-probe.log | tail -1)" if [ -z "${RUNNING_MISMATCHED}" ]; then echo "::error::zero-tolerance-probe outcome was '${PROBE_OUTCOME}' but no mismatch-count line was found in its output -- refusing to fabricate a mismatched_pixels value." RUNNING_MISMATCHED="unknown_non_zero" fi RUNNING_VERIFY_SUCCEEDED=false fi # combat-hud-critical has no independent zero-tolerance probe today # (only combat-hud-running is triple-run/probed above) -- its # verified status is derived from the whole-file component-vrt run # outcome (both scenarios live in the same spec file and both # `toMatchScreenshot()` calls must pass for RUN_OUTCOME=success). # On failure, never guess WHICH scenario mismatched or by how much # -- fail-closed sentinel string, same "never fabricate" policy as # the running-scenario probe above. if [ "${RUN_OUTCOME}" = "success" ]; then CRITICAL_MISMATCHED=0 CRITICAL_VERIFY_SUCCEEDED=true else CRITICAL_MISMATCHED="unknown_non_zero" CRITICAL_VERIFY_SUCCEEDED=false fi python3 - "$GH_HEAD_SHA" "$GITHUB_RUN_ID" "$GH_RUN_ATTEMPT" "$ACTUAL_1" "$RUNNING_MISMATCHED" "$RUNNING_VERIFY_SUCCEEDED" "$CRITICAL_MISMATCHED" "$CRITICAL_VERIFY_SUCCEEDED" "$SCREENSHOTS_ARTIFACT_ID" <<'PY' > surface_inputs.json import json import sys ( head_sha, run_id, run_attempt, running_actual_sha256, running_mismatched, running_verify_succeeded, critical_mismatched, critical_verify_succeeded, screenshots_artifact_id, ) = sys.argv[1:10] def to_bool(value): return value == "true" def to_mismatched(value): return int(value) if value.lstrip("-").isdigit() else value # Issue #2230 fix_delta P1-2: `workflow_run_id`/`run_attempt` are # IDENTITY fields consumed by `resolve_visual_impact.py`'s strict, # non-coercing `_require_strict_positive_int` validator (never the # lenient `to_mismatched`-style string-coercion above, which is # correct only for pixel counts). `$GITHUB_RUN_ID`/`$GH_RUN_ATTEMPT` # arrive here as shell strings via sys.argv; GitHub's own # `github.run_id`/`github.run_attempt` context values are ALWAYS # positive integers by contract, so a plain `int()` cast (not a # defensive fallback-to-string) is correct -- if this ever raises, # that is itself a real bug worth surfacing loudly, not silently # swallowing back into a string identity field. run_id_int = int(run_id) run_attempt_int = int(run_attempt) records = [ { "surface_id": "combat-hud-running", "head_sha": head_sha, "workflow_run_id": run_id_int, "run_attempt": run_attempt_int, "actual_sha256": running_actual_sha256, "mismatched_pixels": to_mismatched(running_mismatched), "verify_succeeded": to_bool(running_verify_succeeded), "update_executed": False, "update_succeeded": False, "expected_artifact_id": screenshots_artifact_id, "actual_artifact_id": screenshots_artifact_id, "diff_artifact_id": screenshots_artifact_id, }, { "surface_id": "combat-hud-critical", "head_sha": head_sha, "workflow_run_id": run_id_int, "run_attempt": run_attempt_int, # No independent zero-tolerance probe exists for this # surface today -- never fabricate a per-run actual PNG # hash it did not itself produce. "actual_sha256": None, "mismatched_pixels": to_mismatched(critical_mismatched), "verify_succeeded": to_bool(critical_verify_succeeded), "update_executed": False, "update_succeeded": False, "expected_artifact_id": screenshots_artifact_id, "actual_artifact_id": screenshots_artifact_id, "diff_artifact_id": screenshots_artifact_id, }, ] json.dump(records, sys.stdout, indent=2) PY uv run --locked python3 scripts/agent-ops/resolve_visual_impact.py \ --mode build-evidence-manifest \ --surface-inputs-file surface_inputs.json \ --manifest-output /tmp/visual_baseline_review_evidence.json \ --evidence-manifest-schema v3 \ --run-id "$GITHUB_RUN_ID" \ --run-attempt "$GH_RUN_ATTEMPT" \ --head-sha "$GH_HEAD_SHA" { echo "" echo "### VISUAL_BASELINE_REVIEW_EVIDENCE_V3 (Issue #2019 P0-5, Issue #2284 Phase B)" echo '```json' cat /tmp/visual_baseline_review_evidence.json echo '```' } >> "$GITHUB_STEP_SUMMARY" - name: Upload VISUAL_BASELINE_REVIEW_EVIDENCE_V3 manifest id: upload-evidence-manifest if: ${{ always() }} uses: actions/upload-artifact@v6 with: name: component-vrt-evidence-manifest-${{ github.run_attempt }} path: /tmp/visual_baseline_review_evidence.json if-no-files-found: error retention-days: 30 - name: Emit vrt_evidence_artifact_digest job output id: vrt-evidence-artifact-digest if: ${{ always() }} env: VRT_EVIDENCE_ARTIFACT_ID: ${{ steps.upload-evidence-manifest.outputs.artifact-id || '' }} VRT_EVIDENCE_ARTIFACT_DIGEST: ${{ steps.upload-evidence-manifest.outputs.artifact-digest || '' }} run: | echo "artifact_id=${VRT_EVIDENCE_ARTIFACT_ID}" >> "$GITHUB_OUTPUT" echo "artifact_digest=${VRT_EVIDENCE_ARTIFACT_DIGEST}" >> "$GITHUB_OUTPUT" echo "vrt_evidence_artifact_digest=${VRT_EVIDENCE_ARTIFACT_DIGEST}" - name: Summarize component VRT evidence if: ${{ always() }} env: RUN_OUTCOME: ${{ steps.run-component-vrt.outcome }} TYPECHECK_OUTCOME: ${{ steps.typecheck-component-vrt.outcome }} NEGATIVE_CONTROL_OUTCOME: ${{ steps.run-negative-control.outcome }} NEGATIVE_CONTROL_PROOF_OUTCOME: ${{ steps.verify-negative-control-attachments.outcome }} SCREENSHOTS_URL: ${{ steps.upload-component-vrt-screenshots.outputs.artifact-url || 'N/A' }} SCREENSHOTS_DIGEST: ${{ steps.upload-component-vrt-screenshots.outputs.artifact-digest || 'sha256:none' }} run: | PW_VERSION="$(node -p "require('@playwright/test/package.json').version" 2>/dev/null || echo 'unknown')" # PR #1977 review fix (P2 item, OWNER REQUEST_CHANGES): a GitHub # Actions step `outcome` is `success` / `failure` / `skipped` / # `cancelled` — never an "exit code" — and each state is reported # distinctly below so a `skipped` step (e.g. from an earlier # dependency-install failure) is never conflated with "no visual # mismatch". classify_outcome() { case "$1" in success) echo "success (no visual mismatch)" ;; failure) echo "failure (visual mismatch or run failure detected)" ;; skipped) echo "skipped (step did not run — NOT the same as a pass)" ;; cancelled) echo "cancelled" ;; *) echo "unknown ($1)" ;; esac } { echo "## Component VRT (report-only, non-required — Issue #1389)" echo "" echo "Current-head evidence is consumed by the retained visual-impact-policy check." echo "" echo "### Environment fingerprint" echo "- typecheck outcome: $(classify_outcome "${TYPECHECK_OUTCOME}")" echo "- run outcome: $(classify_outcome "${RUN_OUTCOME}")" echo "- runner: ${RUNNER_OS} ${RUNNER_ARCH} (image ${ImageOS:-unknown} ${ImageVersion:-unknown})" echo "- node: $(node -p 'process.version')" echo "- Playwright: ${PW_VERSION}" echo "- browser: chromium" echo "- viewport: 1280x720" echo "- deviceScaleFactor: 1" echo "- screenshot directory: tests/component/__screenshots__/" echo "" echo "### Artifacts" echo "- component-vrt-screenshots (baseline + actual/expected/diff on failure): ${SCREENSHOTS_URL} (digest: ${SCREENSHOTS_DIGEST})" echo "" echo "### actual / expected / diff" if [ "${RUN_OUTCOME}" = "failure" ]; then echo "- visual mismatch or run failure detected: see the component-vrt-screenshots artifact above for any *-actual.png / *-expected.png / *-diff.png Vitest Browser Mode wrote" else echo "- N/A (no visual mismatch; expected/actual/diff are only emitted on toMatchScreenshot() failure)" fi echo "" echo "### Hidden-attachment upload proof (negative control)" echo "- fixture outcome: $(classify_outcome "${NEGATIVE_CONTROL_OUTCOME}") (expected: failure — the fixture is a deliberate, controlled mismatch)" echo "- round-trip verification: $(classify_outcome "${NEGATIVE_CONTROL_PROOF_OUTCOME}") (proves the uploaded artifact ZIP actually contains *-actual-*.png / *-diff-*.png)" } >> "$GITHUB_STEP_SUMMARY" visual-impact-policy: needs: - component-vrt-report runs-on: ubuntu-latest permissions: contents: read actions: read checks: read pull-requests: read issues: read steps: - uses: actions/checkout@v6 with: persist-credentials: false fetch-depth: 0 ref: ${{ github.event.pull_request.head.sha || github.sha }} - uses: ./.github/actions/setup-node-pnpm - uses: ./.github/actions/setup-python-uv - name: Install dependencies run: pnpm install --frozen-lockfile - name: Resolve base/head SHAs and registry blob SHAs id: shas env: BASE_SHA: ${{ github.event.pull_request.base.sha || '' }} HEAD_SHA: ${{ github.event.pull_request.head.sha || github.sha }} run: | echo "head_sha=${HEAD_SHA}" >> "$GITHUB_OUTPUT" if [ -n "${BASE_SHA}" ] && git cat-file -e "${BASE_SHA}" 2>/dev/null; then echo "base_sha=${BASE_SHA}" >> "$GITHUB_OUTPUT" # `git rev-parse --verify --quiet` (not plain `git rev-parse`) is # required here: without `--verify`, an unresolved `:` # arg makes git rev-parse ALSO echo the raw arg back to stdout # (pathspec disambiguation fallback) before exiting non-zero, # which corrupts the `||` fallback value with an extra bare line # and breaks $GITHUB_OUTPUT parsing (##[error]Invalid format). BASE_REGISTRY_BLOB_SHA="$(git rev-parse --verify --quiet "${BASE_SHA}:docs/dev/visual-surfaces.yml" 2>/dev/null || echo '0000000000000000000000000000000000000000')" else # push / workflow_dispatch (no PR base) -- diff against HEAD # itself, which yields an empty changed-path set (no-op run). echo "base_sha=${HEAD_SHA}" >> "$GITHUB_OUTPUT" BASE_REGISTRY_BLOB_SHA="0000000000000000000000000000000000000000" fi HEAD_REGISTRY_BLOB_SHA="$(git rev-parse --verify --quiet HEAD:docs/dev/visual-surfaces.yml 2>/dev/null || echo '0000000000000000000000000000000000000000')" echo "base_registry_blob_sha=${BASE_REGISTRY_BLOB_SHA}" >> "$GITHUB_OUTPUT" echo "head_registry_blob_sha=${HEAD_REGISTRY_BLOB_SHA}" >> "$GITHUB_OUTPUT" - name: Materialize base-branch-locked visual-impact evaluator (Issue id: trusted-evaluator env: BASE_SHA: ${{ steps.shas.outputs.base_sha }} run: | set -e mkdir -p trusted_evaluator/scripts/agent-ops trusted_evaluator/docs/dev : > trusted_evaluator_bootstrap.log for rel in scripts/agent-ops/resolve_visual_impact.py scripts/agent-ops/resolve_visual_impact.mjs docs/dev/visual-surfaces.schema.json docs/dev/visual-impact.schema.json do if git show "${BASE_SHA}:${rel}" > "trusted_evaluator/${rel}" 2>/dev/null; then echo "base_pinned=${rel}" else cp "${rel}" "trusted_evaluator/${rel}" echo "bootstrap_fallback_used_for=${rel} (does not exist at base_sha=${BASE_SHA} yet -- using head copy)" | tee -a trusted_evaluator_bootstrap.log fi done { echo "" echo "### Trust boundary hardening (Issue #2019 P0-6)" echo "- evaluator materialized from base_sha: \`${BASE_SHA}\`" if [ -s trusted_evaluator_bootstrap.log ]; then echo "- bootstrap fallback (base predates these files, head copy used instead):" sed 's/^/ - /' trusted_evaluator_bootstrap.log else echo "- fully base-pinned: no bootstrap fallback used" fi } >> "$GITHUB_STEP_SUMMARY" - name: Compute changed paths id: changed-paths env: BASE_SHA: ${{ steps.shas.outputs.base_sha }} HEAD_SHA: ${{ steps.shas.outputs.head_sha }} run: | set -o pipefail # PR #2045 OWNER fix_delta P0-4: `--name-status -z --find-renames` # (not plain `--name-only`) so renames/adds/removes keep their real # status instead of everything being forced to "modified" -- the # typed {"status","path","old_path"?} record set the policy check # consumes for both resolution (old+new path union) and the # VISUAL_IMPACT_DECISION_V1 changed_paths_digest. # # PR #2045 OWNER fix_delta P1-4 / P0-6: parsing is delegated to # `resolve_visual_impact.py --mode changed-paths` # (parse_git_diff_name_status_z) -- never re-implemented inline # here -- and, per the same P0-6 trust-boundary rationale as the # policy-check step below, the BASE-BRANCH-LOCKED copy # (trusted_evaluator/) is used so a malicious PR head cannot alter # its own rename-classification logic to hide a meta-policy-file # change from `resolve()`'s meta_policy_change detection. if git cat-file -e "${BASE_SHA}" 2>/dev/null; then git diff --name-status -z --find-renames "${BASE_SHA}" "${HEAD_SHA}" > changed_paths_name_status.nul else : > changed_paths_name_status.nul fi uv run --locked python3 trusted_evaluator/scripts/agent-ops/resolve_visual_impact.py \ --mode changed-paths \ --name-status-file changed_paths_name_status.nul \ --typed-output changed_paths_typed.json \ --flat-output changed_paths.txt cat changed_paths.txt - name: Write PR body to file (untrusted input -- never shell-expanded) env: GH_TOKEN: ${{ github.token }} PR_NUMBER: ${{ github.event.pull_request.number || '' }} run: | : > pr_body.md if [ -n "${PR_NUMBER}" ]; then gh api "repos/${GITHUB_REPOSITORY}/pulls/${PR_NUMBER}" --jq '.body // ""' > pr_body.md fi - name: Write trusted base-branch CODEOWNERS env: BASE_SHA: ${{ steps.shas.outputs.base_sha }} run: | git show "${BASE_SHA}:.github/CODEOWNERS" > base_codeowners.txt 2>/dev/null || : > base_codeowners.txt - name: Download component-vrt-evidence-manifest artifact (same run) id: download-evidence-manifest if: ${{ needs.component-vrt-report.outputs.vrt_evidence_artifact_id != '' }} uses: actions/download-artifact@v6 with: artifact-ids: ${{ needs.component-vrt-report.outputs.vrt_evidence_artifact_id }} path: evidence-manifest-download - name: Resolve component-vrt-report CheckRun id for current head id: component-vrt-check-run if: ${{ always() }} env: GH_TOKEN: ${{ github.token }} HEAD_SHA: ${{ steps.shas.outputs.head_sha }} run: | gh api "repos/${GITHUB_REPOSITORY}/commits/${HEAD_SHA}/check-runs?per_page=100" > check_runs.json || echo '{"check_runs":[]}' > check_runs.json # jq (not a bare `python3 -c` command substitution) is used here so # this step stays outside the governed Python invocation policy # (#1193) scope entirely -- `python3 -c "..."` inside `$(...)` was # rejected as unsupported_shell_grammar by # scripts/ci/check_python_invocation_policy.py --strict. # # PR #2045 OWNER fix_delta P0-5 second-round REQUEST_CHANGES: # filter on check_name AND status=="completed" AND # app.slug=="github-actions" (never name alone), then pick the # MOST RECENTLY COMPLETED match (never an arbitrary "first row of # the same name" -- a rerun can leave multiple check runs with the # identical name for the same head SHA). MATCHED="$(jq -c '(.check_runs // []) | map(select(.name == "component-vrt-report" and .status == "completed" and .app.slug == "github-actions")) | sort_by(.completed_at) | reverse | (.[0] // {})' check_runs.json)" CHECK_RUN_ID="$(echo "${MATCHED}" | jq -r '(.id // "") | tostring')" CHECK_SUITE_ID="$(echo "${MATCHED}" | jq -r '(.check_suite.id // "") | tostring')" APP_ID="$(echo "${MATCHED}" | jq -r '(.app.id // "") | tostring')" APP_SLUG="$(echo "${MATCHED}" | jq -r '(.app.slug // "")')" CHECK_CONCLUSION="$(echo "${MATCHED}" | jq -r '(.conclusion // "")')" { echo "check_run_id=${CHECK_RUN_ID}" echo "check_suite_id=${CHECK_SUITE_ID}" echo "app_id=${APP_ID}" echo "app_slug=${APP_SLUG}" echo "check_conclusion=${CHECK_CONCLUSION}" } >> "$GITHUB_OUTPUT" - name: Run visual-impact-policy check id: policy-check if: ${{ github.event_name == 'pull_request' }} env: HEAD_SHA: ${{ steps.shas.outputs.head_sha }} BASE_SHA: ${{ steps.shas.outputs.base_sha }} BASE_REGISTRY_BLOB_SHA: ${{ steps.shas.outputs.base_registry_blob_sha }} HEAD_REGISTRY_BLOB_SHA: ${{ steps.shas.outputs.head_registry_blob_sha }} PR_ACTOR: ${{ github.event.pull_request.user.login || '' }} PR_NUMBER: ${{ github.event.pull_request.number || 0 }} VRT_ARTIFACT_ID: ${{ needs.component-vrt-report.outputs.vrt_evidence_artifact_id || '' }} VRT_ARTIFACT_DIGEST: ${{ needs.component-vrt-report.outputs.vrt_evidence_artifact_digest || '' }} COMPONENT_VRT_CHECK_RUN_ID: ${{ steps.component-vrt-check-run.outputs.check_run_id || '' }} COMPONENT_VRT_CHECK_SUITE_ID: ${{ steps.component-vrt-check-run.outputs.check_suite_id || '' }} COMPONENT_VRT_APP_ID: ${{ steps.component-vrt-check-run.outputs.app_id || '' }} COMPONENT_VRT_APP_SLUG: ${{ steps.component-vrt-check-run.outputs.app_slug || '' }} COMPONENT_VRT_CHECK_CONCLUSION: ${{ steps.component-vrt-check-run.outputs.check_conclusion || '' }} GH_RUN_ID: ${{ github.run_id }} GH_RUN_ATTEMPT: ${{ github.run_attempt }} run: | # PR #2045 OWNER fix_delta P0-1: `set +o pipefail` here made the # `| tee` pipeline's exit status always be `tee`'s (0), so a # non-zero evaluator exit was silently discarded and the step # (and therefore the required `visual-impact-policy` check) # PASSED regardless of the actual policy result. `set -o # pipefail` makes the pipeline exit non-zero whenever the # evaluator itself does. set -o pipefail # Issue #2019 P0-6: run the BASE-BRANCH-LOCKED copy of the # evaluator (materialized above), never the PR head's own # `scripts/agent-ops/resolve_visual_impact.py` -- see the # "Materialize base-branch-locked visual-impact evaluator" step # comment above for the full trust-boundary rationale. `--schema` # / `--visual-impact-schema` / `--mjs` are likewise base-pinned; # `--registry` stays pointed at the real (head-checked-out) # working-tree path because the evaluator itself resolves registry # CONTENT via `--head-ref`/`--base-ref` (`git show :`), # never the raw working-tree file, for both base and head. # # NOTE (Issue #2230 fix_delta P1-1/P1-5, 2026-08-21, PR #2279 # review comment #2279#issuecomment-5369771738): because this # step ALWAYS runs the BASE-BRANCH-LOCKED evaluator above, a PR # that changes `build_decision()`'s signature/behavior (like # Issue #2230's `workflow_run_id`/`run_attempt` threading) can # never exercise its OWN new logic on its OWN CI run -- on THIS # PR's own pre-merge run, `--run-id`/`--run-attempt` below parse # fine (base already has those CLI flags from an unrelated # subcommand) but are silently NOT forwarded into `decision.json` # yet, since base's `build_decision()` predates this change. Do # not mistake that for a regression. This is an INHERENT # bootstrap/self-validation gap shared by every past change to # this base-locked evaluator (#2019, #2091, #2099, #2100, #2229) # -- splitting a change across multiple PRs does not remove the # gap, it only relocates which PR carries it, since producer # (this job) and consumer (`visual-impact-trusted-consumer.yml`) # both flip to the new workflow-file version simultaneously at # merge (no version-skew window). The first real proof that new # evaluator logic works end to end can only come from a # POST-MERGE run on `main` (see PR #2279's AC9 section, corrected # to SKIP/OPEN for exactly this reason). uv run --locked python3 trusted_evaluator/scripts/agent-ops/resolve_visual_impact.py \ --mode policy-check \ --registry docs/dev/visual-surfaces.yml \ --schema trusted_evaluator/docs/dev/visual-surfaces.schema.json \ --visual-impact-schema trusted_evaluator/docs/dev/visual-impact.schema.json \ --mjs trusted_evaluator/scripts/agent-ops/resolve_visual_impact.mjs \ --repo-root . \ --changed-paths-typed-file changed_paths_typed.json \ --changed-paths-file changed_paths.txt \ --pr-body-file pr_body.md \ --evidence-manifest-file evidence-manifest-download/visual_baseline_review_evidence.json \ --codeowners-file base_codeowners.txt \ --actor "${PR_ACTOR}" \ --repository "${GITHUB_REPOSITORY}" \ --pr-number "${PR_NUMBER}" \ --base-sha "${BASE_SHA}" \ --head-sha "${HEAD_SHA}" \ --base-ref "${BASE_SHA}" \ --head-ref "${HEAD_SHA}" \ --base-registry-blob-sha "${BASE_REGISTRY_BLOB_SHA}" \ --head-registry-blob-sha "${HEAD_REGISTRY_BLOB_SHA}" \ --component-vrt-check-run-id "${COMPONENT_VRT_CHECK_RUN_ID}" \ --component-vrt-check-suite-id "${COMPONENT_VRT_CHECK_SUITE_ID}" \ --component-vrt-app-id "${COMPONENT_VRT_APP_ID}" \ --component-vrt-app-slug "${COMPONENT_VRT_APP_SLUG}" \ --component-vrt-check-conclusion "${COMPONENT_VRT_CHECK_CONCLUSION}" \ --github-actions-app-identity "github-actions[bot]" \ --artifact-id "${VRT_ARTIFACT_ID}" \ --artifact-digest "${VRT_ARTIFACT_DIGEST}" \ --run-id "${GH_RUN_ID}" \ --run-attempt "${GH_RUN_ATTEMPT}" \ --decision-output visual_impact_decision_v1.json \ | tee policy_check_output.json - name: Upload VISUAL_IMPACT_DECISION_V1 artifact if: ${{ always() && github.event_name == 'pull_request' }} uses: actions/upload-artifact@v6 with: name: visual-impact-decision-v1-${{ github.run_attempt }} path: visual_impact_decision_v1.json if-no-files-found: error retention-days: 30 if: always() python-test-core: runs-on: ubuntu-latest steps: - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 with: persist-credentials: false ref: ${{ github.event.pull_request.head.sha || github.sha }} - uses: ./.github/actions/setup-node-pnpm - uses: ./.github/actions/setup-python-uv - run: pnpm install --frozen-lockfile - run: uv sync --locked --group dev - name: Validate retained Python sources and dependency lock run: | uv lock --check uv run --locked ruff check . - name: Game and retained secret-boundary regressions run: uv run --locked pytest -q - name: Game schema and visual pipeline checks run: | uv run --locked python scripts/check_input_command_schema.py uv run --locked python scripts/check-visual-artifact-pipeline.py .github/workflows/ci.yml uv run --locked python scripts/check-vrt-snapshot-policy.py python-test: needs: - python-test-core if: always() runs-on: ubuntu-latest steps: - env: RESULT: ${{ needs.python-test-core.result }} run: test "$RESULT" = success actionlint: runs-on: ubuntu-latest env: GH_HEAD_SHA: ${{ github.event.pull_request.head.sha || github.sha }} steps: - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 with: persist-credentials: false ref: ${{ github.event.pull_request.head.sha || github.sha }} - name: Install actionlint (timed) id: timed-actionlint-install run: | run_timed() { local step_id="$1"; shift local start_ms end_ms elapsed_ms status start_ms=$(date +%s%3N) set +e "$@" status=$? set -e end_ms=$(date +%s%3N) elapsed_ms=$((end_ms - start_ms)) printf '{"step_id":"%s","phase_id":"%s","status":%d,"elapsed_ms":%d}\n' \ "$step_id" "$step_id" "$status" "$elapsed_ms" \ >> measurements.jsonl return $status } run_timed actionlint_install bash -c 'curl -fsSL https://raw.githubusercontent.com/rhysd/actionlint/914e7df21a07ef503a81201c76d2b11c789d3fca/scripts/download-actionlint.bash | bash -s -- 1.7.12 && sudo mv actionlint /usr/local/bin/actionlint' - name: Run actionlint (timed) id: timed-actionlint run: | run_timed() { local step_id="$1"; shift local start_ms end_ms elapsed_ms status start_ms=$(date +%s%3N) set +e "$@" status=$? set -e end_ms=$(date +%s%3N) elapsed_ms=$((end_ms - start_ms)) printf '{"step_id":"%s","phase_id":"%s","status":%d,"elapsed_ms":%d}\n' \ "$step_id" "$step_id" "$status" "$elapsed_ms" \ >> measurements.jsonl return $status } run_timed actionlint actionlint ci-verdict-summary: needs: - typecheck - lint - test - build - e2e - python-test - actionlint - visual-impact-policy if: always() runs-on: ubuntu-latest steps: - name: Require retained game checks env: RESULTS: ${{ toJSON(needs) }} run: | python3 - <<'PYCODE' import json, os, sys results = json.loads(os.environ['RESULTS']) failed = {name: value['result'] for name, value in results.items() if value['result'] != 'success'} print(json.dumps({'checks': results, 'non_success': failed}, indent=2)) sys.exit(bool(failed)) PYCODE