Skip to content

Commit 6e77bd8

Browse files
authored
fix(tests): fix setup-node and setup-go act tests (#678)
1 parent 249c66d commit 6e77bd8

1 file changed

Lines changed: 12 additions & 12 deletions

File tree

tests/act/internal/versions/versions.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,17 @@ import (
1313
)
1414

1515
const (
16-
nodeReleasesURL = "https://nodejs.org/download/release/index.json"
17-
goReleasesURL = "https://golang.org/dl/?mode=json&include=all"
16+
nodeReleasesURL = "https://raw.githubusercontent.com/actions/node-versions/refs/heads/main/versions-manifest.json"
17+
goReleasesURL = "https://raw.githubusercontent.com/actions/go-versions/refs/heads/main/versions-manifest.json"
1818
httpTimeout = 30 * time.Second
1919
)
2020

2121
type nodeRelease struct {
22-
Version string `json:"version"` // e.g., "v24.12.0"
22+
Version string `json:"version"` // e.g., "24.12.0"
2323
}
2424

2525
type goRelease struct {
26-
Version string `json:"version"` // e.g., "go1.25.6"
26+
Version string `json:"version"` // e.g., "1.25.6"
2727
Stable bool `json:"stable"`
2828
}
2929

@@ -35,12 +35,13 @@ func LatestNodeVersion(major string) (string, error) {
3535
return "", fmt.Errorf("fetch node releases: %w", err)
3636
}
3737

38-
// Match versions like "v24.x.y" for major "24"
39-
prefix := "v" + major + "."
38+
// Match versions like "24.x.y" for major "24"
39+
prefix := major + "."
4040
for _, r := range releases {
4141
if strings.HasPrefix(r.Version, prefix) {
4242
// The releases are sorted newest first, so the first match is the latest
43-
return r.Version, nil
43+
// Add "v" prefix to match format used by setup-node action
44+
return "v" + r.Version, nil
4445
}
4546
}
4647

@@ -55,17 +56,16 @@ func LatestGoVersion(majorMinor string) (string, error) {
5556
return "", fmt.Errorf("fetch go releases: %w", err)
5657
}
5758

58-
prefix := "go" + majorMinor
5959
var candidates []string
6060

6161
for _, r := range releases {
6262
if !r.Stable {
6363
continue
6464
}
65-
// Match "go1.25" or "go1.25.x"
66-
if r.Version == prefix || strings.HasPrefix(r.Version, prefix+".") {
67-
// Convert to semver format: "go1.25.6" -> "v1.25.6"
68-
v := "v" + strings.TrimPrefix(r.Version, "go")
65+
// Match "1.25" or "1.25.x"
66+
if r.Version == majorMinor || strings.HasPrefix(r.Version, majorMinor+".") {
67+
// Convert to semver format: "1.25.6" -> "v1.25.6"
68+
v := "v" + r.Version
6969
candidates = append(candidates, v)
7070
}
7171
}

0 commit comments

Comments
 (0)