Skip to content
Open
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
669e669
Remove old compilecheck test
RafaelCenzano Dec 4, 2025
d0d0045
Extract go versions into bash script
RafaelCenzano Dec 5, 2025
ce0bb58
inline go script and run go mod commands in container
RafaelCenzano Dec 5, 2025
dc99892
create Go 1.19 compilecheck
RafaelCenzano Dec 8, 2025
f523a71
Set CodeQL Go version to 1.25.0
RafaelCenzano Dec 9, 2025
aae2e31
Call tasks directly instead of through Taskfile
RafaelCenzano Dec 9, 2025
53192c1
add TODO for future ticket GODRIVER-3723
RafaelCenzano Dec 9, 2025
d9739fd
Remove uneeded compiling for each arch
RafaelCenzano Dec 9, 2025
eebe058
Copilot Suggestions
RafaelCenzano Dec 10, 2025
76252c2
clean up how the test is run/called
RafaelCenzano Dec 10, 2025
9ce3b58
Increase build compilation types
RafaelCenzano Dec 11, 2025
4f0f191
Remove uneeded architectures test as it is included in compile test
RafaelCenzano Dec 11, 2025
3b5384f
install libmongocrypt in container for build tags
RafaelCenzano Dec 11, 2025
2876500
try to correct issue with libmongocrypt
RafaelCenzano Dec 11, 2025
2f2741a
try to correct issue with build
RafaelCenzano Dec 12, 2025
46f7fb5
Redo the libmongocrypt implementation using the same setup as the Tas…
RafaelCenzano Dec 12, 2025
e04053f
try to capture dep in a different way
RafaelCenzano Dec 12, 2025
4c2c5ec
run install step for libmongocrypt
RafaelCenzano Dec 12, 2025
64e14ec
Update container creation
RafaelCenzano Dec 15, 2025
36247d2
Fix how tests are called
RafaelCenzano Dec 15, 2025
ae9a44e
Update dockerfile to use go 1.25 base
RafaelCenzano Dec 16, 2025
25360a6
Include inline main go file to test compilation as an import
RafaelCenzano Dec 16, 2025
3090403
Tweaks to fix the test
RafaelCenzano Dec 17, 2025
01e2f05
check output of go mod tidy
RafaelCenzano Dec 17, 2025
dab69c0
Parallelize
RafaelCenzano Dec 17, 2025
41c8316
Fix the erroneous runOnRequirements CSFLE disabled check in mtest. (#…
matthewdale Dec 10, 2025
cc99ff8
Skip snapshot sessions tests that require the new getSnapshotTime op.…
matthewdale Dec 11, 2025
6dc01a9
GODRIVER-3659 Add optin setting to await MinPoolSize population (#2258)
prestonvasquez Dec 12, 2025
66275a5
GODRIVER-3690 Add ErrorCodesFrom to the mongo package (#2241)
prestonvasquez Dec 16, 2025
474da0f
GODRIVER-3486 Support auto encryption in unified tests. (#2240)
qingyang-hu Dec 16, 2025
d243498
resolve go.mod issue
RafaelCenzano Dec 17, 2025
990c738
Address comments
RafaelCenzano Dec 18, 2025
411d243
Bump actions/upload-artifact from 5.0.0 to 6.0.0 in the actions group…
dependabot[bot] Dec 18, 2025
30721a2
Skip buggy handshake metadata test. (#2270)
matthewdale Dec 18, 2025
08217ae
Make architectures subtests
RafaelCenzano Dec 18, 2025
7cd1211
Pin to amd64 architecture
RafaelCenzano Dec 19, 2025
44acf46
Make improvements based off comments
RafaelCenzano Dec 19, 2025
6e1d31d
Merge branch 'master' into GODRIVER-3573
RafaelCenzano Dec 22, 2025
fefbb99
Remove package sudo
RafaelCenzano Dec 22, 2025
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
24 changes: 22 additions & 2 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.25.0"
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v4
Expand All @@ -40,8 +44,24 @@ jobs:
build-mode: manual
- name: Install Taskfile support
uses: arduino/setup-task@v2
- shell: bash
run: task build
- name: Build (CodeQL-instrumented)
shell: bash
env:
GOTOOLCHAIN: local
run: |
# TODO(GODRIVER-3723): Run using taskfile targets.
go build ./...
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[blocking] We need to include the libmongocrypt task before building:

task install-libmongocrypt

If this doesn't work, try running the script manually:

bash etc/install-libmongocrypt.sh
test -d install || test -d /cygdrive/c/libmongocrypt/bin

If we have to do the latter, we should remove taskfile support:

      - name: Install Taskfile support
        uses: arduino/setup-task@v2

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

GO_VERSIONS="1.19" go test -v ./internal/test/compilecheck -run '^TestCompileCheck/golang:1.19$'
Copy link

Copilot AI Dec 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The compile check test should be run with GOWORK=off to match the configuration in the Taskfile (line 26) and the bash script at etc/run-compile-check-test.sh (line 18). Without this, the test may use workspace settings which could affect the compilation test behavior.

Suggested change
GO_VERSIONS="1.19" go test -v ./internal/test/compilecheck -run '^TestCompileCheck/golang:1.19$'
GOWORK=off GO_VERSIONS="1.19" go test -v ./internal/test/compilecheck -run '^TestCompileCheck/golang:1.19$'

Copilot uses AI. Check for mistakes.

GOOS=linux GOARCH=386 go build ./...
GOOS=linux GOARCH=arm go build ./...
GOOS=linux GOARCH=arm64 go build ./...
GOOS=linux GOARCH=amd64 go build ./...
GOOS=linux GOARCH=ppc64le go build ./...
GOOS=linux GOARCH=s390x go build ./...
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v4
with:
Expand Down
4 changes: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ bin
internal/cmd/faas/awslambda/.aws-sam
internal/cmd/faas/awslambda/events/event.json

# Ignore compiled binaries from the compilecheck
internal/cmd/compilecheck/compilecheck
internal/cmd/compilecheck/compilecheck.so

# Ignore api report files
api-report.md
api-report.txt
Expand Down
13 changes: 11 additions & 2 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,19 @@ tasks:
- go build ./...
- go build ${BUILD_TAGS} ./...
- task: build-tests
- task: build-compile-check
- task: compilecheck-119
- task: cross-compile
build-tests: go test -short ${BUILD_TAGS} -run ^$$ ./...
build-compile-check: bash etc/compile_check.sh
compilecheck-119:
dir: internal/test/compilecheck
env:
GOWORK: off
GOTOOLCHAIN: auto
GO_VERSIONS: "1.19"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[question] Can we lose all these env variables?

COMPILECHECK_USE_DOCKER: "0"
Copy link

Copilot AI Dec 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The environment variable COMPILECHECK_USE_DOCKER is set but never used in the test code. This appears to be dead code that should be removed to avoid confusion.

Suggested change
COMPILECHECK_USE_DOCKER: "0"

Copilot uses AI. Check for mistakes.
cmds:
- go mod download
- go test -v -run '^TestCompileCheck/golang:1\.19$'
build-compile-check-all: bash etc/run-compile-check-test.sh
build-aws-ecs-test: go test -c ./internal/test/aws -o aws.testbin
cross-compile:
Expand Down
48 changes: 0 additions & 48 deletions etc/compile_check.sh

This file was deleted.

11 changes: 10 additions & 1 deletion etc/run-compile-check-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,16 @@
set -eu
set +x

echo "Running internal/test/compilecheck"
# Use specified GO_VERSIONS or default to all supported versions.
# To run the compile check tests with specific Go versions, set the GO_VERSIONS environment variable before running this script.
# For example, to use a single version: GO_VERSIONS=1.25 ./etc/run-compile-check-test.sh
# Or to use multiple versions: GO_VERSIONS="1.23,1.24,1.25" ./etc/run-compile-check-test.sh
if [ -z "${GO_VERSIONS:-}" ]; then
GO_VERSIONS="1.19,1.20,1.21,1.22,1.23,1.24,1.25"
fi
export GO_VERSIONS
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[blocking] We should move the go versions to the compile check test. If we need to run a specific version(s), we can do that with the test name:

GO_WORK=off GO_VERSIONS="1.19" go test -v ./internal/test/compilecheck -run '^TestCompileCheck/golang:1.19$'

GO_VERSIONS="1.19" is a redundancy, 1.19 is already specified in the name regex.


echo "Running internal/test/compilecheck with Go versions: $GO_VERSIONS"
pushd internal/test/compilecheck
GOWORK=off go test -timeout 30m -v ./... >>../../../test.suite
popd
1 change: 0 additions & 1 deletion go.work
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use (
./examples/_logger/zap
./examples/_logger/zerolog
./internal/cmd/benchmark
./internal/cmd/compilecheck
./internal/cmd/faas/awslambda/mongodb
./internal/test/compilecheck
./internal/test/goleak
Expand Down
20 changes: 0 additions & 20 deletions internal/cmd/compilecheck/go.mod

This file was deleted.

42 changes: 0 additions & 42 deletions internal/cmd/compilecheck/go.sum

This file was deleted.

5 changes: 0 additions & 5 deletions internal/cmd/compilecheck/go.work

This file was deleted.

24 changes: 0 additions & 24 deletions internal/cmd/compilecheck/main.go

This file was deleted.

84 changes: 61 additions & 23 deletions internal/test/compilecheck/compile_check_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,49 @@
package main

import (
"bytes"
"context"
"fmt"
"io"
"os"
"path/filepath"
"strings"
"testing"

"github.com/stretchr/testify/assert"
"github.com/docker/docker/api/types/container"
"github.com/stretchr/testify/require"
"github.com/testcontainers/testcontainers-go"
)

var versions = []string{
"1.19",
"1.20",
"1.21",
"1.22",
"1.23",
"1.24",
"1.25",
const mainGo = `package main

import (
"fmt"

"go.mongodb.org/mongo-driver/v2/bson"
"go.mongodb.org/mongo-driver/v2/mongo"
"go.mongodb.org/mongo-driver/v2/mongo/options"
)

func main() {
_, _ = mongo.Connect(options.Client())
fmt.Println(bson.D{{Key: "key", Value: "value"}})
}
`

func getVersions(t *testing.T) []string {
t.Helper()

env := os.Getenv("GO_VERSIONS")
if env == "" {
t.Skip("GO_VERSIONS environment variable not set")
}

return strings.Split(env, ",")
}

func TestCompileCheck(t *testing.T) {
versions := getVersions(t)
cwd, err := os.Getwd()
require.NoError(t, err)

Expand All @@ -43,18 +63,17 @@ func TestCompileCheck(t *testing.T) {
t.Parallel()

req := testcontainers.ContainerRequest{
Image: image,
Cmd: []string{"tail", "-f", "/dev/null"},
Mounts: []testcontainers.ContainerMount{
testcontainers.BindMount(rootDir, "/workspace"),
Image: image,
Cmd: []string{"tail", "-f", "/dev/null"},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nit] Can we add a note about what this does? Something like "keep container running to Exec commands into it"?

WorkingDir: "/app",
HostConfigModifier: func(hostConfig *container.HostConfig) {
hostConfig.Binds = []string{fmt.Sprintf("%s:/driver", rootDir)}
},
WorkingDir: "/workspace",
Env: map[string]string{
"GC": "go",
// Compilation modules are not part of the workspace as testcontainers requires
// a version of klauspost/compress not supported by the Go Driver / other modules
// in the workspace.
"GOWORK": "off",
Files: []testcontainers.ContainerFile{
{
ContainerFilePath: "/app/main.go",
Reader: bytes.NewReader([]byte(mainGo)),
},
},
}

Expand All @@ -71,14 +90,33 @@ func TestCompileCheck(t *testing.T) {
require.NoError(t, err)
}()

exitCode, outputReader, err := container.Exec(context.Background(), []string{"bash", "etc/compile_check.sh"})
// Initialize go module and set up replace directive to use local driver.
setupCmds := [][]string{
{"go", "mod", "init", "app"},
{"go", "mod", "edit", "-replace", "go.mongodb.org/mongo-driver/v2=/driver"},
{"go", "mod", "tidy"},
}

for _, cmd := range setupCmds {
exitCode, outputReader, err := container.Exec(context.Background(), cmd)
require.NoError(t, err)

output, err := io.ReadAll(outputReader)
require.NoError(t, err)

require.Equal(t, 0, exitCode, "command %v failed: %s", cmd, output)
}

// Standard build.
exitCode, outputReader, err := container.Exec(context.Background(), []string{"go", "build", "./..."})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[blocking] We also need to include dynamic linking, building with tags, and building with various architectures.

# Dynamic linking
$BUILD_CMD -buildmode=plugin
# Check build with tags.
[[ -n "$BUILD_TAGS" ]] && $BUILD_CMD $BUILD_TAGS ./...
# Check build with various architectures.
for ARCH in "${ARCHITECTURES[@]}"; do
GOOS=linux GOARCH=$ARCH $BUILD_CMD ./...
done

Build tags can be env-dependent. The architectures should be subtests:

archTests := []string{"amd64", "arm64", /* etc */}
for _, arch := range archTests {
  t.Run(fmt.Sprintf("GOARCH=%s", arch), func(t *testing.T) {
	  // TODO
  })
}

require.NoError(t, err)

output, err := io.ReadAll(outputReader)
require.NoError(t, err)

t.Logf("output: %s", output)
assert.Equal(t, 0, exitCode)
require.Equal(t, 0, exitCode, "standard build failed: %s", output)

t.Logf("compilation checks passed for %s", image)
})
}
}
2 changes: 1 addition & 1 deletion internal/test/compilecheck/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ go 1.25.0
toolchain go1.25.3

require (
github.com/docker/docker v28.0.0+incompatible
github.com/stretchr/testify v1.10.0
github.com/testcontainers/testcontainers-go v0.35.0
)
Expand All @@ -20,7 +21,6 @@ require (
github.com/cpuguy83/dockercfg v0.3.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/distribution/reference v0.6.0 // indirect
github.com/docker/docker v28.0.0+incompatible // indirect
github.com/docker/go-connections v0.5.0 // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
Expand Down
Loading