Skip to content

Commit 7c0cd8c

Browse files
authored
build: Adapt to new Go toolchain versioning change in 1.21 (#150)
* build: Adapt to new Go toolchain versioning change in 1.21 * github: bump CI test timeouts
1 parent 035724c commit 7c0cd8c

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

.github/workflows/test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@ jobs:
112112
go test -v -race ./...
113113
114114
- name: E2E tests
115-
timeout-minutes: 35
115+
timeout-minutes: 70
116116
env:
117117
E2E_TESTING: 1
118118
run: |
119-
go test -timeout=30m -v ./...
119+
go test -timeout=60m -v ./...

internal/build/install_go_version.go

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,21 @@ import (
1313
"github.com/hashicorp/go-version"
1414
)
1515

16+
var v1_21 = version.Must(version.NewVersion("1.21"))
17+
1618
// installGoVersion installs given version of Go using Go
1719
// according to https://golang.org/doc/manage-install
1820
func (gb *GoBuild) installGoVersion(ctx context.Context, v *version.Version) (Go, error) {
19-
versionString := v.Core().String()
21+
goVersion := v.String()
2022

21-
// trim 0 patch versions as that's how Go does it :shrug:
22-
shortVersion := strings.TrimSuffix(versionString, ".0")
23-
pkgURL := fmt.Sprintf("golang.org/dl/go%s", shortVersion)
23+
// trim 0 patch versions as that's how Go does it
24+
// for versions prior to 1.21
25+
// See https://github.com/golang/go/issues/62136
26+
if v.LessThan(v1_21) {
27+
versionString := v.Core().String()
28+
goVersion = strings.TrimSuffix(versionString, ".0")
29+
}
30+
pkgURL := fmt.Sprintf("golang.org/dl/go%s", goVersion)
2431

2532
gb.log().Printf("go getting %q", pkgURL)
2633
cmd := exec.CommandContext(ctx, "go", "get", pkgURL)
@@ -36,7 +43,7 @@ func (gb *GoBuild) installGoVersion(ctx context.Context, v *version.Version) (Go
3643
return Go{}, fmt.Errorf("unable to install Go %s: %w\n%s", v, err, out)
3744
}
3845

39-
cmdName := fmt.Sprintf("go%s", shortVersion)
46+
cmdName := fmt.Sprintf("go%s", goVersion)
4047

4148
gb.log().Printf("downloading go %q", v)
4249
cmd = exec.CommandContext(ctx, cmdName, "download")

0 commit comments

Comments
 (0)