From 4f3f842958e7038d833f386862b47f8bba54065d Mon Sep 17 00:00:00 2001 From: Jesse_Chen Date: Sun, 9 Aug 2026 21:06:47 +0800 Subject: [PATCH] avoid duplicate staging production build --- .gitea/workflows/backend-quality-gate.yml | 11 ++++++++--- frontend/tests/staging-backend-workflows.test.ts | 5 ++++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/.gitea/workflows/backend-quality-gate.yml b/.gitea/workflows/backend-quality-gate.yml index 70180257..8db05156 100644 --- a/.gitea/workflows/backend-quality-gate.yml +++ b/.gitea/workflows/backend-quality-gate.yml @@ -33,6 +33,7 @@ jobs: timeout-minutes: 45 env: GITEA_SHA: ${{ gitea.sha }} + GITEA_EVENT_NAME: ${{ gitea.event_name }} NODE_TOOL_SOURCE_IMAGE: swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/library/node:22-bookworm-slim@sha256:ef343465b6a14bbdf2ab52f6e100ec0659a792464fcf72c462370d88b3df909c NODE_TOOL_IMAGE: node:22-bookworm-slim steps: @@ -215,9 +216,13 @@ jobs: python -m build npm test --prefix frontend npm run lint --prefix frontend - if ! timeout 600 npm run build --prefix frontend; then - echo "frontend production build exceeded bounded 600-second timeout" >&2 - exit 124 + if [ "$GITEA_EVENT_NAME" != "push" ]; then + if ! timeout 600 npm run build --prefix frontend; then + echo "frontend production build exceeded bounded 600-second timeout" >&2 + exit 124 + fi + else + echo "staging push production build is verified once by the publish image build" fi publish: diff --git a/frontend/tests/staging-backend-workflows.test.ts b/frontend/tests/staging-backend-workflows.test.ts index 3e67d438..11a1c895 100644 --- a/frontend/tests/staging-backend-workflows.test.ts +++ b/frontend/tests/staging-backend-workflows.test.ts @@ -232,7 +232,7 @@ test("Gitea quality gate validates before publishing an immutable ACR manifest", assert.match(workflow, /npm --version/); assert.match( workflow, - /validate:[\s\S]*?env:\n\s+GITEA_SHA: \$\{\{ gitea\.sha \}\}\n\s+NODE_TOOL_SOURCE_IMAGE: swr\.cn-north-4\.myhuaweicloud\.com\/ddn-k8s\/docker\.io\/library\/node:22-bookworm-slim@sha256:ef343465b6a14bbdf2ab52f6e100ec0659a792464fcf72c462370d88b3df909c\n\s+NODE_TOOL_IMAGE: node:22-bookworm-slim[\s\S]*?- name: Prepare pinned Node tooling/, + /validate:[\s\S]*?env:\n\s+GITEA_SHA: \$\{\{ gitea\.sha \}\}\n\s+GITEA_EVENT_NAME: \$\{\{ gitea\.event_name \}\}\n\s+NODE_TOOL_SOURCE_IMAGE: swr\.cn-north-4\.myhuaweicloud\.com\/ddn-k8s\/docker\.io\/library\/node:22-bookworm-slim@sha256:ef343465b6a14bbdf2ab52f6e100ec0659a792464fcf72c462370d88b3df909c\n\s+NODE_TOOL_IMAGE: node:22-bookworm-slim[\s\S]*?- name: Prepare pinned Node tooling/, ); const installStep = workflow.match( /- name: Install dependencies[\s\S]*?(?=\n\s+- name: Validate backend, package, frontend, and database contracts)/, @@ -279,8 +279,11 @@ test("Gitea quality gate validates before publishing an immutable ACR manifest", assert.equal((workflow.match(/npm test --prefix frontend/g) ?? []).length, 1); assert.equal((workflow.match(/npm run lint --prefix frontend/g) ?? []).length, 1); 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, /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/); assert.match(workflow, /IMAGE_REPOSITORY: crpi-[^\n]+\/copse\/jyotisha/); assert.match(workflow, /\$IMAGE_REPOSITORY:api-\$GITEA_SHA/);