Files
clean-architecture-frontend…/scripts/ci/dependency-cache-root.sh
DongHyeonka d254d70a64 ci(gates): 접근성 시험은 FE-GATE-009에서만 돌고 main job도 의존성 캐시를 쓴다
문제:
- FE-GATE-008의 `test:e2e`(`playwright test`)는 `tests/e2e/` 전부를 돈다.
  이름에 `@a11y`가 붙은 시험 33개(세 엔진 각 11)도 거기 든다. FE-GATE-009의
  `test:a11y`가 같은 33개를 다시 돌아, merge browser job이 같은 시험을 두
  번 돈다(009 runner 0:27~0:28).
- main job(`main_gate`, FE-GATE-029·030)만 의존성 캐시가 없다. setup-node와
  frozen install이 0:15~0:24다(merge job은 1~2초).

고른 방법:
- `test:e2e`를 `playwright test --grep-invert @a11y`로 바꾼다. `@a11y` 시험은
  009의 자기 실행만 돈다. 두 실행은 같은 `playwright.config.ts`를 쓰므로
  project도 같다(chromium·firefox·webkit, chromium-compact는
  `compact-smoke.spec.ts`만 돌고 `@a11y` 시험이 없다). 증거 검사
  (`check-test-evidence.ts`)는 e2e 시험 수를 보지 않아 옮길 단언이 없다.
- 시험 둘이 이 짝을 지킨다. 두 script의 playwright 실행이 같은 태그를
  반대로 거르는지, 008·009가 그 명령을 갖고 같은 job에 있는지 본다. PR
  경로표에서 008을 고르는 규칙은 009도 고르는지도 본다. 하나가 풀리면
  `@a11y` 시험이 어느 게이트에서도 안 돌 수 있다.
- `main_gate`에 `dependency-cache` 단계를 더한다.
  - `scripts/contracts/ci-gates.ts`의 `DEPENDENCY_CACHE.jobIds`에 main_gate를
    넣고, `expectedStepKinds.main_gate`와 진단 문구도 맞춘다.
  - 키(`.nvmrc`·lockfile 해시)·경로·main run만 저장·`--frozen-lockfile`은
    merge job과 같다.
  - 캐시가 없어야 할 job을 보는 시험에 production·field·documentation job을
    더한다.
  - main job 거절 사례는 documentation job 거절로 바꾼다. 이름에 없는
    gate-sequence job은 거절하는지 새 시험으로 본다.
  - main job이 캐시를 빼면 drift가 나는지도 본다.
  - workflow의 action 수는 49에서 51이다.
- `docs/work/reference/decisions.md`에 FE-6·FE-7 행을 더한다.
  - 옛 결정 R9-D11(2026-11-12)과 「의존성 캐시는 merge job만」(2026-11-13)에는
    바꾼 행을 가리키는 표시만 단다.
  - 운영 문서의 캐시 문장, 시험 층 표, 생성 기능 매뉴얼, fe-qa 스킬,
    verify-app 에이전트가 008이 무엇을 도는지 맞게 적는다.

버린 것:
- FE-GATE-009가 008 결과로 보고서를 만들기: 게이트 하나가 다른 게이트
  산출물에 기댄다. 008이 실패하면 009도 판정을 못 낸다(R9-D11이 버린 안).
- 생성 기능 목록의 빈·오류 상태 화면 단언을 `@a11y` 밖 시험으로 떼어 008에
  남기기: 이번 범위는 `tests/e2e/`의 시험 내용을 바꾸지 않는다. 그 상태는
  009가 세 엔진에서 돈다.

위험·한계:
- FE-GATE-008만 돌리면 `@a11y` 시험(axe 스캔, 생성 기능 목록의 빈·오류
  상태 화면)은 돌지 않는다. 제품이 e2e spec에 `@a11y`를 붙이면 그 시험도
  009에서만 돈다.
- main job은 main push에서만 돈다. 캐시 복원·저장이 실제 runner에서 맞는지는
  병합 뒤 첫 main run에서야 본다.
