This reverts commit411c9338c6. 문제: #55(b4895894)가 main run 376의 FE-GATE-030(browser file/storage 제거 드릴)을 깨서 411c9338(#64)로 통째로 되돌렸다. #55의 검사기 진단과 시험 빈틈 고침 12커밋이 main에 없다. 고른 방법: 되돌림을 되돌려 #55를 그대로 다시 넣고, 드릴을 깬 원인은 다음 커밋에서 따로 고친다. 리뷰어가 이 커밋이 #55와 같은지 트리로 볼 수 있다. 이 커밋의 트리는b4895894트리에 그 뒤 main에 들어온 #63·#65만 더한 것이다(git diffb4895894<이 커밋>: docs/ledger 두 파일, cross-context-invalidation adapter 한 파일과 시험 두 파일). 버린 대안: #55 커밋 12개 cherry-pick.71606ff1merge의 충돌 해소분을 다시 풀어야 하고 결과 트리를 b4895894와 대조하기 어렵다. 위험·한계: 이 커밋만으로는 main 단계의 FE-GATE-030이 run 376처럼 실패한다(같은 트리 내용). PR 단계 게이트는 돈다. 검증: 다음 커밋 본문에 적는다. 그 커밋의 새 단언을 이 커밋의 검사기에 돌리면 실패한다(RED). Refs: #55, #64
91 lines
3.2 KiB
TypeScript
91 lines
3.2 KiB
TypeScript
import { spawnSync } from "node:child_process";
|
|
import { mkdir, readFile, readdir } from "node:fs/promises";
|
|
import path from "node:path";
|
|
|
|
import { reproducibleBuildArtifactSchema } from "./contracts/release-artifacts.ts";
|
|
import { assertCiBuildEnvironment } from "./lib/build-environment.ts";
|
|
import { checkoutBuildReadFailure } from "./lib/run-isolation.ts";
|
|
import { supplyChainDigest } from "./lib/supply-chain.ts";
|
|
import { writeValidatedJsonArtifact } from "./lib/validated-json-artifact.ts";
|
|
|
|
assertCiBuildEnvironment(process.env);
|
|
// 1106/12-02. This builds twice and digests dist where the checkout keeps it. Under RUN_OUTPUT_ROOT the build wrote elsewhere, so
|
|
// this would judge the earlier build the checkout still holds.
|
|
const outputRootFailure = checkoutBuildReadFailure("scripts/verify-reproducible-build.ts");
|
|
if (outputRootFailure !== undefined) {
|
|
process.stderr.write(`${outputRootFailure}\n`);
|
|
process.exit(1);
|
|
}
|
|
|
|
async function filesWithin(directory: string): Promise<string[]> {
|
|
const entries = await readdir(directory, { withFileTypes: true });
|
|
const nested: string[][] = await Promise.all(
|
|
entries.map((entry) => {
|
|
const target = path.join(directory, entry.name);
|
|
return entry.isDirectory() ? filesWithin(target) : [target];
|
|
}),
|
|
);
|
|
return nested.flat().sort();
|
|
}
|
|
|
|
async function distDigest(): Promise<string> {
|
|
const rows = await Promise.all(
|
|
(await filesWithin("dist")).map(async (file) => ({
|
|
path: path.relative("dist", file).replaceAll("\\", "/"),
|
|
bytes: (await readFile(file)).byteLength,
|
|
content: supplyChainDigest(await readFile(file)),
|
|
})),
|
|
);
|
|
return supplyChainDigest(rows);
|
|
}
|
|
|
|
function build(environment: NodeJS.ProcessEnv = process.env) {
|
|
return spawnSync("corepack", ["pnpm", "build"], {
|
|
env: environment,
|
|
encoding: "utf8",
|
|
maxBuffer: 16 * 1024 * 1024,
|
|
});
|
|
}
|
|
|
|
const deterministicEnvironment = {
|
|
...process.env,
|
|
SOURCE_DATE_EPOCH: "946684800",
|
|
};
|
|
const firstBuild = build(deterministicEnvironment);
|
|
const firstDigest = firstBuild.status === 0 ? await distDigest() : "BUILD_FAILED";
|
|
const secondBuild = build(deterministicEnvironment);
|
|
const secondDigest =
|
|
secondBuild.status === 0 ? await distDigest() : "BUILD_FAILED";
|
|
const restoreBuild = build();
|
|
const passed =
|
|
firstBuild.status === 0 &&
|
|
secondBuild.status === 0 &&
|
|
restoreBuild.status === 0 &&
|
|
firstDigest === secondDigest;
|
|
|
|
await mkdir("artifacts/release", { recursive: true });
|
|
await writeValidatedJsonArtifact({
|
|
path: "artifacts/release/reproducible-build.json",
|
|
schema: reproducibleBuildArtifactSchema,
|
|
value: {
|
|
schemaVersion: 1,
|
|
sourceDateEpoch: deterministicEnvironment.SOURCE_DATE_EPOCH,
|
|
buildId: process.env.VITE_BUILD_ID ?? "local-build",
|
|
commitSha: process.env.VITE_COMMIT_SHA ?? "local",
|
|
releaseId: process.env.RELEASE_ID ?? "local-release",
|
|
runnerImage:
|
|
process.env.CI_RUNNER_IMAGE ?? `${process.platform}-${process.arch}`,
|
|
firstDigest,
|
|
secondDigest,
|
|
restored: restoreBuild.status === 0,
|
|
status: passed ? "PASS" : "FAIL",
|
|
},
|
|
});
|
|
if (!passed) {
|
|
process.stderr.write(
|
|
`Reproducible build failed: first=${firstDigest} second=${secondDigest}\n`,
|
|
);
|
|
process.exit(1);
|
|
}
|
|
process.stdout.write(`Reproducible build: PASS (${firstDigest})\n`);
|