fix(ci): shard the focused test job instead of one long-lived run
The focused path tested every impacted package in a single job with a plain `go test -race`, so internal/app ran inside one long-lived process alongside all of its reverse dependencies. That is exactly the shape scripts/ci/run-app-race-tests.sh exists to avoid: a single app test process retains every constructed command tree in framework registries, so the run grows to 900s and the job stays alive long enough to be reclaimed by the runner. Recent focused runs failed with SIGTERM after 9-10 minutes without a single test failure, and one earlier run failed at `internal/app 902.651s`, 2.65s past the package timeout. Fan the same package plan across the shard matrix test-race already uses, and run each shard the way test-race runs it: internal/app through the process-isolating helper, cli/smoke with their wider package budget, release-scripts without race and with archive tooling. changed-test-packages.sh gains `list-shard`, which intersects the impacted set with scripts/ci/test-packages.sh shard membership so shard definitions stay single-sourced — and so an unknown shard name aborts there rather than reporting an empty selection, which would let a mistyped shard skip every test while reporting success. release-scripts is in the matrix on purpose: its dedicated job only runs at full-suite or release-sensitive scope, so omitting it here would stop testing test/scripts changes altogether. A test pins that the shard selections partition the impacted set exactly, so shard-plan drift cannot silently shrink focused coverage.
This commit is contained in:
@@ -7,16 +7,32 @@ set -eu
|
||||
ROOT="$(CDPATH= cd -- "$(dirname -- "$0")/../.." && pwd)"
|
||||
|
||||
usage() {
|
||||
printf '%s\n' "usage: $0 <changed|list> BASE_REF HEAD_REF" >&2
|
||||
printf '%s\n' \
|
||||
"usage: $0 <changed|list> BASE_REF HEAD_REF" \
|
||||
" $0 list-shard SHARD BASE_REF HEAD_REF" >&2
|
||||
exit 2
|
||||
}
|
||||
|
||||
[ "${1:-}" = changed ] || [ "${1:-}" = list ] || usage
|
||||
[ "$#" -eq 3 ] || usage
|
||||
|
||||
MODE="$1"
|
||||
BASE_REF="$2"
|
||||
HEAD_REF="$3"
|
||||
# list-shard narrows the impacted set to one test shard so focused CI runs can
|
||||
# fan the same package plan across the shard matrix instead of testing every
|
||||
# impacted package in a single long-lived job.
|
||||
SHARD=""
|
||||
case "${1:-}" in
|
||||
changed|list)
|
||||
[ "$#" -eq 3 ] || usage
|
||||
MODE="$1"
|
||||
BASE_REF="$2"
|
||||
HEAD_REF="$3"
|
||||
;;
|
||||
list-shard)
|
||||
[ "$#" -eq 4 ] || usage
|
||||
MODE="$1"
|
||||
SHARD="$2"
|
||||
BASE_REF="$3"
|
||||
HEAD_REF="$4"
|
||||
;;
|
||||
*) usage ;;
|
||||
esac
|
||||
|
||||
cd "$ROOT"
|
||||
git rev-parse --verify --quiet "${BASE_REF}^{commit}" >/dev/null || {
|
||||
@@ -116,9 +132,29 @@ while IFS= read -r file; do
|
||||
[ "$embedded_owner_found" = true ] || continue
|
||||
done < "$files"
|
||||
|
||||
# emit_selection prints the planned packages, restricted to SHARD when the
|
||||
# caller asked for one. Restriction reuses scripts/ci/test-packages.sh as the
|
||||
# single source of shard membership, which also means an unknown shard name
|
||||
# aborts there instead of being reported as an empty selection: a silently empty
|
||||
# shard would let a mistyped CI shard name skip every test and still succeed.
|
||||
emit_selection() {
|
||||
selection="$1"
|
||||
if [ -z "$SHARD" ]; then
|
||||
cat "$selection"
|
||||
return 0
|
||||
fi
|
||||
shard_packages="$workdir/shard-packages"
|
||||
"$ROOT/scripts/ci/test-packages.sh" list "$SHARD" > "$shard_packages"
|
||||
LC_ALL=C sort -u "$shard_packages" -o "$shard_packages"
|
||||
LC_ALL=C sort -u "$selection" -o "$selection"
|
||||
# An empty intersection is a normal outcome for a shard no change touched, so
|
||||
# comm's silence must not be treated as an error.
|
||||
LC_ALL=C comm -12 "$selection" "$shard_packages"
|
||||
}
|
||||
|
||||
LC_ALL=C sort -u "$changed_packages" -o "$changed_packages"
|
||||
if [ "$MODE" = changed ] || [ ! -s "$changed_packages" ]; then
|
||||
cat "$changed_packages"
|
||||
emit_selection "$changed_packages"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
@@ -133,4 +169,5 @@ while IFS= read -r package; do
|
||||
done < "$all_packages" > "$impacted_packages"
|
||||
|
||||
cat "$changed_packages" >> "$impacted_packages"
|
||||
LC_ALL=C sort -u "$impacted_packages"
|
||||
LC_ALL=C sort -u "$impacted_packages" -o "$impacted_packages"
|
||||
emit_selection "$impacted_packages"
|
||||
|
||||
Reference in New Issue
Block a user