Simplify release validation gates
This commit is contained in:
@@ -12,68 +12,18 @@ run_go() {
|
||||
GOTOOLCHAIN="$toolchain" GOPROXY=off go "$@"
|
||||
}
|
||||
|
||||
check_toolchain() {
|
||||
local toolchain=$1
|
||||
GOTOOLCHAIN="$toolchain" GOPROXY=off go version >/dev/null
|
||||
run_go "$toolchain" mod download
|
||||
}
|
||||
|
||||
check_toolchain "$baseline_toolchain"
|
||||
bash -n scripts/release-check.sh
|
||||
|
||||
temporary_dir=$(mktemp -d)
|
||||
trap 'rm -rf -- "$temporary_dir"' EXIT
|
||||
candidate_manifest=$temporary_dir/candidate-files
|
||||
while IFS= read -r -d '' candidate_file; do
|
||||
if [[ -e "$candidate_file" || -L "$candidate_file" ]]; then
|
||||
printf '%s\0' "$candidate_file" >>"$candidate_manifest"
|
||||
fi
|
||||
done < <(git ls-files --cached --others --exclude-standard -z)
|
||||
tar --null --files-from="$candidate_manifest" --create --file=- |
|
||||
tar --extract --file=- --directory="$temporary_dir"
|
||||
(
|
||||
cd "$temporary_dir"
|
||||
GOTOOLCHAIN="$baseline_toolchain" GOPROXY=off go mod tidy
|
||||
)
|
||||
diff -u go.mod "$temporary_dir/go.mod"
|
||||
diff -u go.sum "$temporary_dir/go.sum"
|
||||
|
||||
go_files=()
|
||||
while IFS= read -r -d '' go_file; do
|
||||
if [[ -f "$go_file" ]]; then
|
||||
go_files+=("$go_file")
|
||||
fi
|
||||
done < <(git ls-files --cached --others --exclude-standard -z -- '*.go')
|
||||
if ((${#go_files[@]})); then
|
||||
unformatted=$(gofmt -l -- "${go_files[@]}")
|
||||
if [[ -n "$unformatted" ]]; then
|
||||
printf 'gofmt required for:\n%s\n' "$unformatted" >&2
|
||||
exit 1
|
||||
fi
|
||||
if ! GOTOOLCHAIN="$baseline_toolchain" GOPROXY=off go version >/dev/null; then
|
||||
printf 'release toolchain %s is unavailable; acquire it before validation\n' "$baseline_toolchain" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
git diff --check HEAD --
|
||||
while IFS= read -r -d '' candidate_file; do
|
||||
if [[ ! -f "$candidate_file" ]]; then
|
||||
continue
|
||||
fi
|
||||
case "$candidate_file" in
|
||||
*.go|*.md|*.sh|go.mod|go.sum|LICENSE|.gitignore|AGENTS.md)
|
||||
if LC_ALL=C grep -nE '[[:blank:]]+$' -- "$candidate_file"; then
|
||||
printf 'trailing whitespace found in %s\n' "$candidate_file" >&2
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
done < <(git ls-files --cached --others --exclude-standard -z)
|
||||
|
||||
# Verbose output reports skipped cases without a separate evidence run.
|
||||
run_go "$baseline_toolchain" test -race -v ./...
|
||||
run_go "$baseline_toolchain" vet ./...
|
||||
run_go "$baseline_toolchain" test -mod=readonly -vet=off -race -v ./...
|
||||
run_go "$baseline_toolchain" vet -mod=readonly ./...
|
||||
|
||||
# Only release-validated targets gate publication; macOS is best-effort.
|
||||
for target in linux/amd64 linux/arm64; do
|
||||
target_os=${target%/*}
|
||||
target_arch=${target#*/}
|
||||
GOTOOLCHAIN="$baseline_toolchain" GOPROXY=off CGO_ENABLED=0 GOOS="$target_os" GOARCH="$target_arch" go build ./...
|
||||
GOTOOLCHAIN="$baseline_toolchain" GOPROXY=off CGO_ENABLED=0 GOOS="$target_os" GOARCH="$target_arch" go build -mod=readonly ./...
|
||||
done
|
||||
|
||||
Reference in New Issue
Block a user