File tree Expand file tree Collapse file tree 6 files changed +77
-13
lines changed Expand file tree Collapse file tree 6 files changed +77
-13
lines changed Original file line number Diff line number Diff line change @@ -51,13 +51,39 @@ jobs:
51
51
run : go mod tidy
52
52
- name : changes
53
53
run : test -z "$(git diff 2> /dev/null)" || exit "Go modules not tidied, issue \`go mod tidy\` and commit the result"
54
+ gofumpt :
55
+ name : gofumpt
56
+ runs-on : ubuntu-latest
57
+ steps :
58
+ - name : Check out code
59
+ uses : actions/checkout@v2
60
+ - name : Set up Go
61
+ uses : actions/setup-go@v2
62
+ with :
63
+ go-version : 1.19
64
+ - uses : actions/cache@v2
65
+ with :
66
+ path : |
67
+ ~/.cache/go-build
68
+ ~/go/pkg/mod
69
+ key : ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
70
+ restore-keys : |
71
+ ${{ runner.os }}-go-
72
+ - name : tidy
73
+ run : make gofumpt
74
+ - name : changes
75
+ run : test -z "$(git diff 2> /dev/null)" || exit "Go code not formatted, issue \`make gofumpt\` and commit the result"
54
76
lint :
55
77
name : golangci-lint
56
78
needs : ["generate", "tidy"]
57
79
runs-on : ubuntu-latest
58
80
steps :
59
81
- name : Check out code into the Go module directory
60
82
uses : actions/checkout@v2
83
+ - name : Set up Go
84
+ uses : actions/setup-go@v2
85
+ with :
86
+ go-version : 1.19
61
87
- uses : actions/cache@v2
62
88
with :
63
89
path : |
66
92
key : ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
67
93
restore-keys : |
68
94
${{ runner.os }}-go-
69
- - name : golangci-lint
70
- uses : docker://ghcr.io/haproxytech/go-linter:1.50.0
71
- with :
72
- args : --timeout 5m
95
+ - name : Lint
96
+ run : |
97
+ make lint
73
98
build :
74
99
name : build
75
100
runs-on : ubuntu-latest
Original file line number Diff line number Diff line change 3
3
kubernetes-ingress
4
4
dist /
5
5
.code-generator /
6
+ bin /golangci-lint
Original file line number Diff line number Diff line change @@ -45,19 +45,33 @@ tidy:
45
45
script :
46
46
- go mod tidy
47
47
- test -z "$(git diff 2> /dev/null)" || exit 'Go modules not tidied, issue \`go mod tidy\` and commit the result'
48
+ gofumpt :
49
+ stage : lint
50
+ needs : []
51
+ rules :
52
+ - if : $CI_PIPELINE_SOURCE == 'merge_request_event'
53
+ - if : $CI_PIPELINE_SOURCE == 'push'
54
+ image :
55
+ name : $CI_REGISTRY_GO/golang:1.19
56
+ entrypoint : [""]
57
+ tags :
58
+ - go
59
+ script :
60
+ - make gofumpt
61
+ - test -z "$(git diff 2> /dev/null)" || exit 'Go code not formatted, issue \`make gofumpt\` and commit the result'
48
62
golangci_lint :
49
63
stage : lint
50
64
needs : []
51
65
rules :
52
66
- if : $CI_PIPELINE_SOURCE == 'merge_request_event'
53
67
- if : $CI_PIPELINE_SOURCE == 'push'
54
68
image :
55
- name : $CI_REGISTRY_GO/lint :1.50.0
69
+ name : $CI_REGISTRY_GO/golang :1.19
56
70
entrypoint : [""]
57
71
tags :
58
72
- go
59
73
script :
60
- - golangci-lint run --enable-all --timeout=10m
74
+ - make lint
61
75
lint-commit-msg :
62
76
stage : lint
63
77
needs : []
@@ -192,7 +206,6 @@ docker-build-sch:
192
206
parallel :
193
207
matrix :
194
208
- TEST_PART : [ "18#e2e_parallel", "18#e2e_https", "1#e2e_sequential" ]
195
- VAR_DUMMY : " YES"
196
209
script :
197
210
- CI_ENV=gitlab deploy/tests/create.sh
198
211
- kubectl get pods -A
Original file line number Diff line number Diff line change @@ -14,7 +14,6 @@ linters-settings:
14
14
- name : var-naming
15
15
severity : warning
16
16
disabled : true
17
-
18
17
linters :
19
18
enable-all : true
20
19
disable :
@@ -29,7 +28,6 @@ linters:
29
28
- gocyclo
30
29
- godot
31
30
- goerr113
32
- - gofumpt
33
31
- gomnd
34
32
- lll
35
33
- nestif
@@ -39,9 +37,19 @@ linters:
39
37
- nakedret
40
38
- paralleltest
41
39
- testpackage
42
- - nonamedreturns
43
- - nosnakecase
44
40
- varnamelen
45
- - staticcheck
41
+ - nosnakecase
46
42
- exhaustruct
43
+ - nonamedreturns
47
44
- forcetypeassert
45
+ - golint # deprecated
46
+ - varcheck # deprecated
47
+ - ifshort # deprecated
48
+ - structcheck # deprecated
49
+ - maligned # deprecated
50
+ - scopelint # deprecated
51
+ - interfacer # deprecated
52
+ - deadcode # deprecated
53
+ - rowserrcheck # rowserrcheck is disabled because of generics
54
+ - sqlclosecheck # rowserrcheck is disabled because of generics
55
+ - wastedassign # rowserrcheck is disabled because of generics
Original file line number Diff line number Diff line change 1
1
PROJECT_PATH =${PWD}
2
2
TARGETPLATFORM? =linux/amd64
3
+ GOLANGCI_LINT_VERSION =1.50.1
3
4
4
5
.PHONY : test
5
6
test :
21
22
22
23
.PHONY : lint
23
24
lint :
25
+ cd bin; GOLANGCI_LINT_VERSION=${GOLANGCI_LINT_VERSION} sh lint-check.sh
26
+ bin/golangci-lint run --timeout 5m --color always --max-issues-per-linter 0 --max-same-issues 0
27
+
28
+ .PHONY : yaml-lint
29
+ yaml-lint :
24
30
docker run --rm -v $(pwd ) :/data cytopia/yamllint .
25
- docker run --rm -v ${PROJECT_PATH} :/app -w /app ghcr.io/haproxytech/go-linter:1.50.0 -v --timeout 5m --color always --max-issues-per-linter 0 --max-same-issues 0
26
31
27
32
.PHONY : example
28
33
example :
@@ -49,3 +54,8 @@ cr_generate:
49
54
crs/code-generator.sh
50
55
grep -lir defaultses crs/* | xargs sed -i ' s/Defaultses/Defaults/g'
51
56
grep -lir defaultses crs/* | xargs sed -i ' s/defaultses/defaults/g'
57
+
58
+ .PHONY : gofumpt
59
+ gofumpt :
60
+ go install mvdan.cc/gofumpt@latest
61
+ gofumpt -l -w .
Original file line number Diff line number Diff line change
1
+ #! /bin/sh
2
+ V=$( ./golangci-lint --version)
3
+
4
+ case " $V " in
5
+ * $GOLANGCI_LINT_VERSION * ) echo " $V " ;;
6
+ * ) curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $( pwd) " v$GOLANGCI_LINT_VERSION " ;;
7
+ esac
You can’t perform that action at this time.
0 commit comments