Files
wire/internal/runtests.sh
Robert Findley 5c5c92a1c5 all: update the x/tools dependency to fix the build with Go 1.25 (#432)
An unfortunate bug caused a number of packages in old x/tools versions
to fail to build with Go 1.25 (https://go.dev/issue/74462). Fix this
minimally by updating to the lowest patched version with the fix:
v0.24.1. This should allow wire to continue building with the same range
of Go versions as it could build with before (down to 1.19).

Also:
- Update the go.mod go directive to Go 1.19 to allow for module graph
  pruning, and to be consistent with the minimum build version.
- Fix a test that is broken in recent Go versions due to an error
  message change.
- Update tests to run on Go 1.25.x (the most recent version of Go).
- Remove coverage, since coverage upload wasn't working anyway.

Fixes #431
2025-08-21 10:01:40 -04:00

72 lines
2.2 KiB
Bash
Executable File

#!/usr/bin/env bash
# Copyright 2019 The Wire Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# https://coderwall.com/p/fkfaqq/safer-bash-scripts-with-set-euxo-pipefail
set -euo pipefail
if [[ $# -gt 0 ]]; then
echo "usage: runtests.sh" 1>&2
exit 64
fi
# Run Go tests.
result=0
echo "Running Go tests..."
go test -mod=readonly -race ./... || result=1
# No need to run other checks on OSs other than linux.
# We default RUNNER_OS to "Linux" so that we don't abort here when run locally.
if [[ "${RUNNER_OS:-Linux}" != "Linux" ]]; then
exit $result
fi
echo
echo "Ensuring .go files are formatted with gofmt -s..."
mapfile -t go_files < <(find . -name '*.go' -type f | grep -v testdata)
DIFF="$(gofmt -s -d "${go_files[@]}")"
if [ -n "$DIFF" ]; then
echo "FAIL: please run gofmt -s and commit the result"
echo "$DIFF";
result=1;
else
echo "OK"
fi;
# Ensure that the code has no extra dependencies (including transitive
# dependencies) that we're not already aware of by comparing with
# ./internal/alldeps
#
# Whenever project dependencies change, rerun ./internal/listdeps.sh
echo
echo "Ensuring that there are no dependencies not listed in ./internal/alldeps..."
(./internal/listdeps.sh | diff ./internal/alldeps - && echo "OK") || {
echo "FAIL: dependencies changed; run: internal/listdeps.sh > internal/alldeps"
# Module behavior may differ across versions.
echo "using the latest go version."
result=1
}
# For pull requests, check if there are undeclared incompatible API changes.
# Skip this if we're already going to fail since it is expensive.
# CURRENTLY BROKEN
# if [[ ${result} -eq 0 ]] && [[ ! -z "${GITHUB_HEAD_REF:-x}" ]]; then
# echo
# ./internal/check_api_change.sh || result=1;
# fi
exit $result