File tree Expand file tree Collapse file tree 19 files changed +161
-38
lines changed Expand file tree Collapse file tree 19 files changed +161
-38
lines changed Original file line number Diff line number Diff line change 1515 - name : Set up Go
1616 uses : actions/setup-go@v2
1717 with :
18- go-version : 1.19
18+ go-version-file : ' go.mod '
1919 - name : Run GoReleaser
2020 uses : goreleaser/goreleaser-action@v2
2121 with :
Original file line number Diff line number Diff line change @@ -10,10 +10,10 @@ jobs:
1010 runs-on : ubuntu-latest
1111 steps :
1212
13- - name : Set up Go 1.19
14- uses : actions/setup-go@v1
13+ - name : Set up Go
14+ uses : actions/setup-go@v4
1515 with :
16- go-version : 1.19
16+ go-version-file : ' go.mod '
1717 id : go
1818
1919 - name : Check out code into the Go module directory
Original file line number Diff line number Diff line change @@ -15,10 +15,10 @@ jobs:
1515 uses : actions/checkout@v2
1616 - name : Downloading required packages
1717 run : sudo apt-get install bats
18- - name : Set up Go 1.19
19- uses : actions/setup-go@v1
18+ - name : Set up Go
19+ uses : actions/setup-go@v4
2020 with :
21- go-version : 1.19
21+ go-version-file : ' go.mod '
2222 - run : make e2e
2323 env :
2424 HAPROXY_VERSION : ${{ matrix.haproxy_version }}
Original file line number Diff line number Diff line change 44 branches :
55 - master
66jobs :
7+ gofumpt :
8+ name : gofumpt
9+ runs-on : ubuntu-latest
10+ steps :
11+ - name : Check out code
12+ uses : actions/checkout@v3
13+ - name : Set up Go
14+ uses : actions/setup-go@v4
15+ with :
16+ go-version-file : ' go.mod'
17+ - uses : actions/cache@v3
18+ with :
19+ path : |
20+ ~/.cache/go-build
21+ ~/go/pkg/mod
22+ key : ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
23+ restore-keys : |
24+ ${{ runner.os }}-go-
25+ - name : tidy
26+ run : make gofumpt
27+ - name : changes
28+ run : test -z "$(git diff 2> /dev/null)" || exit "Go code not formatted, issue \`make gofumpt\` and commit the result"
729 golangci-lint :
830 name : runner / golangci-lint
931 runs-on : ubuntu-latest
1335 - name : golangci-lint
1436 uses : reviewdog/action-golangci-lint@v1
1537 with :
16- github_token : ${{ secrets.github_token }}
38+ go-version-file : ' go.mod'
39+ - uses : actions/cache@v3
40+ with :
41+ path : |
42+ ~/.cache/go-build
43+ ~/go/pkg/mod
44+ key : ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
45+ restore-keys : |
46+ ${{ runner.os }}-go-
47+ - name : Lint
48+ run : |
49+ make lint
Original file line number Diff line number Diff line change @@ -6,11 +6,12 @@ variables:
66 DOCKER_HOST : tcp://docker:2375
77 DOCKER_BASE_IMAGE : $CI_REGISTRY_GO/haproxy-alpine
88 BATS_VERSION : v1.4.1
9+ GO_VERSION : ' 1.21'
910
1011diff :
1112 stage : lint
1213 image :
13- name : $CI_REGISTRY_GO/docker:stable-go1.19
14+ name : $CI_REGISTRY_GO/docker:stable-go$GO_VERSION
1415 entrypoint : [ "" ]
1516 services :
1617 - name : $CI_REGISTRY_GO/docker:20.10.5-dind
@@ -34,16 +35,28 @@ golangci-lint:
3435 paths :
3536 - build
3637 image :
37- name : $CI_REGISTRY_GO/lint:1.46.2
38+ name : $CI_REGISTRY_GO/golang:$GO_VERSION
3839 entrypoint : [""]
3940 tags :
4041 - go
4142 script :
42- - golangci-lint cache clean && go clean -modcache -cache -i
43- - golangci-lint run --timeout 5m --color always --max-issues-per-linter 0 --max-same-issues 0
44- only :
45- - merge_requests
46- - branches
43+ - make lint
44+ rules :
45+ - if : $CI_PIPELINE_SOURCE == 'merge_request_event'
46+ - if : $CI_PIPELINE_SOURCE == 'push'
47+ gofumpt :
48+ stage : lint
49+ rules :
50+ - if : $CI_PIPELINE_SOURCE == 'merge_request_event'
51+ - if : $CI_PIPELINE_SOURCE == 'push'
52+ image :
53+ name : $CI_REGISTRY_GO/golang:$GO_VERSION
54+ entrypoint : [""]
55+ tags :
56+ - go
57+ script :
58+ - make gofumpt
59+ - test -z "$(git diff 2> /dev/null)" || exit 'Go code not formatted, issue \`make gofumpt\` and commit the result'
4760lint-commit-msg :
4861 stage : lint
4962 image :
6275 paths :
6376 - build
6477 image :
65- name : $CI_REGISTRY_GO/golang:1.19
78+ name : $CI_REGISTRY_GO/golang:$GO_VERSION
6679 entrypoint : [ "" ]
6780 tags :
6881 - go
Original file line number Diff line number Diff line change @@ -12,21 +12,72 @@ linters-settings:
1212 goconst :
1313 min-len : 2
1414 min-occurrences : 2
15-
15+ revive :
16+ rules :
17+ - name : var-naming
18+ severity : warning
19+ disabled : true
1620linters :
17- enable :
18- - golint
19- - gocritic
20- - stylecheck
21- - goimports
22- - gosec
23- - unconvert
21+ enable-all : true
2422 disable :
25- - maligned
26- - prealloc
23+ - dupl
24+ - exhaustive
25+ - exhaustivestruct
26+ - funlen
27+ - gci
2728 - gochecknoglobals
29+ - gocognit
30+ - goconst
31+ - gocyclo
32+ - godot
33+ - goerr113
34+ - gomnd
35+ - lll
36+ - nestif
37+ - nlreturn
38+ - wrapcheck
39+ - wsl
40+ - nakedret
41+ - paralleltest
42+ - testpackage
43+ - varnamelen
44+ - nosnakecase
45+ - exhaustruct
46+ - nonamedreturns
47+ - forcetypeassert
48+ - golint # deprecated
49+ - varcheck # deprecated
50+ - ifshort # deprecated
51+ - structcheck # deprecated
52+ - maligned # deprecated
53+ - scopelint # deprecated
54+ - interfacer # deprecated
55+ - deadcode # deprecated
56+ - rowserrcheck # rowserrcheck is disabled because of generics
57+ - sqlclosecheck # rowserrcheck is disabled because of generics
58+ - wastedassign # rowserrcheck is disabled because of generics
59+ - ireturn
60+ - tagliatelle
61+ - noctx
62+ - errorlint
63+ - contextcheck
64+ - godox
65+ - containedctx
66+ - unused
67+ - unparam
68+ - prealloc
69+ - forbidigo
70+ - errcheck
71+ - gocritic
72+ - tagalign
73+ - depguard
2874
2975issues :
76+ exclude :
77+ # bugs of typecheck linter
78+ - " undeclared name: `shellquote`"
79+ - " github.com/kballard/go-shellquote\" imported but not used"
80+ - " github.com/haproxytech/config-parser/v5/types\" imported but not used"
3081 exclude-rules :
3182 - linters :
3283 - staticcheck
Original file line number Diff line number Diff line change @@ -9,12 +9,23 @@ GIT_MODIFIED=${GIT_MODIFIED1}${GIT_MODIFIED2}
99SWAGGER_VERSION =${shell curl -s https://raw.githubusercontent.com/haproxytech/client-native/master/Makefile | grep SWAGGER_VERSION -m 1 | awk -F"=" '{print $$2}'}
1010BUILD_DATE =$(shell date -u '+% Y-% m-% dT% H:% M:% SZ')
1111CGO_ENABLED? =0
12+ GOLANGCI_LINT_VERSION =1.54.2
1213
1314all : update clean build
1415
1516update :
1617 go mod tidy
1718
19+ .PHONY : lint
20+ lint :
21+ cd bin; GOLANGCI_LINT_VERSION=${GOLANGCI_LINT_VERSION} sh lint-check.sh
22+ bin/golangci-lint run --timeout 5m --color always --max-issues-per-linter 0 --max-same-issues 0
23+
24+ .PHONY : gofumpt
25+ gofumpt :
26+ go install mvdan.cc/gofumpt@latest
27+ gofumpt -l -w .
28+
1829clean :
1930 rm -rf ${DATAPLANEAPI_PATH} /build
2031
Original file line number Diff line number Diff line change 99
1010## Building the Data Plane API
1111
12- In order to build the Data Plane API you need go 1.19 installed on your system with go modules support enabled, and execute the following steps:
12+ In order to build the Data Plane API you need Go installed on your system with go modules support enabled, and execute the following steps:
1313
14141\. Clone dataplaneapi repository
1515
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
Original file line number Diff line number Diff line change 44// you may not use this file except in compliance with the License.
55// You may obtain a copy of the License at
66//
7- // http://www.apache.org/licenses/LICENSE-2.0
7+ // http://www.apache.org/licenses/LICENSE-2.0
88//
99// Unless required by applicable law or agreed to in writing, software
1010// distributed under the License is distributed on an "AS IS" BASIS,
1111// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212// See the License for the specific language governing permissions and
1313// limitations under the License.
14- //
1514package main
1615
1716import (
You can’t perform that action at this time.
0 commit comments