From 8d4a0bdba8d5929c31932d33886a440eaf4c0758 Mon Sep 17 00:00:00 2001 From: chenxing Date: Tue, 27 Oct 2026 12:11:10 +0800 Subject: [PATCH] =?UTF-8?q?fix(ci):=20=E5=8F=8D=E5=90=91=E9=97=A8=E7=A6=81?= =?UTF-8?q?=E4=B8=8D=E5=86=8D=E5=86=99=E6=AD=BB=E7=94=A8=E4=BE=8B=E6=80=BB?= =?UTF-8?q?=E6=95=B0=EF=BC=8C=E6=94=B9=E9=92=89=E3=80=8C=E7=BC=BA=E8=A1=A8?= =?UTF-8?q?=E5=BF=85=E6=8A=A5=20error=E3=80=81=E6=96=AD=E8=A8=80=E4=B8=8D?= =?UTF-8?q?=E5=BE=97=E5=A4=B1=E8=B4=A5=E3=80=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit verify-failure-guard.sh 原断言固定 'Tests run: 92, Failures: 0, Errors: 11', 而本候选门禁类实跑 101 例(D10/D11 新增用例),写死总数会让正常演进直接红灯、 阻断镜像产出。改为解析最后一行 Surefire 汇总并断言 tests>0 / failures=0 / errors>0, 保留“空 schema 必须阻断打包且不产 JAR”的原意。 本地等价实跑(隔离 MySQL 8.0.45,ddl-auto=validate,空 schema): NEGATIVE_MVN_EXIT=1,NEGATIVE_SUMMARY tests=101 failures=0 errors=11 skipped=0, CI_EMPTY_SCHEMA_FAILURE_GUARD=PASS。 --- ci/verify-failure-guard.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/ci/verify-failure-guard.sh b/ci/verify-failure-guard.sh index cadef0c..6b64a6f 100644 --- a/ci/verify-failure-guard.sh +++ b/ci/verify-failure-guard.sh @@ -13,6 +13,14 @@ cat "$log" echo "NEGATIVE_MVN_EXIT=$code" [ "$code" -ne 0 ] || { echo 'Empty schema unexpectedly passed' >&2; exit 1; } grep -q 'Schema-validation: missing table' "$log" -grep -q 'Tests run: 92, Failures: 0, Errors: 11, Skipped: 0' "$log" +# 只钉“缺表必须让真实库用例报 error、其余断言不得失败”这一契约,不钉具体用例总数: +# 门禁类会随被测类新增用例而变化(2026-10-27 已由 92 增至 101),写死总数会把正常演进变成红灯。 +summary=$(sed -n 's/.*Tests run: \([0-9]*\), Failures: \([0-9]*\), Errors: \([0-9]*\), Skipped: \([0-9]*\).*/\1 \2 \3 \4/p' "$log" | tail -1) +[ -n "$summary" ] || { echo 'Negative gate produced no Surefire summary' >&2; exit 1; } +set -- $summary +echo "NEGATIVE_SUMMARY tests=$1 failures=$2 errors=$3 skipped=$4" +[ "$1" -gt 0 ] || { echo 'No tests ran' >&2; exit 1; } +[ "$2" -eq 0 ] || { echo 'Empty schema caused assertion failures, not schema errors' >&2; exit 1; } +[ "$3" -gt 0 ] || { echo 'Empty schema did not produce any schema error' >&2; exit 1; } [ -z "$(find target -maxdepth 1 -name '*.jar' -print -quit 2>/dev/null)" ] || { echo 'Failed gate produced a JAR' >&2; exit 1; } echo 'CI_EMPTY_SCHEMA_FAILURE_GUARD=PASS'