Skip to content

Commit 0c2a275

Browse files
authored
fix(ci): validate-tests-merge exits 1 on zero merged test files too (#8174)
#8167 fixed the per-shard --changed case (exits 0 with "No test files found"), but --mergeReports exits 1 for the same condition -- a different code path, not covered by that fix. Confirmed live: PR #8168 (the same docs-only PR #8167 was meant to unblock) passed all 3 validate-tests shards but still failed validate-tests-merge with "No test files found, exiting with code 1", even with COVERAGE_NO_THRESHOLDS already disabling the threshold check. Only treats that exact case as success, and only when COVERAGE_NO_THRESHOLDS is set (i.e. this run is the scoped case to begin with) -- in the unscoped full-suite case, "no test files found" while merging is still a real failure worth surfacing loudly.
1 parent 83c8d70 commit 0c2a275

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

.github/workflows/ci.yml

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1207,7 +1207,24 @@ jobs:
12071207
# so the false branch must be an empty string (falsy), not the literal string "false" (which JS
12081208
# treats as truthy) -- that's why this is a `&& 'true' || ''` expression, not a bare boolean.
12091209
COVERAGE_NO_THRESHOLDS: ${{ (github.event_name == 'pull_request' && vars.SCOPED_TEST_SELECTION_ENABLED != 'false' && needs.changes.outputs.rees != 'true' && needs.changes.outputs.controlPlane != 'true' && needs.changes.outputs.engine != 'true' && needs.changes.outputs.backendConfig != 'true' && (needs.changes.outputs.backend == 'true' || needs.changes.outputs.miner == 'true' || needs.changes.outputs.mcp == 'true' || needs.changes.outputs.discoveryIndex == 'true')) && 'true' || '' }}
1210-
run: npx vitest run --coverage --mergeReports=all-blob-reports
1210+
run: |
1211+
# Unlike the per-shard --changed run (validate-tests above), --mergeReports exits 1 (not 0) when
1212+
# every merged shard's report represents zero matched test files -- confirmed live: PR #8168, a
1213+
# pure docs-only scoped PR where all 3 shards legitimately matched nothing, printed vitest's own
1214+
# "No test files found, exiting with code 1" and failed here even with COVERAGE_NO_THRESHOLDS
1215+
# already disabling the threshold check that comment block above describes. Only treat that exact
1216+
# case as success, and only when COVERAGE_NO_THRESHOLDS is set (i.e. this run is the scoped case
1217+
# to begin with) -- in the unscoped full-suite case, "no test files found" while merging would be
1218+
# a real, surprising break worth failing loudly on, not a legitimate outcome to paper over.
1219+
set -o pipefail
1220+
if npx vitest run --coverage --mergeReports=all-blob-reports 2>&1 | tee vitest-merge-output.log; then
1221+
exit 0
1222+
fi
1223+
if [ -n "$COVERAGE_NO_THRESHOLDS" ] && grep -q "No test files found" vitest-merge-output.log; then
1224+
echo "Merged report matched zero test files, which is expected for this scoped, test-free PR -- not a failure."
1225+
exit 0
1226+
fi
1227+
exit 1
12111228
12121229
# Diff-scoped security gate: fails only on vulnerabilities this PR introduces.
12131230
# Ambient advisories in untouched deps are handled by Renovate + the scheduled

0 commit comments

Comments
 (0)