Skip to content

Commit 88f606f

Browse files
authored
Merge pull request #4444 from camilamacedo86/improve-sample-linter
🌱 (ci): Improve GitHub Action to linter samples under testdata
2 parents d16e6c3 + 318a6eb commit 88f606f

File tree

8 files changed

+37
-15
lines changed
  • .github/workflows
  • docs/book/src
    • cronjob-tutorial/testdata/project/cmd
    • getting-started/testdata/project/cmd
    • multiversion-tutorial/testdata/project/cmd
  • pkg/plugins/golang/v4/scaffolds/internal/templates/cmd
  • testdata

8 files changed

+37
-15
lines changed

.github/workflows/lint-sample.yml

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@ on:
1111
jobs:
1212
lint-samples:
1313
runs-on: ubuntu-latest
14+
strategy:
15+
matrix:
16+
folder: [
17+
"testdata/project-v4",
18+
"testdata/project-v4-with-plugins",
19+
"testdata/project-v4-multigroup"
20+
]
1421
if: (github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository)
1522
steps:
1623
- name: Clone the code
@@ -19,15 +26,16 @@ jobs:
1926
uses: actions/setup-go@v5
2027
with:
2128
go-version-file: go.mod
29+
- name: Prepare ${{ matrix.folder }}
30+
working-directory: ${{ matrix.folder }}
31+
run: go mod tidy
2232
- name: Run linter
2333
uses: golangci/golangci-lint-action@v6
2434
with:
25-
version: v1.59
26-
working-directory: testdata/project-v4
27-
args: --config .golangci.yml ./...
28-
- name: Run linter
29-
uses: golangci/golangci-lint-action@v6
30-
with:
31-
version: v1.59
32-
working-directory: testdata/project-v4-with-plugins
35+
version: v1.61.0
36+
working-directory: ${{ matrix.folder }}
3337
args: --config .golangci.yml ./...
38+
- name: Run linter via makefile target
39+
working-directory: ${{ matrix.folder }}
40+
run: make lint
41+

docs/book/src/cronjob-tutorial/testdata/project/cmd/main.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ The other thing that's changed is that kubebuilder has added a block calling our
7272
CronJob controller's `SetupWithManager` method.
7373
*/
7474

