From 0739f26b80cec2ffb48b77080a543c725489b7e6 Mon Sep 17 00:00:00 2001 From: DongHyeonka Date: Sun, 8 Nov 2026 17:53:51 +0900 Subject: [PATCH 1/5] =?UTF-8?q?ci(gates):=20merge=20=EB=8B=A8=EA=B3=84=20j?= =?UTF-8?q?ob=2014=EA=B0=9C=EB=A5=BC=20=EC=85=8B=EC=9C=BC=EB=A1=9C=20?= =?UTF-8?q?=ED=95=A9=EC=B9=9C=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit merge 단계가 게이트마다 job 하나(행렬 14개)라서 PR마다 checkout, setup-node, `pnpm install`을 14번 하고 브라우저 설치를 2번 한다. Gitea runner는 소유자 기계 한 대다. 사례(Vite 등)는 설치를 job당 한 번으로 묶는다(design-docs repo-structure/03-ci.md 3.5절). 고른 방법(03-ci.md 7.3절 F1, 소유자 승인 2026-11-07): - job 종류 `gate-sequence`를 더한다. job 하나가 게이트 여럿을 차례로 돈다. 게이트마다 `FE-GATE-NNN / <이름>` 단계이고 `if: !cancelled()`라 앞 게이트가 실패해도 다음 게이트가 돈다(행렬의 fail-fast: false와 같다). - merge job 셋: `merge_static`(001·002·003·010·011·012, 소스를 읽고 빌드하는 검사), `merge_test`(004·005·006·007·013·020, 시험), `merge_browser`(008·009, 브라우저 설치). release 단계는 셋을 모두 기다린다. 게이트 id·명령·증거·승격 공식은 그대로다. - 증거 업로드는 job마다 하나(`merge-static-` 등)다. 버린 것: 행렬을 두고 `pnpm install`만 캐시하는 방법. runner 한 대에서는 job 수만큼 checkout과 준비가 남는다. 게이트를 job 하나에 모두 넣는 방법은 브라우저 설치를 모든 게이트가 기다린다. 위험: 한 job 안의 게이트가 같은 작업 공간을 쓴다. 앞 게이트의 산출물이 뒤 게이트에 남는다. desktop의 merge 단계 실행(게이트를 한 checkout에서 차례로 도는 것)과 같은 조건이라 그 결과로 확인했다. 실제 Gitea runner의 `!cancelled()` 해석은 Actions를 켠 뒤 확인한다. 검증(desktop): check:ci, check:types, CI 시험 4파일 통과. 합치기 전후 merge 단계 게이트별 결과 비교는 PR 본문에 적는다. Refs: design-docs repo-structure/03-ci.md 3.5·7.3·7.4절, README.md 3.3절 --- .gitea/workflows/quality-gates.yml | 121 ++++++++++++++---- config/ci/gates.json | 94 ++++++++++++-- docs/operations/ci-quality-gates.md | 10 +- scripts/contracts/ci-gates.ts | 27 +++- scripts/generate-ci-workflow.ts | 13 +- scripts/lib/ci-contract-report.ts | 2 +- scripts/lib/feature-scaffold-drill.ts | 2 +- tests/fixtures/ci-contract/job-cycle.json | 2 +- .../ci-contract/unknown-job-dependency.json | 2 +- tests/fixtures/ci-contract/unowned-gate.json | 2 +- .../ci-workflow-generation.test.ts.snap | 121 ++++++++++++++---- tests/unit/ci-workflow-generation.test.ts | 17 +-- tests/unit/product-ci-overlay.test.ts | 4 +- 13 files changed, 327 insertions(+), 90 deletions(-) diff --git a/.gitea/workflows/quality-gates.yml b/.gitea/workflows/quality-gates.yml index 20d19234..8483eb6d 100644 --- a/.gitea/workflows/quality-gates.yml +++ b/.gitea/workflows/quality-gates.yml @@ -31,31 +31,97 @@ env: CI_RUNNER_IMAGE: "${{ vars.RUNNER_IMAGE_DIGEST }}" jobs: - merge_gate: - name: "${{ matrix.gate }} / ${{ matrix.name }}" + merge_static: + name: "merge / static checks" + if: ${{ gitea.event_name != 'workflow_dispatch' || inputs.stage != 'documentation' }} + runs-on: ubuntu-latest + timeout-minutes: 45 + steps: + - uses: https://github.com/actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 + with: + persist-credentials: false + - uses: https://github.com/actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 + with: + node-version-file: .nvmrc + - name: Frozen install + run: | + corepack enable + corepack pnpm install --frozen-lockfile --ignore-scripts + - name: "FE-GATE-001 / manifest-lockfile" + if: ${{ !cancelled() }} + run: corepack pnpm ci:gate -- FE-GATE-001 + - name: "FE-GATE-002 / lint" + if: ${{ !cancelled() }} + run: corepack pnpm ci:gate -- FE-GATE-002 + - name: "FE-GATE-003 / typecheck" + if: ${{ !cancelled() }} + run: corepack pnpm ci:gate -- FE-GATE-003 + - name: "FE-GATE-010 / architecture" + if: ${{ !cancelled() }} + run: corepack pnpm ci:gate -- FE-GATE-010 + - name: "FE-GATE-011 / build" + if: ${{ !cancelled() }} + run: corepack pnpm ci:gate -- FE-GATE-011 + - name: "FE-GATE-012 / bundle" + if: ${{ !cancelled() }} + run: corepack pnpm ci:gate -- FE-GATE-012 + - name: Upload merge static evidence + if: always() + uses: https://github.com/ChristopherHX/gitea-upload-artifact@81f940d004763f986ba3582c007fd842dd5cb0d7 + with: + name: "merge-static-${{ gitea.run_id }}" + path: artifacts/ + if-no-files-found: error + + merge_test: + name: "merge / tests" if: ${{ gitea.event_name != 'workflow_dispatch' || inputs.stage != 'documentation' }} # FE-GATE-013 runner requirement: Linux with executable /usr/bin/bwrap (with --size), /usr/bin/prlimit, /usr/bin/systemd-run, /usr/bin/systemctl and /usr/bin/tar, an active systemd user manager 254 or newer, and unified cgroup v2 with delegated memory, pids and cpu controllers # 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 runs-on: ubuntu-latest timeout-minutes: 45 - strategy: - fail-fast: false - matrix: - include: - - { gate: FE-GATE-001, name: manifest-lockfile, browser: false } - - { gate: FE-GATE-002, name: lint, browser: false } - - { gate: FE-GATE-003, name: typecheck, browser: false } - - { gate: FE-GATE-004, name: runtime-schema, browser: false } - - { gate: FE-GATE-005, name: unit, browser: false } - - { gate: FE-GATE-006, name: component, browser: false } - - { gate: FE-GATE-007, name: integration, browser: false } - - { gate: FE-GATE-008, name: e2e, browser: true } - - { gate: FE-GATE-009, name: accessibility, browser: true } - - { gate: FE-GATE-010, name: architecture, browser: false } - - { gate: FE-GATE-011, name: build, browser: false } - - { gate: FE-GATE-012, name: bundle, browser: false } - - { gate: FE-GATE-013, name: security, browser: false } - - { gate: FE-GATE-020, name: removability, browser: false } + steps: + - uses: https://github.com/actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 + with: + persist-credentials: false + - uses: https://github.com/actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 + with: + node-version-file: .nvmrc + - name: Frozen install + run: | + corepack enable + corepack pnpm install --frozen-lockfile --ignore-scripts + - name: "FE-GATE-004 / runtime-schema" + if: ${{ !cancelled() }} + run: corepack pnpm ci:gate -- FE-GATE-004 + - name: "FE-GATE-005 / unit" + if: ${{ !cancelled() }} + run: corepack pnpm ci:gate -- FE-GATE-005 + - name: "FE-GATE-006 / component" + if: ${{ !cancelled() }} + run: corepack pnpm ci:gate -- FE-GATE-006 + - name: "FE-GATE-007 / integration" + if: ${{ !cancelled() }} + run: corepack pnpm ci:gate -- FE-GATE-007 + - name: "FE-GATE-013 / security" + if: ${{ !cancelled() }} + run: corepack pnpm ci:gate -- FE-GATE-013 + - name: "FE-GATE-020 / removability" + if: ${{ !cancelled() }} + run: corepack pnpm ci:gate -- FE-GATE-020 + - name: Upload merge test evidence + if: always() + uses: https://github.com/ChristopherHX/gitea-upload-artifact@81f940d004763f986ba3582c007fd842dd5cb0d7 + with: + name: "merge-test-${{ gitea.run_id }}" + path: artifacts/ + if-no-files-found: error + + merge_browser: + name: "merge / browser tests" + if: ${{ gitea.event_name != 'workflow_dispatch' || inputs.stage != 'documentation' }} + runs-on: ubuntu-latest + timeout-minutes: 45 steps: - uses: https://github.com/actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 with: @@ -68,23 +134,26 @@ jobs: corepack enable corepack pnpm install --frozen-lockfile --ignore-scripts - name: Install Playwright browsers - if: ${{ matrix.browser }} run: | corepack pnpm exec playwright install --with-deps chromium firefox webkit $(command -v sudo || true) apt-get install -y fonts-noto-core fonts-noto-cjk fonts-noto-cjk-extra fonts-liberation - - name: Run blocking gate - run: corepack pnpm ci:gate -- ${{ matrix.gate }} - - name: Upload merge gate evidence + - name: "FE-GATE-008 / e2e" + if: ${{ !cancelled() }} + run: corepack pnpm ci:gate -- FE-GATE-008 + - name: "FE-GATE-009 / accessibility" + if: ${{ !cancelled() }} + run: corepack pnpm ci:gate -- FE-GATE-009 + - name: Upload merge browser evidence if: always() uses: https://github.com/ChristopherHX/gitea-upload-artifact@81f940d004763f986ba3582c007fd842dd5cb0d7 with: - name: "${{ matrix.gate }}-${{ gitea.run_id }}" + name: "merge-browser-${{ gitea.run_id }}" path: artifacts/ if-no-files-found: error release_gate: name: "${{ matrix.gate }} / ${{ matrix.name }}" - needs: merge_gate + needs: [merge_static, merge_test, merge_browser] if: ${{ startsWith(gitea.ref, 'refs/tags/v') || (gitea.event_name == 'workflow_dispatch' && (inputs.stage == 'release' || inputs.stage == 'production' || inputs.stage == 'field')) }} runs-on: ubuntu-latest timeout-minutes: 45 diff --git a/config/ci/gates.json b/config/ci/gates.json index 5877462a..3875b209 100644 --- a/config/ci/gates.json +++ b/config/ci/gates.json @@ -2083,9 +2083,9 @@ ], "jobs": [ { - "id": "merge_gate", - "displayName": "${{ matrix.gate }} / ${{ matrix.name }}", - "kind": "gate-matrix", + "id": "merge_static", + "displayName": "merge / static checks", + "kind": "gate-sequence", "needs": [], "condition": "merge", "timeoutMinutes": 45, @@ -2093,18 +2093,88 @@ "FE-GATE-001", "FE-GATE-002", "FE-GATE-003", + "FE-GATE-010", + "FE-GATE-011", + "FE-GATE-012" + ], + "browserGateIds": [], + "environment": [], + "steps": [ + { + "kind": "checkout" + }, + { + "kind": "setup-node" + }, + { + "kind": "frozen-install" + }, + { + "kind": "run-gate" + }, + { + "kind": "upload", + "transferId": "merge-static-evidence", + "name": "merge-static-${{ gitea.run_id }}", + "paths": [ + "artifacts/" + ], + "always": true + } + ] + }, + { + "id": "merge_test", + "displayName": "merge / tests", + "kind": "gate-sequence", + "needs": [], + "condition": "merge", + "timeoutMinutes": 45, + "gateIds": [ "FE-GATE-004", "FE-GATE-005", "FE-GATE-006", "FE-GATE-007", - "FE-GATE-008", - "FE-GATE-009", - "FE-GATE-010", - "FE-GATE-011", - "FE-GATE-012", "FE-GATE-013", "FE-GATE-020" ], + "browserGateIds": [], + "environment": [], + "steps": [ + { + "kind": "checkout" + }, + { + "kind": "setup-node" + }, + { + "kind": "frozen-install" + }, + { + "kind": "run-gate" + }, + { + "kind": "upload", + "transferId": "merge-test-evidence", + "name": "merge-test-${{ gitea.run_id }}", + "paths": [ + "artifacts/" + ], + "always": true + } + ] + }, + { + "id": "merge_browser", + "displayName": "merge / browser tests", + "kind": "gate-sequence", + "needs": [], + "condition": "merge", + "timeoutMinutes": 45, + "gateIds": [ + "FE-GATE-008", + "FE-GATE-009" + ], "browserGateIds": [ "FE-GATE-008", "FE-GATE-009" @@ -2128,8 +2198,8 @@ }, { "kind": "upload", - "transferId": "merge-gate-evidence", - "name": "${{ matrix.gate }}-${{ gitea.run_id }}", + "transferId": "merge-browser-evidence", + "name": "merge-browser-${{ gitea.run_id }}", "paths": [ "artifacts/" ], @@ -2142,7 +2212,9 @@ "displayName": "${{ matrix.gate }} / ${{ matrix.name }}", "kind": "gate-matrix", "needs": [ - "merge_gate" + "merge_static", + "merge_test", + "merge_browser" ], "condition": "release", "timeoutMinutes": 45, diff --git a/docs/operations/ci-quality-gates.md b/docs/operations/ci-quality-gates.md index 1f6a349a..ff8a53d3 100644 --- a/docs/operations/ci-quality-gates.md +++ b/docs/operations/ci-quality-gates.md @@ -6,8 +6,10 @@ strict v2 contract; it is not an independent configuration authority. Update the registry, run `corepack pnpm generate:ci-workflow`, and commit the generated bytes together. `corepack pnpm check:ci-workflow` rejects missing, stale, CRLF, or otherwise byte-different output. `corepack pnpm check:ci` runs artifact-schema -checking, the typed contract checker, and this workflow drift check. The Gitea -adapter runs each gate as an independent matrix check with full fan-out and no +checking, the typed contract checker, and this workflow drift check. The merge +stage runs as three jobs (`merge_static`, `merge_test`, `merge_browser`), one +install each; every gate is a step named by its ID, and a failed gate does not +skip the next. Release and production gates stay matrix checks. There is no soft-fail wiring. ## 기준선 갱신과 새 프로젝트 시작 시 초기화할 기준선 @@ -407,9 +409,9 @@ the paired backend: `{ "id": "PRODUCT-GATE-001", "name": "backend-contract", "script": "check:backend-contract" }`. Ids are `PRODUCT-GATE-NNN`; the `FE-GATE-NNN` ids, their commands, artifacts and readiness formula stay the template's. Each runs as `corepack pnpm