Skip to content

Commit 283fb8f

Browse files
fix(ci): fail loudly instead of silently running full suite on shard-lookup failure (#7864)
The shard-file lookup used `mapfile -t SHARD_FILES < <(node -e ...)`, which runs the node one-liner in a process-substitution subshell whose exit code mapfile does not propagate. If matrix.shard doesn't match a key in shard-assignment.json, or the file is missing/corrupt, the node script throws, exits non-zero, but mapfile still returns 0 -- leaving SHARD_FILES empty and silently making vitest run the entire suite instead of its slice. Capture the node output via a checked command-substitution assignment instead (same idiom used to fix compose_file_args in #7765), so a lookup failure now fails the step with an explicit ::error:: annotation and a non-zero exit. Closes #7767
1 parent 2ac97ad commit 283fb8f

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

.github/workflows/ci.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1041,7 +1041,16 @@ jobs:
10411041
# write output at all if that's ever violated, so a bug here fails this step loudly rather
10421042
# than silently dropping a test file from CI.
10431043
node --experimental-strip-types scripts/compute-test-shards.ts --shards=3 --timing=test-timing.json --output=shard-assignment.json
1044-
mapfile -t SHARD_FILES < <(node -e "console.log(JSON.parse(require('fs').readFileSync('shard-assignment.json','utf8'))['${{ matrix.shard }}'].join('\n'))")
1044+
# #7767: capture via a checked assignment so a throw in the node one-liner (bad matrix.shard
1045+
# value, corrupt/missing shard-assignment.json) actually aborts this step -- the old
1046+
# `mapfile -t SHARD_FILES < <(node -e ...)` ran node in a subshell whose non-zero exit was
1047+
# swallowed (mapfile itself returns 0), leaving SHARD_FILES empty and silently making vitest
1048+
# run the entire suite instead of its slice. Same fix idiom as compose_file_args (#7765).
1049+
if ! SHARD_FILES_RAW="$(node -e "console.log(JSON.parse(require('fs').readFileSync('shard-assignment.json','utf8'))['${{ matrix.shard }}'].join('\n'))")"; then
1050+
echo "::error::failed to resolve shard file list for shard ${{ matrix.shard }}"
1051+
exit 1
1052+
fi
1053+
mapfile -t SHARD_FILES <<< "$SHARD_FILES_RAW"
10451054
npm run test:coverage -- --maxWorkers=4 "${SHARD_FILES[@]}" --reporter=default --reporter=blob --reporter=junit --outputFile.blob=blob-report/report-${{ matrix.shard }}.blob --outputFile.junit=reports/junit/vitest.xml "${EXCLUDE_ARGS[@]}"
10461055
fi
10471056
- name: Test failure guidance

0 commit comments

Comments
 (0)