From 9235ee66f6d889e6c27e4b85411448889dd7d37d Mon Sep 17 00:00:00 2001 From: Jesse_Chen Date: Sun, 9 Aug 2026 22:14:40 +0800 Subject: [PATCH] keep staging image build on turbopack --- .gitea/workflows/backend-quality-gate.yml | 2 +- docs/BUG_HISTORY.md | 16 ++++++++++++++++ frontend/package.json | 2 +- frontend/tests/staging-backend-workflows.test.ts | 4 ++-- 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/.gitea/workflows/backend-quality-gate.yml b/.gitea/workflows/backend-quality-gate.yml index 8db05156..517f4a70 100644 --- a/.gitea/workflows/backend-quality-gate.yml +++ b/.gitea/workflows/backend-quality-gate.yml @@ -217,7 +217,7 @@ jobs: npm test --prefix frontend npm run lint --prefix frontend if [ "$GITEA_EVENT_NAME" != "push" ]; then - if ! timeout 600 npm run build --prefix frontend; then + if ! timeout 600 npm run build --prefix frontend -- --webpack; then echo "frontend production build exceeded bounded 600-second timeout" >&2 exit 124 fi diff --git a/docs/BUG_HISTORY.md b/docs/BUG_HISTORY.md index 33bde5d6..04254e53 100644 --- a/docs/BUG_HISTORY.md +++ b/docs/BUG_HISTORY.md @@ -2552,3 +2552,19 @@ - 相关记录:BUG-129、BUG-136、BUG-142 - 复发自:无 - 修复版本:待本次提交 / gate / deploy + +## BUG-150 | staging publish 的 Webpack 镜像构建耗尽共享 Gitea 资源 + +- 状态:resolved(local candidate,远端 gate/deploy 待本提交) +- 首次发现:2026-08-09 +- 最近更新:2026-08-09 +- 影响面:Gitea staging quality gate 的 publish 镜像构建、共享 Gitea/runner 可用性;production 未涉及。 +- 用户现象:Run 1634 的 validate 在约 12 分钟内成功,publish 随后在 Docker 内执行 `next build --webpack` 超过 25 分钟;期间 Gitea API 持续返回 502 和空 JSON,最终 job 中断。 +- 触发条件:`frontend/package.json` 将默认 `build` 改为 Webpack 后,Dockerfile 的 `RUN npm run build` 也继承该构建器;classic Docker builder 的慢 COPY 与资源受限 runner 进一步放大构建开销。 +- 根因:为非 push 校验引入的 Webpack 兼容参数错误地放进了全局 package script,使实际镜像发布也从已成功的 Turbopack 路径切换到高开销 Webpack;Gitea 与 runner 共享资源时因此拖垮控制面。直接重跑旧 revision 会重复相同故障。 +- 修复:恢复默认 `npm run build` 为 `next build`,让 Docker publish 继续使用 Turbopack;仅在 PR/manual 的非 push validate 分支显式追加 `-- --webpack`。staging push 继续跳过重复 production build,由 publish 镜像构建唯一验证。 +- 验证:聚焦 workflow contract 锁定默认 Turbopack、非 push Webpack 与 staging push 单次镜像构建语义;本地测试和 `git diff --check` 通过。远端 gate、publish、deploy 与 exact-SHA smoke 待本提交后验证。 +- 防复发:不得把只用于隔离 worktree/非 push 校验的构建器参数写回全局 package script;发布构建器变化必须由 workflow contract 同时覆盖 Dockerfile 与事件分支。 +- 相关记录:BUG-142、BUG-149 +- 复发自:无 +- 修复版本:待本次提交 / gate / deploy diff --git a/frontend/package.json b/frontend/package.json index ea86ef35..487af014 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -5,7 +5,7 @@ "type": "module", "scripts": { "dev": "next dev", - "build": "next build --webpack", + "build": "next build", "start": "next start", "test": "tsx --test tests/*.test.ts", "test:db": "tsx --test --test-concurrency=1 tests/database-*.test.ts", diff --git a/frontend/tests/staging-backend-workflows.test.ts b/frontend/tests/staging-backend-workflows.test.ts index 11a1c895..db665f16 100644 --- a/frontend/tests/staging-backend-workflows.test.ts +++ b/frontend/tests/staging-backend-workflows.test.ts @@ -132,7 +132,7 @@ test("railway web image uses Next standalone runtime output", () => { const config = read(nextConfig); const packageJson = JSON.parse(read(frontendPackage)) as { scripts?: { build?: string } }; - assert.equal(packageJson.scripts?.build, "next build --webpack"); + assert.equal(packageJson.scripts?.build, "next build"); assert.match(config, /output: "standalone"/); assert.match(config, /outputFileTracingRoot: repositoryRoot/); assert.match(dockerfile, /RUN npm run build\n/); @@ -281,7 +281,7 @@ test("Gitea quality gate validates before publishing an immutable ACR manifest", assert.equal((workflow.match(/npm run build --prefix frontend/g) ?? []).length, 1); assert.match(workflow, /GITEA_EVENT_NAME: \$\{\{ gitea\.event_name \}\}/); assert.match(workflow, /if \[ "\$GITEA_EVENT_NAME" != "push" \]; then/); - assert.match(workflow, /timeout 600 npm run build --prefix frontend/); + assert.match(workflow, /timeout 600 npm run build --prefix frontend -- --webpack/); assert.match(workflow, /frontend production build exceeded bounded 600-second timeout/); assert.match(workflow, /staging push production build is verified once by the publish image build/); assert.match(workflow, /needs: validate/);