From 01fcd50da8e5828e6546885a800eece566bdfa03 Mon Sep 17 00:00:00 2001 From: ci-bot Date: Sat, 29 Aug 2026 14:51:27 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix(ci):=20push=20=E8=B7=AF=E5=BE=84?= =?UTF-8?q?=E6=A3=80=E6=B5=8B=E6=94=B9=E7=94=A8=20compare=20=E5=93=8D?= =?UTF-8?q?=E5=BA=94=E5=86=85=E6=AF=8F=E6=8F=90=E4=BA=A4=20files=20?= =?UTF-8?q?=E8=81=9A=E5=90=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Gitea 1.26.4 compare API 顶层 files 字段始终为空且 merge_base=null, 导致 ci_push_paths.sh 永远走保守全量构建,路径过滤形同虚设。 改为聚合 compare 响应中 commits[].files(该字段完整可用), 覆盖 squash merge(单提交)与多提交 push 区间。 已在本地用三组真实区间验证:纯后端6文件、纯前端3文件、全栈11文件。 --- scripts/ci/ci_push_paths.sh | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/scripts/ci/ci_push_paths.sh b/scripts/ci/ci_push_paths.sh index 0c7dbdfc7..09e99cdf9 100755 --- a/scripts/ci/ci_push_paths.sh +++ b/scripts/ci/ci_push_paths.sh @@ -30,7 +30,8 @@ echo "改动范围检测: before=${before:-} after=${after}" FILES="" if [ -n "$before" ] && [ "$before" != "0000000000000000000000000000000000000000" ]; then - # compare API: {base}...{head} + # Gitea 1.26.x compare API 的顶层 files 字段不填充(始终为空), + # 但响应里每个 commit 条目自带的 files 完整可用;聚合区间内所有提交的 files 即可。 API_URL="${base}/repos/${repo}/compare/${before}...${after}?per_page=300" for attempt in 1 2 3; do FILES=$(curl -s --max-time 30 -H "Authorization: token ${GITHUB_TOKEN}" "$API_URL" \ @@ -38,8 +39,13 @@ if [ -n "$before" ] && [ "$before" != "0000000000000000000000000000000000000000" import json,sys try: d=json.load(sys.stdin) - for f in d.get('files', []): - print(f.get('filename','')) + files=set() + for c in d.get('commits', []) or []: + for f in (c.get('files') or []): + n = f.get('filename') or '' + if n: + files.add(n) + print('\n'.join(sorted(files))) except Exception: pass ") @@ -62,11 +68,11 @@ BACKEND_COUNT=$(python3 -c "print($TOTAL - $FRONTEND_COUNT)") echo "变更文件: ${TOTAL} 个 (前端: ${FRONTEND_COUNT}, 后端/公共: ${BACKEND_COUNT})" -if [ "$BACKEND_COUNT" = "0" ] && [ "$FRONTEND_COUNT" -gt "0" ]; then +if [ "$BACKEND_COUNT" = "0" ] && [ "$FRONTEND_COUNT" -gt 0 ]; then echo "skip_backend=true" >> "$OUTPUT" echo "skip_frontend=false" >> "$OUTPUT" echo "✅ 纯前端改动,跳过后端镜像构建" -elif [ "$FRONTEND_COUNT" = "0" ] && [ "$BACKEND_COUNT" -gt "0" ]; then +elif [ "$FRONTEND_COUNT" = "0" ] && [ "$BACKEND_COUNT" -gt 0 ]; then echo "skip_backend=false" >> "$OUTPUT" echo "skip_frontend=true" >> "$OUTPUT" echo "🔧 纯后端改动,跳过 Web 镜像构建" -- 2.54.0 From e8ac1f5dc6e8c7ff5cd3cb8ab834827413d6da16 Mon Sep 17 00:00:00 2001 From: ci-bot Date: Sat, 29 Aug 2026 14:55:17 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix(ci):=20deploy-staging=20=E9=93=BE?= =?UTF-8?q?=E8=B7=AF=E4=B8=8D=E5=86=8D=E8=A2=AB=E8=B7=AF=E5=BE=84=E8=BF=87?= =?UTF-8?q?=E6=BB=A4=E8=B7=B3=E8=BF=87=E7=9A=84=E4=B8=8A=E6=B8=B8=E8=BF=9E?= =?UTF-8?q?=E5=B8=A6=20skip?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - act_runner 对无状态检查函数的 job-level if 隐式包 success(), build-staging/retag 被路径过滤 if 跳过时,deploy-staging 及下游 staging-e2e/staging-api-tests 会被连带 skip(#1536 合并后首次 develop push 实际发生:三镜像构建成功但 Deploy Staging skipped) - deploy-staging/staging-e2e/staging-api-tests 的 if 显式加 success(), 使 skipped 上游不阻塞、真正失败仍阻断 - retag-staging-skipped runs-on 从 runtime-builder 迁到 ci-l2 (与 deploy-staging/acr-cleanup 一致,仅需 docker CLI) --- .gitea/workflows/ci-pipeline.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.gitea/workflows/ci-pipeline.yml b/.gitea/workflows/ci-pipeline.yml index 61c99b293..7ee8c2920 100755 --- a/.gitea/workflows/ci-pipeline.yml +++ b/.gitea/workflows/ci-pipeline.yml @@ -940,7 +940,7 @@ jobs: retag-staging-skipped: name: Retag skipped Staging ${{ matrix.service_display }} Image - runs-on: runtime-builder + runs-on: ci-l2 timeout-minutes: 10 needs: - check-push-paths @@ -1029,7 +1029,9 @@ jobs: - check-push-paths - build-staging - retag-staging-skipped - if: github.event_name == 'push' && (github.ref_name == 'main' || github.ref_name == 'develop') + # 显式 success() 状态检查:上游 build/retag 被路径过滤 if 跳过(skipped)时不阻塞本 job; + # 上游真正失败时仍然阻断(act_runner 对无状态函数的 if 隐式包 success(),纯 skipped 也会连带跳过) + if: success() && github.event_name == 'push' && (github.ref_name == 'main' || github.ref_name == 'develop') steps: - name: Checkout code shell: sh @@ -1180,7 +1182,7 @@ jobs: name: Staging E2E Tests runs-on: runtime-builder timeout-minutes: 15 - if: github.ref_name == 'develop' || github.ref_name == 'main' + if: success() && (github.ref_name == 'develop' || github.ref_name == 'main') needs: deploy-staging steps: - name: Checkout code @@ -1227,7 +1229,7 @@ jobs: name: Staging API Integration Tests runs-on: runtime-builder timeout-minutes: 10 - if: github.ref_name == 'develop' || github.ref_name == 'main' + if: success() && (github.ref_name == 'develop' || github.ref_name == 'main') needs: deploy-staging steps: - name: Checkout code -- 2.54.0