Skip to content

Commit afbacb2

Browse files
authored
Merge pull request #4432 from mateusoliveira43/fix/use-same-golangci-lint-version
🌱 : Ensure that golangci-lint CI version is passed for the templates
2 parents e54dabf + 33024c9 commit afbacb2

File tree

9 files changed

+19
-9
lines changed
  • docs/book/src
    • cronjob-tutorial/testdata/project/.github/workflows
    • getting-started/testdata/project/.github/workflows
    • multiversion-tutorial/testdata/project/.github/workflows
  • pkg/plugins/golang/v4/scaffolds
  • testdata
    • project-v4-multigroup/.github/workflows
    • project-v4-with-plugins/.github/workflows
    • project-v4/.github/workflows

9 files changed

+19
-9
lines changed

docs/book/src/cronjob-tutorial/testdata/project/.github/workflows/lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ jobs:
2020
- name: Run linter
2121
uses: golangci/golangci-lint-action@v6
2222
with:
23-
version: v1.61
23+
version: v1.61.0

docs/book/src/getting-started/testdata/project/.github/workflows/lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ jobs:
2020
- name: Run linter
2121
uses: golangci/golangci-lint-action@v6
2222
with:
23-
version: v1.61
23+
version: v1.61.0

docs/book/src/multiversion-tutorial/testdata/project/.github/workflows/lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ jobs:
2020
- name: Run linter
2121
uses: golangci/golangci-lint-action@v6
2222
with:
23-
version: v1.61
23+
version: v1.61.0

pkg/plugins/golang/v4/scaffolds/init.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ import (
3636
)
3737

3838
const (
39+
// GolangciLintVersion is the golangci-lint version to be used in the project
40+
GolangciLintVersion = "v1.61.0"
3941
// ControllerRuntimeVersion is the kubernetes-sigs/controller-runtime version to be used in the project
4042
ControllerRuntimeVersion = "v0.19.1"
4143
// ControllerToolsVersion is the kubernetes-sigs/controller-tools version to be used in the project
@@ -154,6 +156,7 @@ func (s *initScaffolder) Scaffold() error {
154156
BoilerplatePath: s.boilerplatePath,
155157
ControllerToolsVersion: ControllerToolsVersion,
156158
KustomizeVersion: kustomizeVersion,
159+
GolangciLintVersion: GolangciLintVersion,
157160
ControllerRuntimeVersion: ControllerRuntimeVersion,
158161
EnvtestVersion: getControllerRuntimeReleaseBranch(),
159162
},
@@ -166,7 +169,9 @@ func (s *initScaffolder) Scaffold() error {
166169
&e2e.SuiteTest{},
167170
&github.E2eTestCi{},
168171
&github.TestCi{},
169-
&github.LintCi{},
172+
&github.LintCi{
173+
GolangciLintVersion: GolangciLintVersion,
174+
},
170175
&utils.Utils{},
171176
&templates.DevContainer{},
172177
&templates.DevContainerPostInstallScript{},

pkg/plugins/golang/v4/scaffolds/internal/templates/github/lint.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ var _ machinery.Template = &TestCi{}
2828
type LintCi struct {
2929
machinery.TemplateMixin
3030
machinery.BoilerplateMixin
31+
32+
// golangci-lint version to use in the project
33+
GolangciLintVersion string
3134
}
3235

3336
// SetTemplateDefaults implements machinery.Template
@@ -65,5 +68,5 @@ jobs:
6568
- name: Run linter
6669
uses: golangci/golangci-lint-action@v6
6770
with:
68-
version: v1.61
71+
version: {{ .GolangciLintVersion }}
6972
`

pkg/plugins/golang/v4/scaffolds/internal/templates/makefile.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ type Makefile struct {
3535
ControllerToolsVersion string
3636
// Kustomize version to use in the project
3737
KustomizeVersion string
38+
// golangci-lint version to use in the project
39+
GolangciLintVersion string
3840
// ControllerRuntimeVersion version to be used to download the envtest setup script
3941
ControllerRuntimeVersion string
4042
// EnvtestVersion store the name of the verions to be used to install setup-envtest
@@ -251,7 +253,7 @@ CONTROLLER_TOOLS_VERSION ?= {{ .ControllerToolsVersion }}
251253
ENVTEST_VERSION ?= $(shell go list -m -f "{{ "{{ .Version }}" }}" sigs.k8s.io/controller-runtime | awk -F'[v.]' '{printf "release-%d.%d", $$2, $$3}')
252254
#ENVTEST_K8S_VERSION is the version of Kubernetes to use for setting up ENVTEST binaries (i.e. 1.31)
253255
ENVTEST_K8S_VERSION ?= $(shell go list -m -f "{{ "{{ .Version }}" }}" k8s.io/api | awk -F'[v.]' '{printf "1.%d", $$3}')
254-
GOLANGCI_LINT_VERSION ?= v1.61.0
256+
GOLANGCI_LINT_VERSION ?= {{ .GolangciLintVersion }}
255257
256258
.PHONY: kustomize
257259
kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary.

testdata/project-v4-multigroup/.github/workflows/lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ jobs:
2020
- name: Run linter
2121
uses: golangci/golangci-lint-action@v6
2222
with:
23-
version: v1.61
23+
version: v1.61.0

testdata/project-v4-with-plugins/.github/workflows/lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ jobs:
2020
- name: Run linter
2121
uses: golangci/golangci-lint-action@v6
2222
with:
23-
version: v1.61
23+
version: v1.61.0

testdata/project-v4/.github/workflows/lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ jobs:
2020
- name: Run linter
2121
uses: golangci/golangci-lint-action@v6
2222
with:
23-
version: v1.61
23+
version: v1.61.0

0 commit comments

Comments
 (0)