Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 2 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 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
32 changes: 14 additions & 18 deletions etc/compile_check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,36 @@
set -e # exit when any command fails
set -x # show all commands being run

GC=go
GC=go$GO_VERSION
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 +46,7 @@ function compile_check {
rm compilecheck.so

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

compile_check
Loading