Skip to content

Commit abd341b

Browse files
committed
Build project with Go 1.20 and Go 1.21
As part of the upgrade to Go 1.21, the Go toolchain now requires the `go` directive to match the maximum Go version in use in dependencies. This leads to any transitive dependency on this library to result in a requirement of the consuming project moving to Go 1.21. Although in a lot of cases this may not be as problematic, it forces consumers to migrate, which we don't need to do in this case. By making sure we build across both the current venison and the next version of Go - taking care to only support the two major Go versions in use by the Go team - we can hopefully pick up on similar issues. This is a slightly more complex setup than just specifying the version manually, but to avoid the risk of not updating it in all the places, we can at a minimum use the `go.mod` version for the current targeted version. We can make sure to not `fail-fast` so we can see each of the builds' results, instead of only seeing the first to fail.
1 parent 4867c7c commit abd341b

File tree

4 files changed

+48
-4
lines changed

4 files changed

+48
-4
lines changed

.github/workflows/ci.yml

+12-1
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,25 @@ jobs:
44
build:
55
name: Build
66
runs-on: ubuntu-latest
7+
strategy:
8+
fail-fast: false
9+
# perform matrix testing to give us an earlier insight into issues with different versions of supported major versions of Go
10+
matrix:
11+
# strategy is used to allow us to pin to a specific Go version, or use the version available in our `go.mod`
12+
strategy: ['go-version']
13+
version: [1.21]
14+
include:
15+
# pick up the Go version from the `go.mod`
16+
- strategy: 'go-version-file'
17+
version: 'go.mod'
718
steps:
819
- name: Check out source code
920
uses: actions/checkout@v3
1021

1122
- name: Set up Go
1223
uses: actions/setup-go@v3
1324
with:
14-
go-version-file: 'go.mod'
25+
${{ matrix.strategy }}: ${{ matrix.version }}
1526

1627
- name: Test
1728
run: make test

.github/workflows/generate.yml

+12-1
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,25 @@ jobs:
44
build:
55
name: Build
66
runs-on: ubuntu-latest
7+
strategy:
8+
fail-fast: false
9+
# perform matrix testing to give us an earlier insight into issues with different versions of supported major versions of Go
10+
matrix:
11+
# strategy is used to allow us to pin to a specific Go version, or use the version available in our `go.mod`
12+
strategy: ['go-version']
13+
version: [1.21]
14+
include:
15+
# pick up the Go version from the `go.mod`
16+
- strategy: 'go-version-file'
17+
version: 'go.mod'
718
steps:
819
- name: Check out source code
920
uses: actions/checkout@v3
1021

1122
- name: Set up Go
1223
uses: actions/setup-go@v3
1324
with:
14-
go-version-file: 'go.mod'
25+
${{ matrix.strategy }}: ${{ matrix.version }}
1526

1627
- name: Run `make generate`
1728
run: make generate

.github/workflows/lint.yml

+12-1
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,25 @@ jobs:
44
build:
55
name: Build
66
runs-on: ubuntu-latest
7+
strategy:
8+
fail-fast: false
9+
# perform matrix testing to give us an earlier insight into issues with different versions of supported major versions of Go
10+
matrix:
11+
# strategy is used to allow us to pin to a specific Go version, or use the version available in our `go.mod`
12+
strategy: ['go-version']
13+
version: [1.21]
14+
include:
15+
# pick up the Go version from the `go.mod`
16+
- strategy: 'go-version-file'
17+
version: 'go.mod'
718
steps:
819
- name: Check out source code
920
uses: actions/checkout@v3
1021

1122
- name: Set up Go
1223
uses: actions/setup-go@v3
1324
with:
14-
go-version-file: 'go.mod'
25+
${{ matrix.strategy }}: ${{ matrix.version }}
1526

1627
- name: Run `make lint-ci`
1728
run: make lint-ci

.github/workflows/tidy.yml

+12-1
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,25 @@ jobs:
44
build:
55
name: Build
66
runs-on: ubuntu-latest
7+
strategy:
8+
fail-fast: false
9+
# perform matrix testing to give us an earlier insight into issues with different versions of supported major versions of Go
10+
matrix:
11+
# strategy is used to allow us to pin to a specific Go version, or use the version available in our `go.mod`
12+
strategy: ['go-version']
13+
version: [1.21]
14+
include:
15+
# pick up the Go version from the `go.mod`
16+
- strategy: 'go-version-file'
17+
version: 'go.mod'
718
steps:
819
- name: Check out source code
920
uses: actions/checkout@v3
1021

1122
- name: Set up Go
1223
uses: actions/setup-go@v3
1324
with:
14-
go-version-file: 'go.mod'
25+
${{ matrix.strategy }}: ${{ matrix.version }}
1526

1627
- name: Install `tidied`
1728
run: go install gitlab.com/jamietanna/tidied@latest

0 commit comments

Comments
 (0)