Files
clean-architecture-frontend…/tests/unit/tracked-artifacts.test.ts
T
DongHyeonka 85f941c44c chore(artifacts): 읽는 곳 없는 산출물 13개를 지우고 폴더째 무시한다
문제: .gitignore가 artifacts/를 확장자별로만 무시한다(*.json, *.xml,
*.txt, *.sarif, *.log). 규칙에 없는 확장자가 새어 들어와 화면 캡처 3개
(artifacts/local-preview/*.png)와 커버리지 보고서 10개
(artifacts/tests/coverage-gateway/)가 추적된다. 읽는 코드·게이트·문서는
없다(git grep 'local-preview', 'coverage-gateway' 0건, 리뷰 기록 제외).
0929/14-01이 찾았고 2026-11-06 리뷰까지 '일부'로 남았다.

고른 방법:
- 13개를 지운다.
- artifacts/를 폴더째 무시하고 .gitkeep 2개와 수동 a11y 기록
  (artifacts/tests/a11y-manual/*.md)만 다시 넣는다. git은 무시한 폴더
  아래 파일을 다시 넣지 못해서, 지나가는 폴더마다 다시 넣고 그 내용을
  다시 무시한다. 확장자·폴더별 옛 규칙은 모두 이 안에 들어가 지웠다.
- tests/unit/tracked-artifacts.test.ts가 git ls-files artifacts를 허용
  목록과 대조한다. git add -f로 넣은 파일도 잡는다.
버린 대안:
- artifacts/** 와 !artifacts/**/ 꼴: git에서는 같게 되지만
  verify:documentation이 .gitignore를 읽는 방식
  (scripts/verify-documentation-readiness.ts generated())이
  !artifacts/**/ 를 "artifacts 아래 전부 다시 넣음"으로 읽는다. 그러면
  문서가 이름 부르는 생성 산출물(artifacts/quality/... 등)이 없는 경로로
  실패한다(코드 읽기로 확인).
- 확장자 규칙에 *.png, *.html, *.info를 더하기: 다음 새 확장자에서 같은
  일이 난다.

위험·한계: a11y 기록 말고 사람이 쓴 파일을 artifacts/에 두면 이제
무시된다. 지금 추적 파일 12개는 모두 허용 목록 안이다. 다운스트림은 지운
13개를 고치지 않았으면 병합이 그대로 지운다.

검증(desktop, 네 커밋의 끝 30a379f에서 한 번. 커밋마다 따로 돌리지는
않았다. 로그 ~/l1-layout-cleanup-logs/):
- tracked-artifacts.test.ts: 지금 트리 통과. 지운 png 3개를 index에
  되돌리면 실패하고 그 3개를 낸다. 허용 목록 밖 note.txt를 git add -f
  하면 실패하고 그 파일을 낸다.
- 새 .gitignore를 빈 저장소에 두고 산출물 15개를 만든 뒤 git add -A:
  .gitkeep 2개와 a11y .md 1개만 추적된다(노트북).
- git ls-files artifacts: 12개(.gitkeep 2, a11y-manual/*.md 10).
- corepack pnpm test:unit: 212 files, 3091 tests 통과.
  verify:documentation: PASS_SCOPED. check:architecture, check:types,
  lint, check:ci, check:adapter-inventory: exit 0.

Refs: design-docs repo-structure/04-frontend-layout.md 9.2절 1단계
2026-11-07 19:02:47 +09:00

36 lines
1.2 KiB
TypeScript

import { spawnSync } from "node:child_process";
import { describe, expect, it } from "vitest";
/**
* 0929/14-01. `artifacts/` is run output, but screenshots and a coverage
* report were committed there and stayed tracked with nothing reading them.
* `.gitignore` ignores the folder as a whole and re-includes only what people
* write or keep: the folder markers and the manual a11y reviews, which the
* a11y gates read (`config/ci/gates.json`). A file `git add -f` puts outside
* that list fails here.
*/
const ALLOWED = [
/^artifacts\/runbooks\/\.gitkeep$/u,
/^artifacts\/tests\/\.gitkeep$/u,
/^artifacts\/tests\/a11y-manual\/[^/]+\.md$/u,
];
function trackedArtifacts(): string[] {
const listed = spawnSync("git", ["ls-files", "-z", "--", "artifacts"], {
encoding: "utf8",
});
if (listed.error || listed.status !== 0) {
throw new Error(`git ls-files failed: ${listed.error?.message ?? listed.stderr}`);
}
return listed.stdout.split("\0").filter((file) => file !== "");
}
describe("tracked artifacts", () => {
it("are only the folder markers and the manual a11y reviews", () => {
expect(
trackedArtifacts().filter((file) => !ALLOWED.some((pattern) => pattern.test(file))),
).toEqual([]);
});
});