From 74e3ae559a6794b5ab82870ddb158044ee2e538a Mon Sep 17 00:00:00 2001 From: phm07 <22707808+phm07@users.noreply.github.com> Date: Wed, 18 Sep 2024 12:37:05 +0200 Subject: [PATCH] ci: build and test with Go 1.23 (#871) This PR makes the CI pipeline use Go 1.23 for building and testing. Only setting the `toolchain` in `go.mod` is not enough, because the [setup-go action does not support the `toolchain` directive yet](https://github.com/actions/setup-go/issues/457), we have to set the Go version to 1.23 in all setup-go CI steps manually. We could also set the `go` version in `go.mod` to 1.23 since we do not have any dependents, but that would be misusing the `go` directive, since it is only intended to specify the minimum supported language version of the project. --- .github/workflows/build.yml | 5 ++++- .github/workflows/ci.yml | 11 +++++++---- .github/workflows/release.yml | 5 ++++- .gitlab-ci.yml | 8 ++++---- go.mod | 2 ++ 5 files changed, 21 insertions(+), 10 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 11be996e..1d2ca99a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -5,6 +5,9 @@ on: branches: [main] pull_request: +env: + GOTOOLCHAIN: local + jobs: build: runs-on: ubuntu-latest @@ -15,7 +18,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v5 with: - go-version-file: go.mod + go-version: "1.23" - name: Run GoReleaser uses: goreleaser/goreleaser-action@v6 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 91654d11..f78e9a50 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,6 +5,9 @@ on: branches: [main] pull_request: +env: + GOTOOLCHAIN: local + jobs: lint: runs-on: ubuntu-latest @@ -15,7 +18,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v5 with: - go-version-file: go.mod + go-version: "1.23" - name: Run gofmt run: diff -u <(echo -n) <(gofmt -d -s .) @@ -37,7 +40,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v5 with: - go-version-file: go.mod + go-version: "1.23" - name: Run tests run: go test -coverpkg=./... -coverprofile=coverage.txt -v -race ./... @@ -59,7 +62,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v5 with: - go-version-file: go.mod + go-version: "1.23" - name: Delete old generated files run: find . -name 'zz_*.go' -delete @@ -82,7 +85,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v5 with: - go-version-file: go.mod + go-version: "1.23" - name: Run go mod tidy run: go mod tidy diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a4760bb2..0858067a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -5,6 +5,9 @@ on: tags: - "v*.*.*" +env: + GOTOOLCHAIN: local + jobs: release: runs-on: ubuntu-latest @@ -15,7 +18,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v5 with: - go-version-file: go.mod + go-version: "1.23" - name: Setup rcodesign uses: hashicorp/action-setup-rcodesign@v1 diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 5c3e92e2..c1ad7c88 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -18,7 +18,7 @@ cache: build: stage: build - image: golang:1.21 + image: golang:1.23 script: - go env - go mod download @@ -31,21 +31,21 @@ test:lint: test:tidy: stage: test - image: golang:1.21 + image: golang:1.23 script: - go mod tidy -v - git diff --exit-code test:generate: stage: test - image: golang:1.21 + image: golang:1.23 script: - go generate ./... - git diff --exit-code test:unit: stage: test - image: golang:1.21 + image: golang:1.23 script: - go test -v -coverpkg=./... -coverprofile=coverage.txt -covermode count ./... - go get github.com/boumenot/gocover-cobertura diff --git a/go.mod b/go.mod index c0a446a1..d25358bf 100644 --- a/go.mod +++ b/go.mod @@ -2,6 +2,8 @@ module github.com/hetznercloud/cli go 1.21 +toolchain go1.23.1 + require ( github.com/BurntSushi/toml v1.4.0 github.com/boumenot/gocover-cobertura v1.2.0