Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use a local Go 1.18 installation to check for minimum version support. #1871

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
7 changes: 1 addition & 6 deletions .evergreen/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1362,19 +1362,14 @@ tasks:
vars:
MONGO_GO_DRIVER_COMPRESSOR: "snappy"

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

# Build with the same Go version that we're using for tests.
- name: build
tags: ["compile-check"]
commands:
Expand Down
18 changes: 16 additions & 2 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,22 @@ 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: cross-compile
- task: build-tests

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

build-compile-check: bash etc/compile_check.sh
# Build the compilecheck submodule, both with the system version of Go and
# with the minimum supported version of Go (Go 1.18).
build-compile-check:
deps: [install-go118]
cmds:
- bash etc/compile_check.sh
- PATH=$(go1.18 env GOROOT)/bin:$PATH GOROOT=$(go1.18 env GOROOT) bash etc/compile_check.sh

build-aws-ecs-test: go build ${BUILD_TAGS} ./internal/cmd/testaws/main.go

Expand Down Expand Up @@ -210,3 +218,9 @@ tasks:
internal: true
cmds:
- go install github.com/walle/lll/...@latest

install-go118:
internal: true
cmds:
- go install golang.org/dl/go1.18@latest
- go1.18 download
23 changes: 5 additions & 18 deletions etc/compile_check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,15 @@ set -x # show all commands being run
GC=go
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}

MACHINE_VERSION=`${GC} version | { read _ _ v _; echo ${v#go}; }`
pushd ${COMPILE_CHECK_DIR}

# If the version is not 1.13, then run "go mod tidy"
if [ "$(version $MACHINE_VERSION)" -ge "$(version 1.15)" ]; then
go mod tidy
fi
${GC} version
${GC} mod tidy

# Check simple build.
${GC} build ./...
Expand All @@ -35,7 +22,7 @@ function compile_check {
${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 +37,7 @@ function compile_check {
rm compilecheck.so

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

compile_check
Loading