ci/validate: add modernize run

Modernize tool [1] basically ensures that the new language features and
packages are used across the code.

The reason to run it in CI is to ensure that
 - PR authors use modern code;
 - our code is modern whether we bump Go version in go.mod.

Shove it into go-fix job which already does a similar thing
but for 'go-fix' and rename the whole job to modernize.

[1]: https://pkg.go.dev/golang.org/x/tools/gopls/internal/analysis/modernize

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
Kir Kolyshkin
2025-08-29 15:24:04 -07:00
parent 7a982f4282
commit c04d9c446d

View File

@@ -48,7 +48,7 @@ jobs:
run: |
golangci-lint run --config .golangci-extra.yml --new-from-rev=HEAD~1
go-fix:
modernize:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v5
@@ -65,6 +65,10 @@ jobs:
run: |
go fix ./...
git diff --exit-code
- name: run modernize
run: |
go run golang.org/x/tools/gopls/internal/analysis/modernize/cmd/modernize@latest -fix -test ./...
git diff --exit-code
compile-buildtags:
runs-on: ubuntu-24.04
@@ -260,9 +264,9 @@ jobs:
- compile-buildtags
- deps
- get-images
- go-fix
- keyring
- lint
- modernize
- release
- shellcheck
- shfmt