mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-11-28 16:58:31 +01:00
Preserve inert early rejection before backend fan-out while compiling only changed root-module test packages and their imports for a complete exact-head test-only diff. Fall back to the full package set for source, graph, control, missing or ambiguous evidence. Keep every runtime/vet check, race flag, deadline and required-check verdict unchanged. Contract-Neutral: CI-only inert precompilation scope for exact test-only diffs; product contracts and full runtime verification are unchanged. Change-source: pulse-maintainer
35 lines
1.7 KiB
Bash
35 lines
1.7 KiB
Bash
#!/usr/bin/env bash
|
|
# Compile the same Linux race-test binaries as CI, without running package
|
|
# initialisers, TestMain, tests or examples. This is not a test verdict.
|
|
set -euo pipefail
|
|
|
|
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
selection="$(python3 "$ROOT_DIR/scripts/select-go-test-compile-packages.py" \
|
|
--base "${PULSE_GO_COMPILE_BASE:-}" --head "${PULSE_GO_COMPILE_HEAD:-}")"
|
|
# An unavailable Git diff selects ./...; a broken selector must not turn the
|
|
# gate into a successful no-op. Paths are literal package arguments, not flags.
|
|
if [[ -z "$selection" ]]; then
|
|
echo 'Go precompilation returned no package selection.' >&2
|
|
exit 1
|
|
fi
|
|
mapfile -t packages <<< "$selection"
|
|
for package in "${packages[@]}"; do
|
|
if [[ "$package" != . && "$package" != ./... && ! "$package" =~ ^\./[A-Za-z0-9][A-Za-z0-9_.-]*(/[A-Za-z0-9][A-Za-z0-9_.-]*)*$ ]]; then
|
|
echo 'Go precompilation returned an invalid package selection.' >&2
|
|
exit 1
|
|
fi
|
|
done
|
|
# -exec replaces execution of each successfully linked binary. In contrast,
|
|
# -run '^$' alone still runs init and TestMain. Vet and real test execution
|
|
# remain in the existing required backend shards. Disable result caching so
|
|
# the output cannot be mistaken for a previously executed test result.
|
|
if [[ "$selection" == ./... ]]; then
|
|
echo 'Compiling all Go race-test binaries; no test binary will execute.'
|
|
go test -race -vet=off -count=1 -exec /bin/true ./...
|
|
else
|
|
printf 'Compiling %s changed-test package(s) and their imports; no test binary will execute.\n' "${#packages[@]}"
|
|
printf ' %s\n' "${packages[@]}"
|
|
go test -race -vet=off -count=1 -exec /bin/true "${packages[@]}"
|
|
fi
|
|
echo 'Selected Go race-test binaries compiled; runtime tests remain required.'
|