diff --git a/internal/test/compilecheck/compile_check_test.go b/internal/test/compilecheck/compile_check_test.go index 831b02053f..3ba2e989f7 100644 --- a/internal/test/compilecheck/compile_check_test.go +++ b/internal/test/compilecheck/compile_check_test.go @@ -8,26 +8,31 @@ package main import ( "context" - "encoding/json" "fmt" "io" - "net/http" "os" "path/filepath" - "strings" "testing" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/testcontainers/testcontainers-go" - "golang.org/x/mod/semver" ) // TODO(GODRIVER-3515): This module cannot be included in the workspace since it // requires a version of klauspost/compress that is not compatible with the Go // Driver. Must use GOWORK=off to run this test. -const minSupportedVersion = "1.19" +// TODO(GODRIVER-3592): Add "1.25" to the list when Go 1.25 is released. +// Estimated release date is August 2025. +var versions = []string{ + "1.19", + "1.20", + "1.21", + "1.22", + "1.23", + "1.24", +} func TestCompileCheck(t *testing.T) { cwd, err := os.Getwd() @@ -35,9 +40,6 @@ func TestCompileCheck(t *testing.T) { rootDir := filepath.Dir(filepath.Dir(filepath.Dir(cwd))) - versions, err := getDockerGolangImages() - require.NoError(t, err) - for _, version := range versions { version := version // Capture range variable. @@ -85,67 +87,3 @@ func TestCompileCheck(t *testing.T) { }) } } - -// getDockerGolangImages retrieves the available Golang Docker image tags from -// Docker Hub that are considered valid and meet the specified version -// condition. It returns a slice of version strings in the MajorMinor format and -// an error, if any. -func getDockerGolangImages() ([]string, error) { - // URL to fetch the Golang tags from Docker Hub with a page size of 100 - // records. - var url = "https://hub.docker.com/v2/repositories/library/golang/tags?page_size=100" - - versionSet := map[string]bool{} - versions := []string{} - - // Iteratively fetch and process tags from Docker Hub as long as there is a - // valid next page URL. - for url != "" { - resp, err := http.Get(url) - if err != nil { - return nil, fmt.Errorf("failed to get response from Docker Hub: %w", err) - } - - var data struct { - Results []struct { - Name string `json:"name"` - } `json:"results"` - Next string `json:"next"` // URL of the next page for pagination. - } - - if err := json.NewDecoder(resp.Body).Decode(&data); err != nil { - resp.Body.Close() - - return nil, fmt.Errorf("failed to decode response Body from Docker Hub: %w", err) - } - - resp.Body.Close() - - for _, tag := range data.Results { - // Skip tags that don't start with a digit (typically version numbers). - if len(tag.Name) == 0 || tag.Name[0] < '0' || tag.Name[0] > '9' { - continue - } - - // Split the tag name and extract the base version part. - // This handles tags like `1.18.1-alpine` by extracting `1.18.1`. - base := strings.Split(tag.Name, "-")[0] - - // Reduce the base version to MajorMinor format (e.g., `v1.18`). - baseMajMin := semver.MajorMinor("v" + base) - if !semver.IsValid(baseMajMin) || versionSet[baseMajMin] { - continue - } - - if semver.Compare(baseMajMin, "v"+minSupportedVersion) >= 0 { - versionSet[baseMajMin] = true - versions = append(versions, baseMajMin[1:]) - } - } - - // Move to the next page of results, set by the `Next` field. - url = data.Next - } - - return versions, nil -} diff --git a/internal/test/compilecheck/go.mod b/internal/test/compilecheck/go.mod index a9f29d458c..d1167ba3fb 100644 --- a/internal/test/compilecheck/go.mod +++ b/internal/test/compilecheck/go.mod @@ -7,7 +7,6 @@ toolchain go1.23.1 require ( github.com/stretchr/testify v1.10.0 github.com/testcontainers/testcontainers-go v0.35.0 - golang.org/x/mod v0.24.0 ) require ( diff --git a/internal/test/compilecheck/go.sum b/internal/test/compilecheck/go.sum index 566e970ebe..07c30103e9 100644 --- a/internal/test/compilecheck/go.sum +++ b/internal/test/compilecheck/go.sum @@ -139,8 +139,6 @@ golang.org/x/crypto v0.36.0 h1:AnAEvhDddvBdpY+uR+MyHmuZzzNqXSe/GvuDeob5L34= golang.org/x/crypto v0.36.0/go.mod h1:Y4J0ReaxCR1IMaabaSMugxJES1EpwhBHhv2bDHklZvc= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.24.0 h1:ZfthKaKaT4NrhGVZHO1/WDTwGES4De8KtWO0SIbNJMU= -golang.org/x/mod v0.24.0/go.mod h1:IXM97Txy2VM4PJ3gI61r1YEk/gAj6zAHN3AdZt6S9Ww= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=