fix(deploy): prevent Next.js chunk version skew
Independent Staging Quality Gate / validate (push) Successful in 13m28s
Independent Staging Quality Gate / publish (push) Successful in 10m14s

This commit is contained in:
Jesse_Chen
2026-08-16 09:09:27 +08:00
parent 7b620c7a2e
commit 8ddcef4cf1
6 changed files with 42 additions and 2 deletions
@@ -169,6 +169,11 @@ test("railway web image uses Next standalone runtime output", () => {
assert.match(config, /outputFileTracingRoot: repositoryRoot/);
assert.match(startupGuard, /process\.env\.NEXT_RUNTIME !== "nodejs"/);
assert.match(startupGuard, /verifyAllActiveSkillPackages\(\)/);
assert.match(dockerfile, /ARG NEXT_DEPLOYMENT_ID\n/);
assert.match(
dockerfile,
/ENV NEXT_DEPLOYMENT_ID=\$\{NEXT_DEPLOYMENT_ID\}[\s\S]*RUN npm run build/,
);
assert.match(dockerfile, /RUN npm run build\n/);
assert.doesNotMatch(dockerfile, /npm prune --omit=dev/);
assert.match(dockerfile, /COPY --from=build \/app\/frontend\/\.next\/standalone \/app/);
@@ -202,6 +207,10 @@ test("quality gate validates relevant changes once and publishes a digest manife
assert.doesNotMatch(workflow, /npm run test:db --prefix frontend/);
assert.match(workflow, /id: api_build[\s\S]*steps\.api_build\.outputs\.digest/);
assert.match(workflow, /id: web_build[\s\S]*steps\.web_build\.outputs\.digest/);
assert.match(
workflow,
/id: web_build[\s\S]*build-args: \|[\s\S]*NEXT_DEPLOYMENT_ID=\$\{\{ github\.sha \}\}/,
);
assert.match(workflow, /\^sha256:\[0-9a-f\]\{64\}\$/);
assert.match(workflow, /node frontend\/scripts\/staging-image-manifest\.mjs/);
assert.match(workflow, /name: staging-image-manifest-\$\{\{ github\.sha \}\}/);
@@ -219,6 +228,10 @@ test("Gitea quality gate validates before publishing an immutable ACR manifest",
assert.equal((workflow.match(/runs-on: manman-linux/g) ?? []).length, 2);
assert.match(workflow, /validate:[\s\S]*?timeout-minutes: 45[\s\S]*?publish:[\s\S]*?timeout-minutes: 60/);
assert.match(workflow, /GITEA_SHA: \$\{\{ gitea\.sha \}\}/);
assert.match(
workflow,
/docker build --build-arg NEXT_DEPLOYMENT_ID="\$GITEA_SHA" -f deploy\/railway-web\.Dockerfile/,
);
assert.equal((workflow.match(/git clean -ffdx/g) ?? []).length, 2);
assert.equal((workflow.match(/git status --porcelain --untracked-files=all/g) ?? []).length, 2);
assert.equal((workflow.match(/for attempt in 1 2 3/g) ?? []).length, 5);