Skip to content

Commit 79d0945

Browse files
GODRIVER-3493 unify compile-check scripts
1 parent 561f78f commit 79d0945

File tree

5 files changed

+17
-80
lines changed

5 files changed

+17
-80
lines changed

Taskfile.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ tasks:
2828

2929
build-tests: go test -short ${BUILD_TAGS} -run ^$$ ./...
3030

31-
build-compile-check: bash etc/compile_check_other.sh
31+
build-compile-check: bash etc/compile_check.sh
3232

3333
build-compile-check-all: bash etc/run-compile-check-test.sh
3434

etc/compile_check.sh

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,17 @@
22
set -e # exit when any command fails
33
set -x # show all commands being run
44

5-
# Default to Go 1.18 if GO_VERSION is not set.
6-
#
7-
# Use the "=" operator (instead of the more common ":-" operator) so that it
8-
# allows setting GO_VERSION="" to use the Go installation in the PATH, and it
9-
# sets the GO_VERSION variable if the default is used.
10-
GC=go${GO_VERSION="1.18"}
5+
: ${GC:=go${GO_VERSION="1.18"}}
6+
117
COMPILE_CHECK_DIR="internal/cmd/compilecheck"
8+
ARCHITECTURES=("386" "arm" "arm64" "ppc64le" "s390x")
9+
BUILD_CMD="${GC} build -buildvcs=false"
1210

1311
# compile_check will attempt to build the internal/test/compilecheck project
1412
# using the provided Go version. This is to simulate an end-to-end use case.
1513
function compile_check {
1614
# Change the directory to the compilecheck test directory.
17-
pushd ${COMPILE_CHECK_DIR}
15+
pushd "${COMPILE_CHECK_DIR}" >/dev/null
1816

1917
# If a custom Go version is set using the GO_VERSION env var (e.g. "1.18"),
2018
# add the GOPATH bin directory to PATH and then install that Go version.
@@ -29,29 +27,22 @@ function compile_check {
2927
${GC} version
3028
${GC} mod tidy
3129

32-
# Check simple build.
33-
${GC} build ./...
30+
# Standard build
31+
$BUILD_CMD ./...
3432

35-
# Check build with dynamic linking.
36-
${GC} build -buildmode=plugin
33+
# Dynamic linking
34+
$BUILD_CMD -buildmode=plugin
3735

3836
# Check build with tags.
39-
${GC} build $BUILD_TAGS ./...
37+
[[ -n "$BUILD_TAGS" ]] && $BUILD_CMD $BUILD_TAGS ./...
4038

4139
# Check build with various architectures.
42-
GOOS=linux GOARCH=386 ${GC} build ./...
43-
GOOS=linux GOARCH=arm ${GC} build ./...
44-
GOOS=linux GOARCH=arm64 ${GC} build ./...
45-
GOOS=linux GOARCH=amd64 ${GC} build ./...
46-
GOOS=linux GOARCH=ppc64le ${GC} build ./...
47-
GOOS=linux GOARCH=s390x ${GC} build ./...
48-
49-
# Remove the binaries.
50-
rm compilecheck
51-
rm compilecheck.so
40+
for ARCH in "${ARCHITECTURES[@]}"; do
41+
GOOS=linux GOARCH=$ARCH $BUILD_CMD ./...
42+
done
5243

5344
# Change the directory back to the working directory.
54-
popd
45+
popd >/dev/null
5546
}
5647

5748
compile_check

etc/compile_check_other.sh

Lines changed: 0 additions & 48 deletions
This file was deleted.

etc/run-compile-check-test.sh

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,7 @@
44
set -eu
55
set +x
66

7-
SUBTEST="${1:-}" # Use the default value if $1 is not set
8-
97
echo "Running internal/test/compilecheck"
108
pushd internal/test/compilecheck
11-
if [ -n "$SUBTEST" ]; then
12-
GOWORK=off go test -run "$SUBTEST" -timeout 30m -v ./... >>../../../test.suite
13-
else
14-
GOWORK=off go test -timeout 30m -v ./... >>../../../test.suite
15-
fi
9+
GOWORK=off go test -timeout 30m -v ./... >>../../../test.suite
1610
popd

internal/test/compilecheck/compile_check_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ func TestCompileCheck(t *testing.T) {
7070
require.NoError(t, err)
7171
}()
7272

73-
exitCode, outputReader, err := container.Exec(context.Background(), []string{"bash", "etc/compile_check_other.sh"})
73+
exitCode, outputReader, err := container.Exec(context.Background(), []string{"bash", "etc/compile_check.sh"})
7474
require.NoError(t, err)
7575

7676
output, err := io.ReadAll(outputReader)

0 commit comments

Comments
 (0)