From 672da3f0796f4e8c192b680c6515be149d387ed8 Mon Sep 17 00:00:00 2001 From: Devin Foley Date: Thu, 10 Sep 2026 18:45:43 -0700 Subject: [PATCH] test: guard production metadata cache ordering Co-Authored-By: Paperclip --- .../src/__tests__/docker-build-stamp.test.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/server/src/__tests__/docker-build-stamp.test.ts b/server/src/__tests__/docker-build-stamp.test.ts index f013d30ec6..454b8b912e 100644 --- a/server/src/__tests__/docker-build-stamp.test.ts +++ b/server/src/__tests__/docker-build-stamp.test.ts @@ -35,6 +35,25 @@ function stageBody(source: string, stageName: string): string { return source.slice(start, end); } +it("keeps per-build runtime metadata out of the weekly CLI-install cache", () => { + const production = stageBody(dockerfile, "production"); + const tools = production.search(/^RUN echo "cli-tools-epoch:/m); + const entrypoint = production.search(/^RUN chmod \+x \/usr\/local\/bin\/docker-entrypoint\.sh/m); + const runtime = production.search(/^ENV NODE_ENV=production/m); + const epoch = production.search(/^ARG CLI_TOOLS_CACHE_EPOCH\b/m); + expect(tools).toBeGreaterThanOrEqual(0); + expect(entrypoint).toBeGreaterThan(tools); + expect(epoch).toBeGreaterThanOrEqual(0); + expect(epoch).toBeLessThan(tools); + for (const name of ["PAPERCLIP_BUILD_VERSION", "PAPERCLIP_BUILD_COMMIT"]) { + const declarations = [...production.matchAll(new RegExp(`^ARG ${name}\\b`, "gm"))]; + expect(declarations).toHaveLength(1); + expect(declarations[0].index).toBeGreaterThan(entrypoint); + expect(declarations[0].index).toBeLessThan(runtime); + expect(production.slice(runtime)).toContain(`${name}=\${${name}}`); + } +}); + describe("docker build-stamp wiring", () => { it("declares PAPERCLIP_BUILD_COMMIT in the build stage before the server build", () => { const build = stageBody(dockerfile, "build");