diff --git a/CHANGELOG.md b/CHANGELOG.md index 0ef66e0e..c2c8b862 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -250,6 +250,7 @@ Gitea runner에서 merge 단계를 초록으로 만들고, worker를 늘리지 | OPFS 다른 탭 시험 둘(purge·reconcile)이 고정 250 ms 대기 대신 Web Locks 대기열(`navigator.locks.query()`)에 B 탭의 요청 하나만 보일 때까지 기다린 뒤 A 탭의 put을 푼다(B를 시작하기 전에는 같은 잠금의 대기가 0이어야 한다). 전에는 B 탭이 250 ms 안에 대기 지점에 못 오면 put이 먼저 끝나 시험이 떨어졌다. preload 지연 시험이 지연한 chunk가 `modulepreload`였는지와 route가 그 요청을 실제로 늦췄는지 단언한다. 전에는 fixture build가 preload를 끄거나 route 경로가 어긋나도 지연 없는 방문으로 통과했다 (REV-FE-0017, REV-FE-0018) | `tests/browser-capabilities/opfs-runtime.spec.ts`, `tests/e2e/preload-use.spec.ts` | `af5b8e1f`, `73bad4c9`, `ffa48725` | | 지식 스킬 `fe-*` 아홉을 네 절(이 시스템 고유 불변식, 실패 패턴 & 적대적 체크 질문, 실행·검증 명령, 하지 않을 것)로 줄이고, 여러 스킬에 걸친 규칙은 정본 스킬 하나에만 둔다. `docs/work/experts.md` 3절 경로표와 스킬 `paths`가 1:1로 같고 시험이 대조한다. 서브에이전트의 도구·돌려주는 줄 수·Opus로 띄울 조건을 정한다. 노트북 감싸개 레인을 실행 위치 정본(`docs/work/operate.md` 4.1절)에 적는다 | `.claude/`, `docs/work/experts.md`, `docs/work/operate.md`, `scripts/tests/test_claude_setup.py` | `f3841080`, `51fba0ce` | | 서브에이전트 `reviewer`의 Bash를 머리 칸 PreToolUse 가드(`.claude/hooks/readonly_bash.py`)가 막는다. 본문에 적힌 `git diff`·`git log`·`git show`·`git grep`과 `python3 -I scripts/check-work-docs.py`만 통과하고, 그 밖의 명령·출력 돌리기·줄바꿈 뒤 명령은 rc 2다. `scripts/tests/test_agent_guard.py`가 머리 칸 인자로 본문 명령과 쓰는 명령을 대 본다. 위 "먼저 할 일" | `.claude/agents/reviewer.md`, `.claude/hooks/`, `.gitignore`, `scripts/hooks/README.md`, `scripts/tests/test_agent_guard.py`, `scripts/tests/test_claude_setup.py`, `docs/work/docs-writing.md` | `2d61bad0` | +| `playwright.config.ts`(`playwright.a11y.config.ts` 상속)와 `playwright.capabilities.config.ts`가 `CI=true`에서 보이는 CPU 수의 절반 기본값 대신 `scripts/lib/playwright-ci-workers.ts`의 숫자 상수(`CI_PLAYWRIGHT_WORKERS = 6`)를 쓰고, CI 밖에서는 `undefined`로 둔다. 유휴 러너 측정(PR #116 `run 740`, workers 2·3·4·6 각 3회)에서 20초 이상 단축되는 더 작은 값이 없어 6으로 고정한다 (CI-FE-0002) | `scripts/lib/playwright-ci-workers.ts`, `playwright.config.ts`, `playwright.capabilities.config.ts`, `tests/unit/playwright-ci-workers.test.ts`, `tests/unit/playwright-capabilities-run-isolation.test.ts`, `docs/operations/ci-quality-gates.md` | `77c2f453`, `427674d0` | ## 미출시 — `8327e221` → 하네스와 작업 매뉴얼 diff --git a/docs/operations/ci-quality-gates.md b/docs/operations/ci-quality-gates.md index b4f763da..61d71180 100644 --- a/docs/operations/ci-quality-gates.md +++ b/docs/operations/ci-quality-gates.md @@ -14,7 +14,10 @@ repo 훅·검사기·`.claude/` 지침 시험(`python3 -I -m unittest discover - 게이트가 실패해도 돌고, PR의 게이트 고르기와 상관없이 늘 돈다. `merge_browser` 컨테이너는 `/dev/shm`을 2 GB로 연다(`--shm-size=2g`). Firefox 시험 프로필을 RAM에 두기 위해서다 (`tests/support/browser/browser-test.ts`). Docker 기본값 64 MB면 프로필이 runner 디스크에 남아 -Firefox의 첫 localStorage 접근이 수 초씩 기다렸다. `merge_browser`의 visual 시험 글꼴 패키지 +Firefox의 첫 localStorage 접근이 수 초씩 기다렸다. `playwright.config.ts`(`playwright.a11y.config.ts` +상속)와 `playwright.capabilities.config.ts`는 CI에서 보이는 CPU 수의 절반 기본값 대신 +`scripts/lib/playwright-ci-workers.ts`가 정한 숫자 상수(`CI_PLAYWRIGHT_WORKERS`)로 +workers를 고정하고, CI 밖에서는 `undefined`로 둔다. `merge_browser`의 visual 시험 글꼴 패키지 (`scripts/lib/visual-test-fonts.ts`)는 `.deb` 파일을 `${{ runner.temp }}/visual-test-fonts`에 캐시해 설치한다(`scripts/ci/install-visual-test-fonts.sh`). 키는 이미지 digest 앞자리와 패키지 목록 해시로 정확히 맞추고 `restore-keys`는 두지 않는다. 의존성 캐시와 같이 `refs/heads/main`에서만 저장하고 diff --git a/playwright.capabilities.config.ts b/playwright.capabilities.config.ts index a9aa7718..e9058abf 100644 --- a/playwright.capabilities.config.ts +++ b/playwright.capabilities.config.ts @@ -1,6 +1,7 @@ import { defineConfig, devices } from "@playwright/test"; import { LOCAL_BUILD_IDENTITY } from "./scripts/lib/build-environment.ts"; +import { ciWorkers } from "./scripts/lib/playwright-ci-workers.ts"; import { flakyJudgement, flakyJudgementReporter } from "./scripts/lib/playwright-flaky-judgement.ts"; import { reservePort, @@ -20,6 +21,7 @@ const origin = `http://127.0.0.1:${port}`; export default defineConfig({ testDir: "./tests/browser-capabilities", forbidOnly: true, + ...ciWorkers(), ...flakyJudgement(), outputDir: testRunPath("artifacts/tests/browser-capabilities/results"), reporter: [ diff --git a/playwright.config.ts b/playwright.config.ts index 25cd014e..40b79734 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -1,5 +1,6 @@ import { defineConfig, devices } from "@playwright/test"; +import { ciWorkers } from "./scripts/lib/playwright-ci-workers.ts"; import { flakyJudgement, flakyJudgementReporter } from "./scripts/lib/playwright-flaky-judgement.ts"; import { reservePort, @@ -27,6 +28,7 @@ export default defineConfig({ // browser project (tests/e2e/support/shared-fixture-builds.ts). globalSetup: "./tests/e2e/support/e2e-global-setup.ts", forbidOnly: true, + ...ciWorkers(), ...flakyJudgement(), outputDir: testRunPath("artifacts/tests/e2e/results"), reporter: [ diff --git a/scripts/lib/playwright-ci-workers.ts b/scripts/lib/playwright-ci-workers.ts new file mode 100644 index 00000000..73b949e9 --- /dev/null +++ b/scripts/lib/playwright-ci-workers.ts @@ -0,0 +1,15 @@ +/** + * FE-3 (1) (CI-FE-0002). The runner's job container sees 12 CPUs under a 6-CPU + * quota, so Playwright's default (half of os.cpus()) gave 6 workers implicitly. + * Measured on the idle runner in PR #116 (run 740, 3x each, FE-GATE-008 p50): + * 2 -> 287 s, 3 -> 244 s, 4 -> 233 s, 6 -> 238 s. No lower count beat 6 by + * >= 20 s, so 6 is pinned explicitly as a constant rather than depending on + * visible host CPUs. Not a flakiness fix: .claude/rules/tests.md 6 still holds. + */ +export const CI_PLAYWRIGHT_WORKERS = 6; + +export function ciWorkers( + environment: NodeJS.ProcessEnv = process.env, +): Readonly<{ workers?: number }> { + return environment["CI"] === "true" ? Object.freeze({ workers: CI_PLAYWRIGHT_WORKERS }) : Object.freeze({}); +} diff --git a/tests/unit/playwright-capabilities-run-isolation.test.ts b/tests/unit/playwright-capabilities-run-isolation.test.ts index 98d4f3f4..90532f60 100644 --- a/tests/unit/playwright-capabilities-run-isolation.test.ts +++ b/tests/unit/playwright-capabilities-run-isolation.test.ts @@ -1,5 +1,6 @@ -import { afterEach, describe, expect, it } from "vitest"; +import { afterEach, describe, expect, it, vi } from "vitest"; +import { CI_PLAYWRIGHT_WORKERS } from "../../scripts/lib/playwright-ci-workers.ts"; import { configRuns, describeResultFolders, @@ -29,7 +30,10 @@ const runs = configRuns({ visual: () => import("../../playwright.visual.config.ts"), }); -afterEach(releaseRuns); +afterEach(async () => { + vi.unstubAllEnvs(); + await releaseRuns(); +}); describeResultFolders(runs, [["capabilities", "browser-capabilities"]]); @@ -49,3 +53,15 @@ describe("vite servers", () => { expect(portOf(await runs.load("capabilities"))).not.toBe(visual); }); }); + +describe("CI Playwright workers (CI-FE-0002)", () => { + it("sets numeric workers in CI and leaves it undefined outside CI", async () => { + vi.stubEnv("CI", "true"); + expect((await runs.load("capabilities")).workers).toBe(CI_PLAYWRIGHT_WORKERS); + + for (const value of [undefined, "", "false"] as const) { + vi.stubEnv("CI", value); + expect((await runs.load("capabilities")).workers).toBeUndefined(); + } + }); +}); diff --git a/tests/unit/playwright-ci-workers.test.ts b/tests/unit/playwright-ci-workers.test.ts new file mode 100644 index 00000000..5c177a07 --- /dev/null +++ b/tests/unit/playwright-ci-workers.test.ts @@ -0,0 +1,42 @@ +import { afterEach, describe, expect, it, vi } from "vitest"; + +import { CI_PLAYWRIGHT_WORKERS, ciWorkers } from "../../scripts/lib/playwright-ci-workers.ts"; +import { configRuns, releaseRuns } from "../helpers/playwright-run-isolation.ts"; + +/** + * CI-FE-0002. Pin numeric Playwright workers in CI for the e2e config (and the + * a11y config that spreads it). The capabilities config lives in + * tests/unit/playwright-capabilities-run-isolation.test.ts so browser-file-storage + * removal drops it by name (1106/10-01). + */ +const runs = configRuns({ + e2e: () => import("../../playwright.config.ts"), + a11y: () => import("../../playwright.a11y.config.ts"), +}); + +afterEach(async () => { + vi.unstubAllEnvs(); + await releaseRuns(); +}); + +describe("CI Playwright workers (CI-FE-0002)", () => { + it("returns the pinned numeric worker count only when CI=true", () => { + expect(ciWorkers({ CI: "true" })).toEqual({ workers: CI_PLAYWRIGHT_WORKERS }); + expect(ciWorkers({})).toEqual({}); + expect(ciWorkers({ CI: "" })).toEqual({}); + expect(ciWorkers({ CI: "false" })).toEqual({}); + }); + + it.each(["e2e", "a11y"] as const)( + "%s sets numeric workers in CI and leaves it undefined outside CI", + async (name) => { + vi.stubEnv("CI", "true"); + expect((await runs.load(name)).workers).toBe(CI_PLAYWRIGHT_WORKERS); + + for (const value of [undefined, "", "false"] as const) { + vi.stubEnv("CI", value); + expect((await runs.load(name)).workers).toBeUndefined(); + } + }, + ); +});