Skip to content

Commit c11ddce

Browse files
GODRIVER-3493 Test why codeql is breaking
1 parent 2d0bb21 commit c11ddce

File tree

5 files changed

+101
-101
lines changed

5 files changed

+101
-101
lines changed

.evergreen/config.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1421,15 +1421,13 @@ tasks:
14211421
MONGO_GO_DRIVER_COMPRESSOR: "snappy"
14221422

14231423
# Build the compilecheck submodule with the oldest supported version of Go.
1424-
- name: go1.18-build
1424+
- name: go1.18+-build
14251425
tags: ["compile-check"]
14261426
commands:
14271427
- command: subprocess.exec
14281428
params:
14291429
binary: bash
1430-
env:
1431-
GO_VERSION: "1.18"
1432-
args: [*task-runner, build-compile-check]
1430+
args: [*task-runner, build-compile-check-all]
14331431

14341432
# Build with the same Go version that we're using for tests.
14351433
- name: build

Taskfile.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ tasks:
3030

3131
build-compile-check: bash etc/compile_check.sh
3232

33+
build-compile-check-all: bash etc/run-compile-check-test.sh
34+
3335
build-aws-ecs-test: go build ${BUILD_TAGS} ./internal/cmd/testaws/main.go
3436

3537
cross-compile:

etc/compile_check.sh

Lines changed: 54 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -1,99 +1,57 @@
11
#!/usr/bin/env bash
22
set -e # exit when any command fails
33
set -x # show all commands being run
4-
#
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"}
11-
#COMPILE_CHECK_DIR="internal/cmd/compilecheck"
12-
#
13-
## compile_check will attempt to build the internal/test/compilecheck project
14-
## using the provided Go version. This is to simulate an end-to-end use case.
15-
#function compile_check {
16-
# # Change the directory to the compilecheck test directory.
17-
# pushd ${COMPILE_CHECK_DIR}
18-
#
19-
# # If a custom Go version is set using the GO_VERSION env var (e.g. "1.18"),
20-
# # add the GOPATH bin directory to PATH and then install that Go version.
21-
# if [ ! -z "$GO_VERSION" ]; then
22-
# PATH=$(go env GOPATH)/bin:$PATH
23-
# export PATH
24-
#
25-
# go install golang.org/dl/go$GO_VERSION@latest
26-
# ${GC} download
27-
# fi
28-
#
29-
# ${GC} version
30-
# ${GC} mod tidy
31-
#
32-
# # Check simple build.
33-
# ${GC} build ./...
34-
#
35-
# # Check build with dynamic linking.
36-
# ${GC} build -buildmode=plugin
37-
#
38-
# # Check build with tags.
39-
# ${GC} build $BUILD_TAGS ./...
40-
#
41-
# # 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
52-
#
53-
# # Change the directory back to the working directory.
54-
# popd
55-
#}
56-
#
57-
#compile_check
58-
##!/usr/bin/env bash
59-
#set -e # exit when any command fails
60-
#set -x # show all commands being run
61-
#
62-
#GC=go
63-
#COMPILE_CHECK_DIR="internal/cmd/compilecheck"
64-
#ARCHITECTURES=("386" "arm" "arm64" "ppc64le" "s390x")
65-
#BUILD_CMD="${GC} build -buildvcs=false"
66-
#
67-
## Compilation modules are not part of the workspace as testcontainers requires
68-
## a version of klauspost/compress not supported by the Go Driver / other modules
69-
## in the workspace.
70-
#export GOWORK=off
71-
#
72-
## compile_check will attempt to build the internal/test/compilecheck project
73-
## using the provided Go version. This is to simulate an end-to-end use case.
74-
#function compile_check {
75-
# # Change the directory to the compilecheck test directory.
76-
# pushd "${COMPILE_CHECK_DIR}" >/dev/null
77-
#
78-
# ${GC} version
79-
# ${GC} mod tidy
80-
#
81-
# # Standard build
82-
# $BUILD_CMD ./...
83-
#
84-
# # Dynamic linking
85-
# $BUILD_CMD -buildmode=plugin
86-
#
87-
# # Check build with tags.
88-
# [[ -n "$BUILD_TAGS" ]] && $BUILD_CMD $BUILD_TAGS ./...
89-
#
90-
# # Check build with various architectures.
91-
# for ARCH in "${ARCHITECTURES[@]}"; do
92-
# GOOS=linux GOARCH=$ARCH $BUILD_CMD ./...
93-
# done
94-
#
95-
# # Change the directory back to the working directory.
96-
# popd >/dev/null
97-
#}
98-
#
99-
#compile_check
4+
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"}
11+
COMPILE_CHECK_DIR="internal/cmd/compilecheck"
12+
13+
# compile_check will attempt to build the internal/test/compilecheck project
14+
# using the provided Go version. This is to simulate an end-to-end use case.
15+
function compile_check {
16+
# Change the directory to the compilecheck test directory.
17+
pushd ${COMPILE_CHECK_DIR}
18+
19+
# If a custom Go version is set using the GO_VERSION env var (e.g. "1.18"),
20+
# add the GOPATH bin directory to PATH and then install that Go version.
21+
if [ ! -z "$GO_VERSION" ]; then
22+
PATH=$(go env GOPATH)/bin:$PATH
23+
export PATH
24+
25+
go install golang.org/dl/go$GO_VERSION@latest
26+
${GC} download
27+
fi
28+
29+
${GC} version
30+
${GC} mod tidy
31+
32+
# Check simple build.
33+
${GC} build ./...
34+
35+
# Check build with dynamic linking.
36+
${GC} build -buildmode=plugin
37+
38+
# Check build with tags.
39+
${GC} build $BUILD_TAGS ./...
40+
41+
# 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
52+
53+
# Change the directory back to the working directory.
54+
popd
55+
}
56+
57+
compile_check

etc/compile_check_other.sh

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/usr/bin/env bash
2+
set -e # exit when any command fails
3+
set -x # show all commands being run
4+
5+
GC=go
6+
COMPILE_CHECK_DIR="internal/cmd/compilecheck"
7+
ARCHITECTURES=("386" "arm" "arm64" "ppc64le" "s390x")
8+
BUILD_CMD="${GC} build -buildvcs=false"
9+
10+
# Compilation modules are not part of the workspace as testcontainers requires
11+
# a version of klauspost/compress not supported by the Go Driver / other modules
12+
# in the workspace.
13+
export GOWORK=off
14+
15+
# compile_check will attempt to build the internal/test/compilecheck project
16+
# using the provided Go version. This is to simulate an end-to-end use case.
17+
function compile_check {
18+
# Change the directory to the compilecheck test directory.
19+
pushd "${COMPILE_CHECK_DIR}" >/dev/null
20+
21+
${GC} version
22+
${GC} mod tidy
23+
24+
# Standard build
25+
$BUILD_CMD ./...
26+
27+
# Dynamic linking
28+
$BUILD_CMD -buildmode=plugin
29+
30+
# Check build with tags.
31+
[[ -n "$BUILD_TAGS" ]] && $BUILD_CMD $BUILD_TAGS ./...
32+
33+
# Check build with various architectures.
34+
for ARCH in "${ARCHITECTURES[@]}"; do
35+
GOOS=linux GOARCH=$ARCH $BUILD_CMD ./...
36+
done
37+
38+
# Change the directory back to the working directory.
39+
popd >/dev/null
40+
}
41+
42+
compile_check

internal/test/compilecheck/compile_check_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ func TestCompileCheck(t *testing.T) {
6666
require.NoError(t, err)
6767
}()
6868

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

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

0 commit comments

Comments
 (0)