75+
// nolint:gocyclo
7576
func main() {
7677
/*
7778
*/
@@ -94,7 +95,8 @@ func main() {
9495
flag.StringVar(&webhookCertPath, "webhook-cert-path", "", "The directory that contains the webhook certificate.")
9596
flag.StringVar(&webhookCertName, "webhook-cert-name", "tls.crt", "The name of the webhook certificate file.")
9697
flag.StringVar(&webhookCertKey, "webhook-cert-key", "tls.key", "The name of the webhook key file.")
97-
flag.StringVar(&metricsCertPath, "metrics-cert-path", "", "The directory that contains the metrics server certificate.")
98+
flag.StringVar(&metricsCertPath, "metrics-cert-path", "",
99+
"The directory that contains the metrics server certificate.")
98100
flag.StringVar(&metricsCertName, "metrics-cert-name", "tls.crt", "The name of the metrics server certificate file.")
99101
flag.StringVar(&metricsCertKey, "metrics-cert-key", "tls.key", "The name of the metrics server key file.")
100102
flag.BoolVar(&enableHTTP2, "enable-http2", false,

docs/book/src/getting-started/testdata/project/cmd/main.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ func init() {
5454
// +kubebuilder:scaffold:scheme
5555
}
5656

57+
// nolint:gocyclo
5758
func main() {
5859
var metricsAddr string
5960
var metricsCertPath, metricsCertName, metricsCertKey string
@@ -74,7 +75,8 @@ func main() {
7475
flag.StringVar(&webhookCertPath, "webhook-cert-path", "", "The directory that contains the webhook certificate.")
7576
flag.StringVar(&webhookCertName, "webhook-cert-name", "tls.crt", "The name of the webhook certificate file.")
7677
flag.StringVar(&webhookCertKey, "webhook-cert-key", "tls.key", "The name of the webhook key file.")
77-
flag.StringVar(&metricsCertPath, "metrics-cert-path", "", "The directory that contains the metrics server certificate.")
78+
flag.StringVar(&metricsCertPath, "metrics-cert-path", "",
79+
"The directory that contains the metrics server certificate.")
7880
flag.StringVar(&metricsCertName, "metrics-cert-name", "tls.crt", "The name of the metrics server certificate file.")
7981
flag.StringVar(&metricsCertKey, "metrics-cert-key", "tls.key", "The name of the metrics server key file.")
8082
flag.BoolVar(&enableHTTP2, "enable-http2", false,

docs/book/src/multiversion-tutorial/testdata/project/cmd/main.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ func init() {
7171
/*
7272
*/
7373

74+
// nolint:gocyclo
7475
func main() {
7576
/*
7677
*/
@@ -93,7 +94,8 @@ func main() {
9394
flag.StringVar(&webhookCertPath, "webhook-cert-path", "", "The directory that contains the webhook certificate.")
9495
flag.StringVar(&webhookCertName, "webhook-cert-name", "tls.crt", "The name of the webhook certificate file.")
9596
flag.StringVar(&webhookCertKey, "webhook-cert-key", "tls.key", "The name of the webhook key file.")
96-
flag.StringVar(&metricsCertPath, "metrics-cert-path", "", "The directory that contains the metrics server certificate.")
97+
flag.StringVar(&metricsCertPath, "metrics-cert-path", "",
98+
"The directory that contains the metrics server certificate.")
9799
flag.StringVar(&metricsCertName, "metrics-cert-name", "tls.crt", "The name of the metrics server certificate file.")
98100
flag.StringVar(&metricsCertKey, "metrics-cert-key", "tls.key", "The name of the metrics server key file.")
99101
flag.BoolVar(&enableHTTP2, "enable-http2", false,

pkg/plugins/golang/v4/scaffolds/internal/templates/cmd/main.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ func init() {
256256
%s
257257
}
258258
259+
// nolint:gocyclo
259260
func main() {
260261
var metricsAddr string
261262
var metricsCertPath, metricsCertName, metricsCertKey string
@@ -276,7 +277,8 @@ func main() {
276277
flag.StringVar(&webhookCertPath, "webhook-cert-path", "", "The directory that contains the webhook certificate.")
277278
flag.StringVar(&webhookCertName, "webhook-cert-name", "tls.crt", "The name of the webhook certificate file.")
278279
flag.StringVar(&webhookCertKey, "webhook-cert-key", "tls.key", "The name of the webhook key file.")
279-
flag.StringVar(&metricsCertPath, "metrics-cert-path", "", "The directory that contains the metrics server certificate.")
280+
flag.StringVar(&metricsCertPath, "metrics-cert-path", "",
281+
"The directory that contains the metrics server certificate.")
280282
flag.StringVar(&metricsCertName, "metrics-cert-name", "tls.crt", "The name of the metrics server certificate file.")
281283
flag.StringVar(&metricsCertKey, "metrics-cert-key", "tls.key", "The name of the metrics server key file.")
282284
flag.BoolVar(&enableHTTP2, "enable-http2", false,

testdata/project-v4-multigroup/cmd/main.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ func init() {
9595
// +kubebuilder:scaffold:scheme
9696
}
9797

98+
// nolint:gocyclo
9899
func main() {
99100
var metricsAddr string
100101
var metricsCertPath, metricsCertName, metricsCertKey string
@@ -115,7 +116,8 @@ func main() {
115116
flag.StringVar(&webhookCertPath, "webhook-cert-path", "", "The directory that contains the webhook certificate.")
116117
flag.StringVar(&webhookCertName, "webhook-cert-name", "tls.crt", "The name of the webhook certificate file.")
117118
flag.StringVar(&webhookCertKey, "webhook-cert-key", "tls.key", "The name of the webhook key file.")
118-
flag.StringVar(&metricsCertPath, "metrics-cert-path", "", "The directory that contains the metrics server certificate.")
119+
flag.StringVar(&metricsCertPath, "metrics-cert-path", "",
120+
"The directory that contains the metrics server certificate.")
119121
flag.StringVar(&metricsCertName, "metrics-cert-name", "tls.crt", "The name of the metrics server certificate file.")
120122
flag.StringVar(&metricsCertKey, "metrics-cert-key", "tls.key", "The name of the metrics server key file.")
121123
flag.BoolVar(&enableHTTP2, "enable-http2", false,

testdata/project-v4-with-plugins/cmd/main.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ func init() {
6060
// +kubebuilder:scaffold:scheme
6161
}
6262

63+
// nolint:gocyclo
6364
func main() {
6465
var metricsAddr string
6566
var metricsCertPath, metricsCertName, metricsCertKey string
@@ -80,7 +81,8 @@ func main() {
8081
flag.StringVar(&webhookCertPath, "webhook-cert-path", "", "The directory that contains the webhook certificate.")
8182
flag.StringVar(&webhookCertName, "webhook-cert-name", "tls.crt", "The name of the webhook certificate file.")
8283
flag.StringVar(&webhookCertKey, "webhook-cert-key", "tls.key", "The name of the webhook key file.")
83-
flag.StringVar(&metricsCertPath, "metrics-cert-path", "", "The directory that contains the metrics server certificate.")
84+
flag.StringVar(&metricsCertPath, "metrics-cert-path", "",
85+
"The directory that contains the metrics server certificate.")
8486
flag.StringVar(&metricsCertName, "metrics-cert-name", "tls.crt", "The name of the metrics server certificate file.")
8587
flag.StringVar(&metricsCertKey, "metrics-cert-key", "tls.key", "The name of the metrics server key file.")
8688
flag.BoolVar(&enableHTTP2, "enable-http2", false,

testdata/project-v4/cmd/main.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ func init() {
6363
// +kubebuilder:scaffold:scheme
6464
}
6565

66+
// nolint:gocyclo
6667
func main() {
6768
var metricsAddr string
6869
var metricsCertPath, metricsCertName, metricsCertKey string
@@ -83,7 +84,8 @@ func main() {
8384
flag.StringVar(&webhookCertPath, "webhook-cert-path", "", "The directory that contains the webhook certificate.")
8485
flag.StringVar(&webhookCertName, "webhook-cert-name", "tls.crt", "The name of the webhook certificate file.")
8586
flag.StringVar(&webhookCertKey, "webhook-cert-key", "tls.key", "The name of the webhook key file.")
86-
flag.StringVar(&metricsCertPath, "metrics-cert-path", "", "The directory that contains the metrics server certificate.")
87+
flag.StringVar(&metricsCertPath, "metrics-cert-path", "",
88+
"The directory that contains the metrics server certificate.")
8789
flag.StringVar(&metricsCertName, "metrics-cert-name", "tls.crt", "The name of the metrics server certificate file.")
8890
flag.StringVar(&metricsCertKey, "metrics-cert-key", "tls.key", "The name of the metrics server key file.")
8991
flag.BoolVar(&enableHTTP2, "enable-http2", false,

0 commit comments

Comments
 (0)