From 6236bb6341aaafd524259e1619f79cc5178d91af Mon Sep 17 00:00:00 2001 From: Camila Macedo <7708031+camilamacedo86@users.noreply.github.com> Date: Sun, 24 Nov 2024 14:14:36 +0000 Subject: [PATCH] Update actions to use go.mod for Go version management This commit changes all GitHub Actions to use the go.mod file for specifying the Go version instead of pinning the version directly. This reduces the burden of maintaining the Go version across multiple workflows. --- .github/workflows/apidiff.yml | 2 +- .github/workflows/external-plugin.yml | 2 +- .github/workflows/legacy-webhook-path.yml | 2 +- .github/workflows/lint-sample.yml | 2 +- .github/workflows/lint.yml | 6 +++--- .github/workflows/release.yml | 2 +- .github/workflows/test-devcontainer.yaml | 2 +- .github/workflows/test-e2e-book.yml | 6 +++--- .github/workflows/test-e2e-samples.yml | 6 +++--- .github/workflows/test-helm-samples.yml | 2 +- .github/workflows/testdata.yml | 2 +- .github/workflows/unit-tests.yml | 4 ++-- .../testdata/project/.github/workflows/lint.yml | 2 +- .../testdata/project/.github/workflows/test-e2e.yml | 2 +- .../testdata/project/.github/workflows/test.yml | 2 +- .../testdata/project/.github/workflows/lint.yml | 2 +- .../testdata/project/.github/workflows/test-e2e.yml | 2 +- .../testdata/project/.github/workflows/test.yml | 2 +- .../testdata/project/.github/workflows/lint.yml | 2 +- .../testdata/project/.github/workflows/test-e2e.yml | 2 +- .../testdata/project/.github/workflows/test.yml | 2 +- go.mod | 4 +--- .../golang/v4/scaffolds/internal/templates/github/lint.go | 2 +- .../v4/scaffolds/internal/templates/github/test-e2e.go | 2 +- .../golang/v4/scaffolds/internal/templates/github/test.go | 2 +- .../scaffolds/internal/templates/github/test_chart.go | 2 +- testdata/project-v4-multigroup/.github/workflows/lint.yml | 2 +- .../project-v4-multigroup/.github/workflows/test-e2e.yml | 2 +- testdata/project-v4-multigroup/.github/workflows/test.yml | 2 +- testdata/project-v4-with-plugins/.github/workflows/lint.yml | 2 +- .../.github/workflows/test-chart.yml | 2 +- .../project-v4-with-plugins/.github/workflows/test-e2e.yml | 2 +- testdata/project-v4-with-plugins/.github/workflows/test.yml | 2 +- testdata/project-v4/.github/workflows/lint.yml | 2 +- testdata/project-v4/.github/workflows/test-e2e.yml | 2 +- testdata/project-v4/.github/workflows/test.yml | 2 +- 36 files changed, 43 insertions(+), 45 deletions(-) diff --git a/.github/workflows/apidiff.yml b/.github/workflows/apidiff.yml index 9f5bdabdbad..c9752d9cdd9 100644 --- a/.github/workflows/apidiff.yml +++ b/.github/workflows/apidiff.yml @@ -22,7 +22,7 @@ jobs: - name: Setup Go uses: actions/setup-go@v5 with: - go-version: "~1.22" + go-version-file: go.mod - name: Execute go-apidiff uses: joelanford/go-apidiff@v0.8.2 with: diff --git a/.github/workflows/external-plugin.yml b/.github/workflows/external-plugin.yml index d177dba8f16..71d6e04ee1d 100644 --- a/.github/workflows/external-plugin.yml +++ b/.github/workflows/external-plugin.yml @@ -26,7 +26,7 @@ jobs: - name: Setup Go uses: actions/setup-go@v5 with: - go-version: '1.22.3' + go-version-file: docs/book/src/simple-external-plugin-tutorial/testdata/sampleexternalplugin/v1/go.mod - name: Build Sample External Plugin working-directory: docs/book/src/simple-external-plugin-tutorial/testdata/sampleexternalplugin/v1 diff --git a/.github/workflows/legacy-webhook-path.yml b/.github/workflows/legacy-webhook-path.yml index c094e23de76..880544d5986 100644 --- a/.github/workflows/legacy-webhook-path.yml +++ b/.github/workflows/legacy-webhook-path.yml @@ -26,7 +26,7 @@ jobs: - name: Setup Go uses: actions/setup-go@v5 with: - go-version: '1.22.3' + go-version-file: go.mod - name: Run make test-legacy run: make test-legacy diff --git a/.github/workflows/lint-sample.yml b/.github/workflows/lint-sample.yml index 1a4a3753cdb..7ac928c9c2c 100644 --- a/.github/workflows/lint-sample.yml +++ b/.github/workflows/lint-sample.yml @@ -18,7 +18,7 @@ jobs: - name: Setup Go uses: actions/setup-go@v5 with: - go-version: '~1.22' + go-version-file: go.mod - name: Run linter uses: golangci/golangci-lint-action@v6 with: diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 76d9e378ab7..16664976e60 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -15,12 +15,12 @@ jobs: # Pull requests from the same repository won't trigger this checks as they were already triggered by the push if: (github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository) steps: + - name: Clone the code + uses: actions/checkout@v4 - name: Setup Go uses: actions/setup-go@v5 with: - go-version: '~1.22' - - name: Clone the code - uses: actions/checkout@v4 + go-version-file: go.mod - name: Run linter uses: golangci/golangci-lint-action@v6 with: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c6c6747a8af..924904f5034 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -21,7 +21,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v5 with: - go-version: '~1.22' + go-version-file: go.mod - name: Clean dist directory run: rm -rf dist || true - name: Install Syft to generate SBOMs diff --git a/.github/workflows/test-devcontainer.yaml b/.github/workflows/test-devcontainer.yaml index 0da5e603abb..2caaa31dee6 100644 --- a/.github/workflows/test-devcontainer.yaml +++ b/.github/workflows/test-devcontainer.yaml @@ -18,7 +18,7 @@ jobs: - name: Setup Go 1.22.x uses: actions/setup-go@v5 with: - go-version: "1.22.x" + go-version-file: go.mod - name: Setup NodeJS 20.x uses: actions/setup-node@v4 diff --git a/.github/workflows/test-e2e-book.yml b/.github/workflows/test-e2e-book.yml index 1264d9a7502..0dcc0000501 100644 --- a/.github/workflows/test-e2e-book.yml +++ b/.github/workflows/test-e2e-book.yml @@ -27,7 +27,7 @@ jobs: - name: Setup Go uses: actions/setup-go@v5 with: - go-version: '~1.22' + go-version-file: go.mod - name: Install the latest version of kind run: | @@ -57,7 +57,7 @@ jobs: - name: Setup Go uses: actions/setup-go@v5 with: - go-version: '~1.22' + go-version-file: go.mod - name: Install the latest version of kind run: | @@ -87,7 +87,7 @@ jobs: - name: Setup Go uses: actions/setup-go@v5 with: - go-version: '~1.22' + go-version-file: go.mod - name: Install the latest version of kind run: | diff --git a/.github/workflows/test-e2e-samples.yml b/.github/workflows/test-e2e-samples.yml index a25078f4388..1a73e9f6890 100644 --- a/.github/workflows/test-e2e-samples.yml +++ b/.github/workflows/test-e2e-samples.yml @@ -23,7 +23,7 @@ jobs: - name: Setup Go uses: actions/setup-go@v5 with: - go-version: '~1.22' + go-version-file: go.mod - name: Install the latest version of kind run: | @@ -62,7 +62,7 @@ jobs: - name: Setup Go uses: actions/setup-go@v5 with: - go-version: '~1.22' + go-version-file: go.mod - name: Install the latest version of kind run: | @@ -104,7 +104,7 @@ jobs: - name: Setup Go uses: actions/setup-go@v5 with: - go-version: '~1.22' + go-version-file: go.mod - name: Install the latest version of kind run: | diff --git a/.github/workflows/test-helm-samples.yml b/.github/workflows/test-helm-samples.yml index 3c468c46c79..42c4278cb7e 100644 --- a/.github/workflows/test-helm-samples.yml +++ b/.github/workflows/test-helm-samples.yml @@ -23,7 +23,7 @@ jobs: - name: Setup Go uses: actions/setup-go@v5 with: - go-version: "~1.22" + go-version-file: go.mod - name: Install the latest version of kind run: | diff --git a/.github/workflows/testdata.yml b/.github/workflows/testdata.yml index ef44c044656..b0fab3f57fb 100644 --- a/.github/workflows/testdata.yml +++ b/.github/workflows/testdata.yml @@ -17,7 +17,7 @@ jobs: - name: Setup Go uses: actions/setup-go@v5 with: - go-version: '1.22.3' + go-version-file: go.mod - name: Remove pre-installed kustomize # This step is needed as the following one tries to remove # kustomize for each test but has no permission to do so diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index 98e4795751c..4019916ab13 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -26,7 +26,7 @@ jobs: - name: Setup Go uses: actions/setup-go@v5 with: - go-version: '~1.22' + go-version-file: go.mod # This step is needed as the following one tries to remove # kustomize for each test but has no permission to do so - name: Remove pre-installed kustomize @@ -56,7 +56,7 @@ jobs: - name: Setup Go uses: actions/setup-go@v5 with: - go-version: "1.22" + go-version-file: go.mod - name: Generate the coverage output run: make test-coverage - name: Send the coverage output diff --git a/docs/book/src/cronjob-tutorial/testdata/project/.github/workflows/lint.yml b/docs/book/src/cronjob-tutorial/testdata/project/.github/workflows/lint.yml index f40d36579ce..8ae2879bfa9 100644 --- a/docs/book/src/cronjob-tutorial/testdata/project/.github/workflows/lint.yml +++ b/docs/book/src/cronjob-tutorial/testdata/project/.github/workflows/lint.yml @@ -15,7 +15,7 @@ jobs: - name: Setup Go uses: actions/setup-go@v5 with: - go-version: '~1.22' + go-version-file: go.mod - name: Run linter uses: golangci/golangci-lint-action@v6 diff --git a/docs/book/src/cronjob-tutorial/testdata/project/.github/workflows/test-e2e.yml b/docs/book/src/cronjob-tutorial/testdata/project/.github/workflows/test-e2e.yml index 8780644002a..b2eda8c3db0 100644 --- a/docs/book/src/cronjob-tutorial/testdata/project/.github/workflows/test-e2e.yml +++ b/docs/book/src/cronjob-tutorial/testdata/project/.github/workflows/test-e2e.yml @@ -15,7 +15,7 @@ jobs: - name: Setup Go uses: actions/setup-go@v5 with: - go-version: '~1.22' + go-version-file: go.mod - name: Install the latest version of kind run: | diff --git a/docs/book/src/cronjob-tutorial/testdata/project/.github/workflows/test.yml b/docs/book/src/cronjob-tutorial/testdata/project/.github/workflows/test.yml index 7baf6579399..fc2e80d304d 100644 --- a/docs/book/src/cronjob-tutorial/testdata/project/.github/workflows/test.yml +++ b/docs/book/src/cronjob-tutorial/testdata/project/.github/workflows/test.yml @@ -15,7 +15,7 @@ jobs: - name: Setup Go uses: actions/setup-go@v5 with: - go-version: '~1.22' + go-version-file: go.mod - name: Running Tests run: | diff --git a/docs/book/src/getting-started/testdata/project/.github/workflows/lint.yml b/docs/book/src/getting-started/testdata/project/.github/workflows/lint.yml index f40d36579ce..8ae2879bfa9 100644 --- a/docs/book/src/getting-started/testdata/project/.github/workflows/lint.yml +++ b/docs/book/src/getting-started/testdata/project/.github/workflows/lint.yml @@ -15,7 +15,7 @@ jobs: - name: Setup Go uses: actions/setup-go@v5 with: - go-version: '~1.22' + go-version-file: go.mod - name: Run linter uses: golangci/golangci-lint-action@v6 diff --git a/docs/book/src/getting-started/testdata/project/.github/workflows/test-e2e.yml b/docs/book/src/getting-started/testdata/project/.github/workflows/test-e2e.yml index 8780644002a..b2eda8c3db0 100644 --- a/docs/book/src/getting-started/testdata/project/.github/workflows/test-e2e.yml +++ b/docs/book/src/getting-started/testdata/project/.github/workflows/test-e2e.yml @@ -15,7 +15,7 @@ jobs: - name: Setup Go uses: actions/setup-go@v5 with: - go-version: '~1.22' + go-version-file: go.mod - name: Install the latest version of kind run: | diff --git a/docs/book/src/getting-started/testdata/project/.github/workflows/test.yml b/docs/book/src/getting-started/testdata/project/.github/workflows/test.yml index 7baf6579399..fc2e80d304d 100644 --- a/docs/book/src/getting-started/testdata/project/.github/workflows/test.yml +++ b/docs/book/src/getting-started/testdata/project/.github/workflows/test.yml @@ -15,7 +15,7 @@ jobs: - name: Setup Go uses: actions/setup-go@v5 with: - go-version: '~1.22' + go-version-file: go.mod - name: Running Tests run: | diff --git a/docs/book/src/multiversion-tutorial/testdata/project/.github/workflows/lint.yml b/docs/book/src/multiversion-tutorial/testdata/project/.github/workflows/lint.yml index f40d36579ce..8ae2879bfa9 100644 --- a/docs/book/src/multiversion-tutorial/testdata/project/.github/workflows/lint.yml +++ b/docs/book/src/multiversion-tutorial/testdata/project/.github/workflows/lint.yml @@ -15,7 +15,7 @@ jobs: - name: Setup Go uses: actions/setup-go@v5 with: - go-version: '~1.22' + go-version-file: go.mod - name: Run linter uses: golangci/golangci-lint-action@v6 diff --git a/docs/book/src/multiversion-tutorial/testdata/project/.github/workflows/test-e2e.yml b/docs/book/src/multiversion-tutorial/testdata/project/.github/workflows/test-e2e.yml index 8780644002a..b2eda8c3db0 100644 --- a/docs/book/src/multiversion-tutorial/testdata/project/.github/workflows/test-e2e.yml +++ b/docs/book/src/multiversion-tutorial/testdata/project/.github/workflows/test-e2e.yml @@ -15,7 +15,7 @@ jobs: - name: Setup Go uses: actions/setup-go@v5 with: - go-version: '~1.22' + go-version-file: go.mod - name: Install the latest version of kind run: | diff --git a/docs/book/src/multiversion-tutorial/testdata/project/.github/workflows/test.yml b/docs/book/src/multiversion-tutorial/testdata/project/.github/workflows/test.yml index 7baf6579399..fc2e80d304d 100644 --- a/docs/book/src/multiversion-tutorial/testdata/project/.github/workflows/test.yml +++ b/docs/book/src/multiversion-tutorial/testdata/project/.github/workflows/test.yml @@ -15,7 +15,7 @@ jobs: - name: Setup Go uses: actions/setup-go@v5 with: - go-version: '~1.22' + go-version-file: go.mod - name: Running Tests run: | diff --git a/go.mod b/go.mod index b2cadaf281b..76282b50606 100644 --- a/go.mod +++ b/go.mod @@ -1,8 +1,6 @@ module sigs.k8s.io/kubebuilder/v4 -go 1.22.0 - -toolchain go1.22.3 +go 1.22.3 require ( github.com/gobuffalo/flect v1.0.3 diff --git a/pkg/plugins/golang/v4/scaffolds/internal/templates/github/lint.go b/pkg/plugins/golang/v4/scaffolds/internal/templates/github/lint.go index 909d8a3278d..d6c629f3901 100644 --- a/pkg/plugins/golang/v4/scaffolds/internal/templates/github/lint.go +++ b/pkg/plugins/golang/v4/scaffolds/internal/templates/github/lint.go @@ -60,7 +60,7 @@ jobs: - name: Setup Go uses: actions/setup-go@v5 with: - go-version: '~1.22' + go-version-file: go.mod - name: Run linter uses: golangci/golangci-lint-action@v6 diff --git a/pkg/plugins/golang/v4/scaffolds/internal/templates/github/test-e2e.go b/pkg/plugins/golang/v4/scaffolds/internal/templates/github/test-e2e.go index f2a031a2742..e5620ec29f0 100644 --- a/pkg/plugins/golang/v4/scaffolds/internal/templates/github/test-e2e.go +++ b/pkg/plugins/golang/v4/scaffolds/internal/templates/github/test-e2e.go @@ -60,7 +60,7 @@ jobs: - name: Setup Go uses: actions/setup-go@v5 with: - go-version: '~1.22' + go-version-file: go.mod - name: Install the latest version of kind run: | diff --git a/pkg/plugins/golang/v4/scaffolds/internal/templates/github/test.go b/pkg/plugins/golang/v4/scaffolds/internal/templates/github/test.go index 8e1dfdf5fe3..8701bd8ffd9 100644 --- a/pkg/plugins/golang/v4/scaffolds/internal/templates/github/test.go +++ b/pkg/plugins/golang/v4/scaffolds/internal/templates/github/test.go @@ -60,7 +60,7 @@ jobs: - name: Setup Go uses: actions/setup-go@v5 with: - go-version: '~1.22' + go-version-file: go.mod - name: Running Tests run: | diff --git a/pkg/plugins/optional/helm/v1alpha/scaffolds/internal/templates/github/test_chart.go b/pkg/plugins/optional/helm/v1alpha/scaffolds/internal/templates/github/test_chart.go index 27e67118f55..86aac141813 100644 --- a/pkg/plugins/optional/helm/v1alpha/scaffolds/internal/templates/github/test_chart.go +++ b/pkg/plugins/optional/helm/v1alpha/scaffolds/internal/templates/github/test_chart.go @@ -61,7 +61,7 @@ jobs: - name: Setup Go uses: actions/setup-go@v5 with: - go-version: '~1.22' + go-version-file: go.mod - name: Install the latest version of kind run: | diff --git a/testdata/project-v4-multigroup/.github/workflows/lint.yml b/testdata/project-v4-multigroup/.github/workflows/lint.yml index f40d36579ce..8ae2879bfa9 100644 --- a/testdata/project-v4-multigroup/.github/workflows/lint.yml +++ b/testdata/project-v4-multigroup/.github/workflows/lint.yml @@ -15,7 +15,7 @@ jobs: - name: Setup Go uses: actions/setup-go@v5 with: - go-version: '~1.22' + go-version-file: go.mod - name: Run linter uses: golangci/golangci-lint-action@v6 diff --git a/testdata/project-v4-multigroup/.github/workflows/test-e2e.yml b/testdata/project-v4-multigroup/.github/workflows/test-e2e.yml index 8780644002a..b2eda8c3db0 100644 --- a/testdata/project-v4-multigroup/.github/workflows/test-e2e.yml +++ b/testdata/project-v4-multigroup/.github/workflows/test-e2e.yml @@ -15,7 +15,7 @@ jobs: - name: Setup Go uses: actions/setup-go@v5 with: - go-version: '~1.22' + go-version-file: go.mod - name: Install the latest version of kind run: | diff --git a/testdata/project-v4-multigroup/.github/workflows/test.yml b/testdata/project-v4-multigroup/.github/workflows/test.yml index 7baf6579399..fc2e80d304d 100644 --- a/testdata/project-v4-multigroup/.github/workflows/test.yml +++ b/testdata/project-v4-multigroup/.github/workflows/test.yml @@ -15,7 +15,7 @@ jobs: - name: Setup Go uses: actions/setup-go@v5 with: - go-version: '~1.22' + go-version-file: go.mod - name: Running Tests run: | diff --git a/testdata/project-v4-with-plugins/.github/workflows/lint.yml b/testdata/project-v4-with-plugins/.github/workflows/lint.yml index f40d36579ce..8ae2879bfa9 100644 --- a/testdata/project-v4-with-plugins/.github/workflows/lint.yml +++ b/testdata/project-v4-with-plugins/.github/workflows/lint.yml @@ -15,7 +15,7 @@ jobs: - name: Setup Go uses: actions/setup-go@v5 with: - go-version: '~1.22' + go-version-file: go.mod - name: Run linter uses: golangci/golangci-lint-action@v6 diff --git a/testdata/project-v4-with-plugins/.github/workflows/test-chart.yml b/testdata/project-v4-with-plugins/.github/workflows/test-chart.yml index bae16f7a169..89351bb29ae 100644 --- a/testdata/project-v4-with-plugins/.github/workflows/test-chart.yml +++ b/testdata/project-v4-with-plugins/.github/workflows/test-chart.yml @@ -15,7 +15,7 @@ jobs: - name: Setup Go uses: actions/setup-go@v5 with: - go-version: '~1.22' + go-version-file: go.mod - name: Install the latest version of kind run: | diff --git a/testdata/project-v4-with-plugins/.github/workflows/test-e2e.yml b/testdata/project-v4-with-plugins/.github/workflows/test-e2e.yml index 8780644002a..b2eda8c3db0 100644 --- a/testdata/project-v4-with-plugins/.github/workflows/test-e2e.yml +++ b/testdata/project-v4-with-plugins/.github/workflows/test-e2e.yml @@ -15,7 +15,7 @@ jobs: - name: Setup Go uses: actions/setup-go@v5 with: - go-version: '~1.22' + go-version-file: go.mod - name: Install the latest version of kind run: | diff --git a/testdata/project-v4-with-plugins/.github/workflows/test.yml b/testdata/project-v4-with-plugins/.github/workflows/test.yml index 7baf6579399..fc2e80d304d 100644 --- a/testdata/project-v4-with-plugins/.github/workflows/test.yml +++ b/testdata/project-v4-with-plugins/.github/workflows/test.yml @@ -15,7 +15,7 @@ jobs: - name: Setup Go uses: actions/setup-go@v5 with: - go-version: '~1.22' + go-version-file: go.mod - name: Running Tests run: | diff --git a/testdata/project-v4/.github/workflows/lint.yml b/testdata/project-v4/.github/workflows/lint.yml index f40d36579ce..8ae2879bfa9 100644 --- a/testdata/project-v4/.github/workflows/lint.yml +++ b/testdata/project-v4/.github/workflows/lint.yml @@ -15,7 +15,7 @@ jobs: - name: Setup Go uses: actions/setup-go@v5 with: - go-version: '~1.22' + go-version-file: go.mod - name: Run linter uses: golangci/golangci-lint-action@v6 diff --git a/testdata/project-v4/.github/workflows/test-e2e.yml b/testdata/project-v4/.github/workflows/test-e2e.yml index 8780644002a..b2eda8c3db0 100644 --- a/testdata/project-v4/.github/workflows/test-e2e.yml +++ b/testdata/project-v4/.github/workflows/test-e2e.yml @@ -15,7 +15,7 @@ jobs: - name: Setup Go uses: actions/setup-go@v5 with: - go-version: '~1.22' + go-version-file: go.mod - name: Install the latest version of kind run: | diff --git a/testdata/project-v4/.github/workflows/test.yml b/testdata/project-v4/.github/workflows/test.yml index 7baf6579399..fc2e80d304d 100644 --- a/testdata/project-v4/.github/workflows/test.yml +++ b/testdata/project-v4/.github/workflows/test.yml @@ -15,7 +15,7 @@ jobs: - name: Setup Go uses: actions/setup-go@v5 with: - go-version: '~1.22' + go-version-file: go.mod - name: Running Tests run: |