// PEP-230: the platform image is built from a git archive (no .git), so the web build must take // its commit from the PEPPA_COMMIT build-arg — otherwise /api/health reports `commit: null` and // scripts/platform-deploy.sh rolls every deploy back. import assert from "node:assert/strict"; import { readFileSync } from "node:fs"; import { describe, test } from "node:test"; const read = (p: string) => readFileSync(new URL(`../../../${p}`, import.meta.url), "utf8"); describe("PEP-230: образ платформы знает свой коммит", () => { test("Сценарий: сборка без .git — коммит приходит в next build из build-arg", () => { const dockerfile = read("infra/platform/Dockerfile"); const build = dockerfile.slice(0, dockerfile.lastIndexOf("\nFROM ")); const env = build.indexOf("ENV PEPPA_COMMIT=${PEPPA_COMMIT}"); assert.ok(build.includes("ARG PEPPA_COMMIT"), "build stage must declare ARG PEPPA_COMMIT"); assert.ok(env > 0 && env < build.indexOf("next build"), "PEPPA_COMMIT must be set before `next build`"); }); test("Сценарий: git недоступен — NEXT_PUBLIC_PEPPA_COMMIT берётся из PEPPA_COMMIT", () => { const config = read("apps/web/next.config.ts"); assert.match(config, /NEXT_PUBLIC_PEPPA_COMMIT: git\([^)]*\) \|\| buildCommit/); assert.match(config, /NEXT_PUBLIC_PEPPA_COMMIT_FULL: git\([^)]*\) \|\| buildCommit/); assert.match(config, /process\.env\.PEPPA_COMMIT/); }); });