-
Notifications
You must be signed in to change notification settings - Fork 919
GODRIVER-3573: Remove old duplicate compilation test #2257
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
base: master
Are you sure you want to change the base?
Changes from 8 commits
669e669
d0d0045
ce0bb58
dc99892
f523a71
aae2e31
53192c1
d9739fd
eebe058
76252c2
9ce3b58
4f0f191
3b5384f
2876500
2f2741a
46f7fb5
e04053f
4c2c5ec
64e14ec
36247d2
ae9a44e
25360a6
3090403
01e2f05
dab69c0
41c8316
cc99ff8
6dc01a9
66275a5
474da0f
d243498
990c738
411d243
30721a2
08217ae
7cd1211
44acf46
6e1d31d
fefbb99
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -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 | ||||||
|
|
@@ -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 ./... | ||||||
| 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$' | ||||||
|
||||||
| 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$' |
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -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" | ||||
|
||||
| COMPILECHECK_USE_DOCKER: "0" | ||||
|
||||
| COMPILECHECK_USE_DOCKER: "0" |
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 | ||
|
||
|
|
||
| echo "Running internal/test/compilecheck with Go versions: $GO_VERSIONS" | ||
| pushd internal/test/compilecheck | ||
| GOWORK=off go test -timeout 30m -v ./... >>../../../test.suite | ||
| popd | ||
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -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) | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
|
|
@@ -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"}, | ||||||||||||||||||||||
|
||||||||||||||||||||||
| 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)), | ||||||||||||||||||||||
| }, | ||||||||||||||||||||||
| }, | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
|
|
@@ -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", "./..."}) | ||||||||||||||||||||||
|
||||||||||||||||||||||
| # 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
})
}
There was a problem hiding this comment.
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:
If this doesn't work, try running the script manually:
If we have to do the latter, we should remove taskfile support: