Skip to content

Commit

Permalink
ci: build and test with Go 1.23 (#871)
Browse files Browse the repository at this point in the history
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](actions/setup-go#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.
  • Loading branch information
phm07 authored Sep 18, 2024
1 parent 7643fa2 commit 74e3ae5
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 10 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ on:
branches: [main]
pull_request:

env:
GOTOOLCHAIN: local

jobs:
build:
runs-on: ubuntu-latest
Expand All @@ -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
Expand Down
11 changes: 7 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ on:
branches: [main]
pull_request:

env:
GOTOOLCHAIN: local

jobs:
lint:
runs-on: ubuntu-latest
Expand All @@ -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 .)
Expand All @@ -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 ./...
Expand All @@ -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
Expand All @@ -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
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ on:
tags:
- "v*.*.*"

env:
GOTOOLCHAIN: local

jobs:
release:
runs-on: ubuntu-latest
Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ cache:

build:
stage: build
image: golang:1.21
image: golang:1.23
script:
- go env
- go mod download
Expand All @@ -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
Expand Down
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 74e3ae5

Please sign in to comment.