Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions .evergreen/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1362,16 +1362,15 @@ tasks:
vars:
MONGO_GO_DRIVER_COMPRESSOR: "snappy"

# Build with the oldest supported version of Go.
# Build the compilecheck submodule with the oldest supported version of Go.
- name: go1.18-build
tags: ["compile-check"]
commands:
- command: subprocess.exec
params:
binary: bash
env:
GOROOT: /opt/golang/go1.18
add_to_path: [/opt/golang/go1.18/bin]
GO_VERSION: "1.18"
args: [*task-runner, build-compile-check]

# Build with the same Go version that we're using for tests.
Expand All @@ -1381,6 +1380,10 @@ tasks:
- command: subprocess.exec
params:
binary: bash
# Set the GO_VERSION to empty string to use the Go installation in the
# PATH.
env:
GO_VERSION: ""
args: [*task-runner, build]

- name: "atlas-test"
Expand Down
5 changes: 4 additions & 1 deletion Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,13 @@ tasks:
check-license: bash etc/check_license.sh

build:
deps: [cross-compile, build-tests, build-compile-check, install-libmongocrypt]
deps: [install-libmongocrypt]
cmds:
- go build ./...
- go build ${BUILD_TAGS} ./...
- task: build-tests
- task: build-compile-check
- task: cross-compile

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

Expand Down
37 changes: 19 additions & 18 deletions etc/compile_check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,41 @@
set -e # exit when any command fails
set -x # show all commands being run

GC=go
# Default to Go 1.18 if GO_VERSION is not set.
#
# Use the "=" operator (instead of the more common ":-" operator) so that it
# allows setting GO_VERSION="" to use the Go installation in the PATH, and it
# sets the GO_VERSION variable if the default is used.
GC=go${GO_VERSION="1.18"}
COMPILE_CHECK_DIR="internal/cmd/compilecheck"
# shellcheck disable=SC2034
DEV_MIN_VERSION=1.19

# version will flatten a version string of upto 4 components for inequality
# comparison.
function version {
echo "$@" | awk -F. '{ printf("%d%03d%03d%03d\n", $1,$2,$3,$4); }';
}

# compile_check will attempt to build the internal/test/compilecheck project
# using the provided Go version. This is to simulate an end-to-end use case.
# This check will only run on environments where the Go version is greater than
# or equal to the given version.
function compile_check {
# Change the directory to the compilecheck test directory.
cd ${COMPILE_CHECK_DIR}
pushd ${COMPILE_CHECK_DIR}

MACHINE_VERSION=`${GC} version | { read _ _ v _; echo ${v#go}; }`
# If a custom Go version is set using the GO_VERSION env var (e.g. "1.18"),
# add the GOPATH bin directory to PATH and then install that Go version.
if [ ! -z "$GO_VERSION" ]; then
PATH=$(go env GOPATH)/bin:$PATH
export PATH

# If the version is not 1.13, then run "go mod tidy"
if [ "$(version $MACHINE_VERSION)" -ge "$(version 1.15)" ]; then
go mod tidy
go install golang.org/dl/go$GO_VERSION@latest
${GC} download
fi

${GC} version
${GC} mod tidy

# Check simple build.
${GC} build ./...

# Check build with dynamic linking.
${GC} build -buildmode=plugin

# Check build with tags.
go build $BUILD_TAGS ./...
${GC} build $BUILD_TAGS ./...

# Check build with various architectures.
GOOS=linux GOARCH=386 ${GC} build ./...
Expand All @@ -50,7 +51,7 @@ function compile_check {
rm compilecheck.so

# Change the directory back to the working directory.
cd -
popd
}

compile_check
Loading