Skip to content

Commit

Permalink
internal/ci: set GOTOOLCHAIN=local as part of installGo
Browse files Browse the repository at this point in the history
Installing a specific version of Go in a CI matrix has intent: i.e. we
intend to use that verison for everything.

The default value for GOTOOLCHAIN is 'auto'. Per:

    https://go.dev/doc/toolchain

this has the effect of downloading other toolchains as required by
go.mod files of dependencies etc. We don't want this: we want to fail in
case the version intended by CI is not appropriate.

Signed-off-by: Paul Jolly <paul@myitcv.io>
Change-Id: I3b0fa04c69dc51d75bafcdf513e0415adf85564d
Dispatch-Trailer: {"type":"trybot","CL":1200599,"patchset":1,"ref":"refs/changes/99/1200599/1","targetBranch":"master"}
  • Loading branch information
myitcv authored and cueckoo committed Sep 3, 2024
1 parent 46fb300 commit 038f3a3
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 14 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ jobs:
with:
cache: false
go-version: 1.23.0
- name: Set common go env vars
run: go env -w GOTOOLCHAIN=local
- name: Setup qemu
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/trybot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ jobs:
with:
cache: false
go-version: ${{ matrix.go-version }}
- name: Set common go env vars
run: go env -w GOTOOLCHAIN=local
- name: Get go mod cache directory
id: go-mod-cache-dir
run: echo "dir=$(go env GOMODCACHE)" >> ${GITHUB_OUTPUT}
Expand Down
31 changes: 23 additions & 8 deletions internal/ci/base/github.cue
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,29 @@ bashWorkflow: json.#Workflow & {
jobs: [string]: defaults: run: shell: "bash"
}

installGo: json.#step & {
name: "Install Go"
uses: "actions/setup-go@v5"
with: {
// We do our own caching in setupGoActionsCaches.
cache: false
"go-version": string
installGo: {
#setupGo: json.#step & {
name: "Install Go"
uses: "actions/setup-go@v5"
with: {
// We do our own caching in setupGoActionsCaches.
cache: false
"go-version": string
}
}

[
#setupGo,

{
json.#step & {
name: "Set common go env vars"
run: """
go env -w GOTOOLCHAIN=local
"""
}
},
]
}

checkoutCode: {
Expand Down Expand Up @@ -100,7 +115,7 @@ checkoutCode: {

earlyChecks: json.#step & {
name: "Early git and code sanity checks"
run: "go run ./internal/ci/checks"
run: "go run ./internal/ci/checks"
}

curlGitHubAPI: {
Expand Down
9 changes: 6 additions & 3 deletions internal/ci/github/release.cue
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,14 @@ workflows: release: _repo.bashWorkflow & {
jobs: goreleaser: {
"runs-on": _repo.linuxMachine
if: "${{github.repository == '\(_repo.githubRepositoryPath)'}}"

let installGo = _repo.installGo & {
#setupGo: with: "go-version": _repo.pinnedReleaseGo
_
}
steps: [
for v in _repo.checkoutCode {v},
_repo.installGo & {
with: "go-version": _repo.pinnedReleaseGo
},
for v in installGo {v},
json.#step & {
name: "Setup qemu"
uses: "docker/setup-qemu-action@v3"
Expand Down
9 changes: 6 additions & 3 deletions internal/ci/github/trybot.cue
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ workflows: trybot: _repo.bashWorkflow & {
_
}

let installGo = _repo.installGo & {
#setupGo: with: "go-version": goVersionVal
_
}

// Only run the trybot workflow if we have the trybot trailer, or
// if we have no special trailers. Note this condition applies
// after and in addition to the "on" condition above.
Expand All @@ -51,9 +56,7 @@ workflows: trybot: _repo.bashWorkflow & {
steps: [
for v in _repo.checkoutCode {v},

_repo.installGo & {
with: "go-version": goVersionVal
},
for v in installGo {v},

// cachePre must come after installing Node and Go, because the cache locations
// are established by running each tool.
Expand Down

0 comments on commit 038f3a3

Please sign in to comment.