- 같은 키를 여러 job이 저장하려 할 때:
  - runner가 1대라 job이 차례로 돈다. 정확히 맞춘 뒤 job은 저장하지 않는다.
    main run 141·143·146의 merge job 셋이 모두 「Cache hit occurred on the
    primary key …, not saving cache」를 남겼다.
  - 동시에 저장하면 actions/cache 4.3.0은 저장 실패를 경고로만 남기고 job을
    계속한다(`src/saveImpl.ts`).

검증(desktop `scripts/verify.sh`):
- Playwright 목록 대조(`--list`): 전체 214 가운데 `@a11y` 33(세 엔진 각
  11)이 `--grep @a11y` 목록과 같고, `--grep-invert @a11y` 목록은 나머지
  181과 같다.
- FE-GATE-008 rc=0(첫 Playwright 실행 181시험, 기준 main은 214),
  FE-GATE-009 rc=0(33시험).
- `@a11y` 시험 하나에 실패 단언을 넣은 트리: 008 rc=0, 009 rc=1(세 엔진 각
  1 실패).
- 새 시험의 변이 셋이 각자 rc=1: `test:e2e`를 `playwright test`로 되돌림,
  application 규칙에서 009를 뺌, `DEPENDENCY_CACHE.jobIds` 검사를 끔.
- `tests/unit/ci-workflow-generation.test.ts`·`tests/unit/pr-gate-selection.test.ts`
  463 통과. FE-GATE-010 rc=0, FE-GATE-029·030 rc=0.
- 리뷰: 새 눈 1회(fe-testing·desktop-gates 렌즈, Medium 1·Low 3) 반영,
  확인 1회 발견 0.
- merge 단계 게이트는 PR 본문에 적는다.

Refs: fe-ci-next (4), FE-6, FE-7
2026-11-20 15:33:03 +09:00

44 lines
2.0 KiB
Bash
Executable File

#!/usr/bin/env bash
# Chooses where a job keeps its dependency cache (scripts/contracts/ci-gates.ts DEPENDENCY_CACHE): the first
# candidate folder on the checkout's filesystem, so pnpm hardlinks node_modules from the restored store. A store on
# another filesystem is copied file by file, and a warm install took longer than a cold one (desktop: 2.1 s on the
# same filesystem, 58.8 s across filesystems, 2026-11-13). A folder inside the checkout is never chosen: a cache
# there would show in `git status`, the repository layout checks and the uploaded artifacts.
#
# scripts/ci/dependency-cache-root.sh <candidate folder>...
#
# Writes COREPACK_HOME, PNPM_CONFIG_STORE_DIR and PNPM_CONFIG_CACHE_DIR to $GITHUB_ENV and root=<folder> to
# $GITHUB_OUTPUT, and logs one line: the folder, whether it shares the checkout's filesystem, each candidate's
# device and the load average at the job's start (the runner shares the desktop with other work). With no
# candidate on that filesystem it takes the first usable candidate, and the install still runs.
set -euo pipefail
workspace=$(cd "${GITHUB_WORKSPACE:?}" && pwd -P)
checkout=$(stat -c %d "$workspace")
chosen=""
fallback=""
devices=""
for candidate in "$@"; do
[ -n "$candidate" ] && [ -d "$candidate" ] && [ -w "$candidate" ] || continue
real=$(cd "$candidate" && pwd -P)
case "$real/" in "$workspace/"*) continue ;; esac
device=$(stat -c %d "$real")
devices="$devices $real=$device"
[ -n "$fallback" ] || fallback=$real
if [ -z "$chosen" ] && [ "$device" = "$checkout" ]; then chosen=$real; fi
done
same=yes
if [ -z "$chosen" ]; then
same=no
chosen=${fallback:-/tmp}
fi
root="${chosen%/}/fe-dependency-cache"
echo "dependency cache: $root (on the checkout's filesystem: $same; devices: checkout=$checkout$devices; load average at job start: $(cut -d' ' -f1-3 /proc/loadavg))"
{
echo "COREPACK_HOME=$root/corepack"
echo "PNPM_CONFIG_STORE_DIR=$root/pnpm-store"
echo "PNPM_CONFIG_CACHE_DIR=$root/pnpm-cache"
} >> "${GITHUB_ENV:?}"
echo "root=$root" >> "${GITHUB_OUTPUT:?}"