Skip to content

Commit 6f3f4ed

Browse files
committed
test.sh: only check gofmt if reference Go version is found
1 parent 4f8a87d commit 6f3f4ed

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

.gitlab-ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ gatekeeper-test:
1616
extends: .test:linux:x64
1717
stage: gatekeeper
1818
variables:
19-
GOVERSION: '1.20'
19+
GOVERSION: '1.17'
2020

2121
test:linux:x64:old:
2222
extends: .test:linux:x64

build/test.sh

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,24 @@ set -eu
55
script_dir=$( cd "$(dirname "$0")" ; pwd -P )
66
cd "${script_dir}/.." # move to project root dir
77

8-
unformatted_files=$(gofmt -l .)
9-
if [[ ${unformatted_files} ]]; then
10-
echo "Some files are not formatted properly. You can use \`gofmt -l -w .\` to fix them:"
11-
printf "%s\n" "${unformatted_files}"
12-
exit 1
8+
go_version=$(go version)
9+
echo $go_version
10+
if [[ $go_version == *go1.17.* ]]; then # Keep in sync with our CI gatekeeper job; TODO update to latest
11+
# gofmt is version specific, so only run this for our reference version for development
12+
echo "Reference Go version found for gofmt; checking source format..."
13+
echo "******** Testing: gofmt ********"
14+
unformatted_files=$(gofmt -l .)
15+
if [[ ${unformatted_files} ]]; then
16+
echo "Some files are not formatted properly. You can use \`gofmt -l -w .\` to fix them:"
17+
printf "%s\n" "${unformatted_files}"
18+
exit 1
19+
fi
20+
else
21+
echo "The found Go version is not our reference for gofmt; skipping source format check"
1322
fi
1423

24+
echo "******** Testing: go vet ********"
1525
go vet ./...
1626

27+
echo "******** Testing: go test ********"
1728
go test "$@" ./...

0 commit comments

Comments
 (0)