문제: merge / browser tests job이 매 실행마다 apt-get update와 약 220MB의 Noto/Liberation 글꼴 패키지를 인터넷 미러에서 다시 받아 약 31초(최대 71초)를 쓴다. 고른 방법과 버린 대안: - scripts/lib/visual-test-fonts.ts에 이미지 sha256 digest 앞 12자와 VISUAL_TEST_FONT_PACKAGES 해시로 정확한 캐시 키를 만드는 helper를 둔다. restore-keys 없이 정확한 키만 쓴다. - scripts/generate-ci-workflow.ts가 merge_browser의 browser-install(image) 앞에 main 전용 actions/cache 저장·복원 step과 비-main 전용 actions/cache/restore 복원 step을 두고(main-push-reuse 조건 포함), scripts/ci/install-visual-test-fonts.sh에 VISUAL_TEST_FONT_PACKAGES 목록을 그대로 넘긴다. - scripts/ci/install-visual-test-fonts.sh는 캐시 폴더에 .deb가 있으면 apt-get 없이 dpkg -i로 설치하고, 비어 있으면 --download-only로 내려받은 뒤 partial·lock을 지우고 dpkg -i로 설치한다. - 버린 대안: 커스텀 Playwright 이미지 레지스트리 등록(소유자 레지스트리 설정· 토큰 필요), /var/lib/apt/lists만 캐시(220MB 다운로드 남음), 글꼴 폴더 tar 캐시(dpkg 상태 불일치). 위험·한계: - main push reuse(CI-FE-0004)가 동작하는 main push에서는 글꼴 step이 건너뛰므로 캐시는 재사용이 아닌 main push 또는 workflow_dispatch(main)에서 최초 저장된다. - runner 캐시 저장소(5GB 상한)에 약 220MB가 더해진다. - release_gate의 non-imaged playwright install --with-deps 경로는 바꾸지 않았다. 검증: - C3 RED(트리 fcc122aa91a6): ci-browser-image.test.ts rc=1 (1 failed | 3 passed) - laptop-gate check:types, lint, verify:documentation, 단위 시험 5파일(535 passed) rc=0 - scripts/verify.sh docs rc=0, scripts/verify.sh hooks rc=0 (112 tests) Refs: CI-FE-0003
46 lines
1.8 KiB
TypeScript
46 lines
1.8 KiB
TypeScript
import { createHash } from "node:crypto";
|
|
|
|
/**
|
|
* 1103/11-02. The Debian/Ubuntu packages that hold the four faces the visual
|
|
* goldens were captured with. `tests/visual/fonts.conf` shows Chromium only
|
|
* their directories, Playwright's `--with-deps` does not install them, and
|
|
* `tests/visual/fonts.setup.ts` fails with this list when one is missing. The
|
|
* CI browser step (`scripts/generate-ci-workflow.ts`) installs the same list,
|
|
* so the hint and the runner cannot name different packages.
|
|
*/
|
|
export const VISUAL_TEST_FONT_PACKAGES = Object.freeze([
|
|
"fonts-noto-core",
|
|
"fonts-noto-cjk",
|
|
"fonts-noto-cjk-extra",
|
|
"fonts-liberation",
|
|
] as const);
|
|
|
|
export const VISUAL_TEST_FONT_INSTALL_ARGUMENTS = `apt-get install -y ${VISUAL_TEST_FONT_PACKAGES.join(" ")}`;
|
|
|
|
/**
|
|
* FE-3 (2) (CI-FE-0003). Caches the downloaded `.deb` archives for the visual
|
|
* goldens' font packages outside the checkout so cache hits install via
|
|
* `dpkg -i` without calling `apt-get update` or re-downloading ~220 MB.
|
|
*/
|
|
export const VISUAL_TEST_FONT_CACHE = Object.freeze({
|
|
keyPrefix: "fe-visual-fonts-",
|
|
directory: "${{ runner.temp }}/visual-test-fonts",
|
|
shellDirectory: '"$RUNNER_TEMP/visual-test-fonts"',
|
|
installScript: "scripts/ci/install-visual-test-fonts.sh",
|
|
});
|
|
|
|
const IMAGE_SHA256_PATTERN = /@sha256:([0-9a-f]{64})$/u;
|
|
|
|
export function visualTestFontCacheKey(
|
|
image: string,
|
|
packages: readonly string[] = VISUAL_TEST_FONT_PACKAGES,
|
|
): string {
|
|
const match = IMAGE_SHA256_PATTERN.exec(image);
|
|
if (!match) {
|
|
throw new TypeError(`visual-test font cache requires an image pinned by sha256 digest: ${image}`);
|
|
}
|
|
const imageDigestPrefix = match[1]!.slice(0, 12);
|
|
const packagesHash = createHash("sha256").update(packages.join("\n")).digest("hex").slice(0, 12);
|
|
return `${VISUAL_TEST_FONT_CACHE.keyPrefix}${imageDigestPrefix}-${packagesHash}`;
|
|
}
|