Skip to content

Commit aba09af

Browse files
authored
Simplify SDK consistency test to avoid flaky go list call (#4927)
## Summary `TestConsistentDatabricksSdkVersion` started failing on CI ([example](https://github.com/databricks/cli/actions/runs/24219817586)). The test used `go list -m -json` to resolve the SDK module version to a git hash, then fetched the OpenAPI SHA from GitHub using that hash. The `go list` command requires network access to the Go module proxy to resolve VCS origin metadata, which was failing on CI. This PR simplifies the test by using the version tag (e.g. `v0.126.0`) directly in the GitHub raw content URL instead of first resolving it to a commit hash. Since `raw.githubusercontent.com` accepts tag references, the `go list` step is unnecessary. ## Test plan - [x] CI passes This pull request was AI-assisted by Isaac.
1 parent fb37547 commit aba09af

1 file changed

Lines changed: 3 additions & 24 deletions

File tree

internal/build/sdk_consistency_test.go

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
package build
22

33
import (
4-
"encoding/json"
54
"fmt"
65
"io"
76
"net/http"
87
"os"
9-
"os/exec"
108
"strings"
119
"testing"
1210

@@ -37,28 +35,9 @@ func TestConsistentDatabricksSdkVersion(t *testing.T) {
3735
}
3836
require.NotEmpty(t, version)
3937

40-
// Full path of the package. For example: github.com/databricks/databricks-sdk-go@v0.47.1-0.20241002195128-6cecc224cbf7
41-
fullPath := fmt.Sprintf("%s@%s", modulePath, version)
42-
43-
type goListResponse struct {
44-
Origin struct {
45-
Hash string
46-
}
47-
}
48-
49-
// Using the go CLI query for the git hash corresponding to the databricks-sdk-go version
50-
cmd := exec.Command("go", "list", "-m", "-json", "-mod=readonly", fullPath)
51-
out, err := cmd.Output()
52-
require.NoError(t, err)
53-
parsedOutput := new(goListResponse)
54-
err = json.Unmarshal(out, parsedOutput)
55-
require.NoError(t, err)
56-
hash := parsedOutput.Origin.Hash
57-
require.NotEmpty(t, hash)
58-
59-
// Read the OpenAPI SHA from the Go SDK.
60-
url := fmt.Sprintf("https://raw.githubusercontent.com/databricks/databricks-sdk-go/%s/.codegen/_openapi_sha", hash)
61-
resp, err := http.Get(url)
38+
// Read the OpenAPI SHA from the Go SDK at the version tag.
39+
url := fmt.Sprintf("https://raw.githubusercontent.com/databricks/databricks-sdk-go/%s/.codegen/_openapi_sha", version)
40+
resp, err := http.Get(url) //nolint:gosec
6241
require.NoError(t, err)
6342
defer resp.Body.Close()
6443
require.Equal(t, http.StatusOK, resp.StatusCode)

0 commit comments

Comments
 (0)