diff --git a/.gitea/workflows/quality-gates.yml b/.gitea/workflows/quality-gates.yml index 4bf9eb16..582f543e 100644 --- a/.gitea/workflows/quality-gates.yml +++ b/.gitea/workflows/quality-gates.yml @@ -41,6 +41,8 @@ jobs: if: ${{ gitea.event_name != 'workflow_dispatch' || (inputs.stage != 'documentation' && inputs.stage != 'main') }} runs-on: ubuntu-latest timeout-minutes: 45 + env: + CI_PR_BASE_REF: "${{ gitea.event_name == 'pull_request' && gitea.base_ref || '' }}" steps: - uses: https://github.com/actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 with: @@ -108,6 +110,8 @@ jobs: # FE-GATE-013 runner requirement: unprivileged user and network namespaces for bwrap (the provider sandbox runs bwrap --unshare-pid --unshare-ipc --unshare-uts --unshare-net); Ubuntu 23.10 and later refuse them while kernel.apparmor_restrict_unprivileged_userns=1 unless /usr/bin/bwrap has an AppArmor profile that allows userns; scripts/check-system-test-prerequisites.ts probes this before test:system runs and scripts/run-and-validate-provider.ts before a provider runs runs-on: ubuntu-latest timeout-minutes: 45 + env: + CI_PR_BASE_REF: "${{ gitea.event_name == 'pull_request' && gitea.base_ref || '' }}" steps: - uses: https://github.com/actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 with: @@ -178,6 +182,7 @@ jobs: options: "--shm-size=2g" env: CI_RUNNER_IMAGE: "mcr.microsoft.com/playwright:v1.62.0-noble@sha256:baed2032d533817f3dbe6425de795788430ba345e819a1201337009ba17c9d07" + CI_PR_BASE_REF: "${{ gitea.event_name == 'pull_request' && gitea.base_ref || '' }}" steps: - uses: https://github.com/actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 with: diff --git a/config/ci/gates.json b/config/ci/gates.json index 594c173d..76cd626f 100644 --- a/config/ci/gates.json +++ b/config/ci/gates.json @@ -2156,7 +2156,12 @@ "FE-GATE-012" ], "browserGateIds": [], - "environment": [], + "environment": [ + { + "name": "CI_PR_BASE_REF", + "value": "${{ gitea.event_name == 'pull_request' && gitea.base_ref || '' }}" + } + ], "steps": [ { "kind": "checkout" @@ -2200,7 +2205,12 @@ "FE-GATE-020" ], "browserGateIds": [], - "environment": [], + "environment": [ + { + "name": "CI_PR_BASE_REF", + "value": "${{ gitea.event_name == 'pull_request' && gitea.base_ref || '' }}" + } + ], "steps": [ { "kind": "checkout" @@ -2243,7 +2253,12 @@ "FE-GATE-008", "FE-GATE-009" ], - "environment": [], + "environment": [ + { + "name": "CI_PR_BASE_REF", + "value": "${{ gitea.event_name == 'pull_request' && gitea.base_ref || '' }}" + } + ], "steps": [ { "kind": "checkout" diff --git a/config/ci/pr-gate-selection.json b/config/ci/pr-gate-selection.json new file mode 100644 index 00000000..eaaade77 --- /dev/null +++ b/config/ci/pr-gate-selection.json @@ -0,0 +1,121 @@ +{ + "$comment": "PR 경로표(design-docs ci/manual.md 4.3절). PR run의 merge 게이트를 바뀐 파일로 고른다. main·release run은 늘 전부 돈다. global 파일이나 어느 줄에도 안 걸리는 파일이 하나라도 바뀌면 전부 돈다. 파일마다 rules를 위에서부터 보고 처음 맞는 줄 하나의 게이트를 always에 더한다. 판정은 scripts/lib/pr-gate-selection.ts, 계약 시험은 tests/unit/pr-gate-selection.test.ts.", + "schemaVersion": 1, + "always": [ + "FE-GATE-001", + "FE-GATE-002", + "FE-GATE-003", + "FE-GATE-010" + ], + "global": [ + ".gitea/**", + ".storybook/**", + "config/**", + "scripts/**", + "package.json", + "pnpm-lock.yaml", + "pnpm-workspace.yaml", + ".env.example", + ".nvmrc", + ".npmrc", + ".gitattributes", + ".gitignore", + ".dependency-cruiser.json", + "renovate.json", + "eslint.config.ts", + "vite.config.ts", + "vite.service-worker.config.ts", + "vitest.config.ts", + "playwright*.config.ts", + "tsconfig*.json" + ], + "rules": [ + { + "id": "accessibility-records", + "paths": [ + "docs/accessibility/**" + ], + "gates": [ + "FE-GATE-005", + "FE-GATE-009", + "FE-GATE-020" + ] + }, + { + "id": "documents", + "paths": [ + "docs/**", + "**/*.md", + ".claude/**" + ], + "gates": [ + "FE-GATE-005" + ] + }, + { + "id": "recipes", + "paths": [ + "recipes/**" + ], + "gates": [ + "FE-GATE-005", + "FE-GATE-007", + "FE-GATE-012" + ] + }, + { + "id": "scaffold", + "paths": [ + "src/features/**", + "src/contexts/**", + "tests/features/**", + "tests/mocks/**", + "tests/fixtures/typecheck/**", + "tests/component/router.test.tsx", + "tests/integration/http-execution-v3-observability.test.ts", + "tests/integration/http-scenario-catalog.test.ts", + "tests/unit/ci-workflow-generation.test.ts", + "tests/unit/external-contract-runtime.test.ts", + "tests/unit/http-execution-v3.test.ts", + "tests/unit/http-scenario-evidence.test.ts", + "tests/unit/removal-fixture.test.ts", + "tests/unit/runtime-adapters.test.ts", + "tests/unit/session-route-access.test.ts", + "tests/unit/__snapshots__/**" + ], + "gates": [ + "FE-GATE-004", + "FE-GATE-005", + "FE-GATE-006", + "FE-GATE-007", + "FE-GATE-008", + "FE-GATE-009", + "FE-GATE-011", + "FE-GATE-012", + "FE-GATE-013", + "FE-GATE-020" + ] + }, + { + "id": "application", + "paths": [ + "src/**", + "tests/**", + "public/**", + "artifacts/**", + "index.html" + ], + "gates": [ + "FE-GATE-004", + "FE-GATE-005", + "FE-GATE-006", + "FE-GATE-007", + "FE-GATE-008", + "FE-GATE-009", + "FE-GATE-011", + "FE-GATE-012", + "FE-GATE-013" + ] + } + ] +} diff --git a/docs/operations/ci-quality-gates.md b/docs/operations/ci-quality-gates.md index ae54a31d..9071ea41 100644 --- a/docs/operations/ci-quality-gates.md +++ b/docs/operations/ci-quality-gates.md @@ -12,6 +12,15 @@ 2 GB로 연다(`--shm-size=2g`). Firefox 시험 프로필을 RAM에 두기 위해서다 (`tests/support/browser/browser-test.ts`). Docker 기본값 64 MB면 프로필이 runner 디스크에 남아 Firefox의 첫 localStorage 접근이 수 초씩 기다렸다. +PR run(`pull_request`)은 merge 게이트를 바뀐 파일로 고른다(소유자 결정 2026-11-13). 경로표는 +`config/ci/pr-gate-selection.json`이다. 파일마다 `rules`를 위에서부터 보고 처음 맞는 줄의 게이트를 +`always`(FE-GATE-001·002·003·010)에 더한다. 문서만 바뀌면 FE-GATE-005까지 돌고, `src/features/`처럼 +scaffold 드릴의 입력이 바뀌면 FE-GATE-020까지 돈다. `global` 파일(`config/`, `scripts/`, `.gitea/`, +도구 설정, lockfile)이나 표에 없는 파일이 하나라도 바뀌면 전부 돈다. 안 도는 게이트는 그 step에서 +`건너뜀: <게이트 ID> — <이유>`를 찍고 성공으로 끝나며, 게이트 로그도 그 한 줄이다. diff는 base +브랜치와의 merge base에서 잰다. checkout이 얕아 첫 게이트가 history를 받는다. diff를 못 읽으면 전부 +돈다. main·release run은 늘 전부 돈다. 판정은 `scripts/lib/pr-gate-selection.ts`, 계약 시험은 +`tests/unit/pr-gate-selection.test.ts`다. merge job 셋만 의존성 캐시를 쓴다(권하는 안으로 정함 2026-11-13, 총괄). setup-node 앞에서 Node toolcache, corepack이 받은 pnpm, pnpm store와 메타데이터 캐시를 `.nvmrc`와 diff --git a/docs/work/reference/decisions.md b/docs/work/reference/decisions.md index b5bab5de..23397268 100644 --- a/docs/work/reference/decisions.md +++ b/docs/work/reference/decisions.md @@ -72,6 +72,7 @@ | round9 R9-D12 CSS·라우트 lazy 합 예산 | 2026-11-12 | 권하는 안으로 정함(2026-11-12, 총괄). 지금 값을 기록만 하고 예산은 두지 않는다. 다시 볼 때: 첫 공개 기능 라우트 lab. 버린 안: 예산 신설 | 같음, 1101/15-03 | | 결정 p 선택 runtime 제거 드릴을 main 단계로 | 2026-11-12 | FE-GATE-020의 선택 runtime 제거 드릴 셋(optional recipe, browser file/storage, realtime)을 새 게이트 FE-GATE-030으로 떼어 main 단계(`main_gate`)에서 돌린다. 기능 드릴(샘플 제거, scaffold)은 merge에 남는다. 이유: runner PR 1회 약 30분 가운데 7분쯤이고, worker를 늘리지 않고 merge 25분 목표에 닿는 길이 이것뿐이었다. 대가: 그 셋의 회귀를 병합 뒤 main run에서 본다. main이 빨강이면 다음 PR이 고친다. 짝 백엔드가 무거운 lane을 nightly로 옮긴 것과 같은 모양이다. 재검토: runner가 늘거나 드릴이 빨라져 merge에 다시 넣어도 25분 안이면 되돌린다 | 권하는 안으로 정함(2026-11-12, 총괄): 백엔드 nightly lane과 같은 모양(design-docs `template-program/README.md` 5절 p, w2-fe-2가 올린 O1) | | 의존성 캐시는 merge job만 | 2026-11-13 | merge job 셋(`merge_static`·`merge_test`·`merge_browser`)만 Node toolcache·corepack·pnpm store와 메타데이터 캐시를 `.nvmrc`·`pnpm-lock.yaml` 해시 키로 복원하고, 저장은 main run만 한다. release·promotion·provider job은 공급망 증거를 만들므로 매번 새로 설치한다. 이유: worker를 늘리지 않고 job마다 되풀이하던 내려받기와 공급망 검증 요청을 없앤다. 캐시가 없거나 깨져도 frozen install이 같은 node_modules를 만든다. 짝 백엔드의 JDK·Gradle·Trivy 캐시와 같은 저장 규칙이다. 버린 안: CI 이미지에 의존성을 굽기(레지스트리 쓰기 토큰이 든다). 규칙의 정본은 `scripts/contracts/ci-gates.ts`의 `DEPENDENCY_CACHE` | 권하는 안으로 정함(2026-11-13, 총괄): 의존성 캐시는 merge job만, 공급망 증거 job은 매번 새로 설치 | +| PR은 바뀐 범위의 merge 게이트만 | 2026-11-13 | PR run의 merge job은 `config/ci/pr-gate-selection.json` 경로표로 바뀐 파일이 닿는 게이트만 돌고, 안 도는 게이트는 `건너뜀: <게이트 ID> — <이유>` 한 줄을 남긴다. 전역 파일·표에 없는 파일·빈 diff·diff를 못 읽음이면 전부 돈다. main·release run은 늘 전부 돈다. 판정은 `scripts/lib/pr-gate-selection.ts`, 계약 시험은 `tests/unit/pr-gate-selection.test.ts`다 | 소유자 결정(2026-11-13 18:3x, design-docs `ci/manual.md` 4절). PR 경로표가 놓친 것은 main이 잡는다. main push에서 선택 때문에 놓친 실패가 나오면 경로표를 고친다 | | 구조·기술 결정 기록 | 2026-07-26~ | `VD-01`~(빈 번호 있음) | `docs/adr/` | ## 3. 결정 대기 쓰는 법 diff --git a/scripts/contracts/ci-gates.ts b/scripts/contracts/ci-gates.ts index 45f41d23..ecb748fe 100644 --- a/scripts/contracts/ci-gates.ts +++ b/scripts/contracts/ci-gates.ts @@ -4,6 +4,7 @@ import path from "node:path"; import { z } from "zod"; import { DEPENDENCY_ADVISORIES_RECORD_PATH } from "../lib/dependency-advisories.ts"; +import { PR_BASE_REF_VARIABLE } from "../lib/pr-gate-selection.ts"; import { selectRepositoryPaths } from "../lib/repository-layout.ts"; import { PROMOTION_FORMULA } from "../lib/promotion-readiness.ts"; import { @@ -999,10 +1000,16 @@ function validateContractSemantics( issue(`canonical job step sequence drift: ${jobId}`); } } + const PR_BASE_REF_BINDING = Object.freeze({ + name: PR_BASE_REF_VARIABLE, + value: "${{ gitea.event_name == 'pull_request' && gitea.base_ref || '' }}", + }); const expectedEnvironmentBindings: Readonly []>> = { - merge_static: [], - merge_test: [], - merge_browser: [], + // PR gate selection (config/ci/pr-gate-selection.json): the base branch + // of a pull_request run, empty in every other run, which runs every gate. + merge_static: [PR_BASE_REF_BINDING], + merge_test: [PR_BASE_REF_BINDING], + merge_browser: [PR_BASE_REF_BINDING], release_gate: [ // 1112/05-01 (R9-D7, release tag). FE-GATE-028 compares each signed // record's Release ID with the tag being released. A run that is not a diff --git a/scripts/lib/fixture-node-modules.ts b/scripts/lib/fixture-node-modules.ts index 26e3e7b5..25460b12 100644 --- a/scripts/lib/fixture-node-modules.ts +++ b/scripts/lib/fixture-node-modules.ts @@ -1,6 +1,8 @@ import { copyFile, mkdir, readdir, readFile, stat, symlink, writeFile } from "node:fs/promises"; import path from "node:path"; +import { PR_BASE_REF_VARIABLE } from "./pr-gate-selection.ts"; + /** * Links the repository's installed dependencies into a throwaway fixture root. * @@ -36,9 +38,18 @@ import path from "node:path"; * shims. A fixture started through `pnpm