Skip to content
This repository was archived by the owner on Sep 1, 2025. It is now read-only.

Commit a78d720

Browse files
committed
BUILD/MEDIUM: ci: add local linter, increase Go version to 1.20
1 parent 9b1a280 commit a78d720

10 files changed

Lines changed: 55 additions & 32 deletions

File tree

.github/workflows/actions.yml

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
- name: Set up Go
2020
uses: actions/setup-go@v2
2121
with:
22-
go-version: 1.19
22+
go-version: 1.20
2323
- name: Generating the files
2424
run: |
2525
make generate
@@ -33,8 +33,21 @@ jobs:
3333
steps:
3434
- name: Check out code into the Go module directory
3535
uses: actions/checkout@v2
36-
- name: golangci-lint
37-
uses: docker://ghcr.io/haproxytech/go-linter:1.50.0
36+
- name: Set up Go
37+
uses: actions/setup-go@v2
38+
with:
39+
go-version: 1.20
40+
- uses: actions/cache@v2
41+
with:
42+
path: |
43+
~/.cache/go-build
44+
~/go/pkg/mod
45+
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
46+
restore-keys: |
47+
${{ runner.os }}-go-
48+
- name: Lint
49+
run: |
50+
make lint
3851
tidy:
3952
name: go mod tidy
4053
needs: ["generate"]
@@ -45,7 +58,7 @@ jobs:
4558
- name: Set up Go
4659
uses: actions/setup-go@v2
4760
with:
48-
go-version: 1.19
61+
go-version: 1.20
4962
- name: tidy
5063
run: go mod tidy
5164
- name: changes
@@ -55,10 +68,10 @@ jobs:
5568
needs: ["lint","tidy"]
5669
runs-on: ubuntu-latest
5770
steps:
58-
- name: Set up Go 1.19
71+
- name: Set up Go 1.20
5972
uses: actions/setup-go@v1
6073
with:
61-
go-version: 1.19
74+
go-version: 1.20
6275
id: go
6376
- name: Check out code into the Go module directory
6477
uses: actions/checkout@v2

.gitlab-ci.yml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1+
variables:
2+
GO_VERSION: "1.20"
13
stages:
24
- diff
35
- lint
46
- test
57
diff:
68
stage: diff
79
image:
8-
name: $CI_REGISTRY_GO/golang:1.19
10+
name: $CI_REGISTRY_GO/golang:$GO_VERSION
911
entrypoint: [""]
1012
tags:
1113
- go
@@ -17,15 +19,15 @@ diff:
1719
rules:
1820
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
1921
- if: $CI_PIPELINE_SOURCE == 'push'
20-
golangci_lint:
22+
lint:
2123
stage: lint
2224
image:
23-
name: $CI_REGISTRY_GO/lint:1.50.0
25+
name: $CI_REGISTRY_GO/golang:$GO_VERSION
2426
entrypoint: [""]
2527
tags:
2628
- go
2729
script:
28-
- golangci-lint run --enable-all
30+
- make lint
2931
rules:
3032
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
3133
- if: $CI_PIPELINE_SOURCE == 'push'
@@ -43,7 +45,7 @@ lint-commit-msg:
4345
tidy:
4446
stage: lint
4547
image:
46-
name: $CI_REGISTRY_GO/golang:1.19
48+
name: $CI_REGISTRY_GO/golang:$GO_VERSION
4749
entrypoint: [""]
4850
tags:
4951
- go
@@ -56,7 +58,7 @@ tidy:
5658
test:
5759
stage: test
5860
image:
59-
name: $CI_REGISTRY_GO/golang:1.19
61+
name: $CI_REGISTRY_GO/golang:$GO_VERSION
6062
entrypoint: [""]
6163
tags:
6264
- go

.golangci.yml

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@ linters-settings:
1616
linters:
1717
enable-all: true
1818
disable:
19-
- golint # deprecated, replaced with revive
20-
- interfacer # deprecated
21-
- maligned # deprecated
2219
- wrapcheck
2320
- nlreturn
2421
- gomnd
@@ -38,13 +35,21 @@ linters:
3835
- goconst
3936
- exhaustruct
4037
- dupword
38+
- interfacebloat
39+
- gci
40+
41+
- ifshort # deprecated
42+
- structcheck # deprecated
43+
- deadcode # deprecated
44+
- nosnakecase # deprecated
45+
- varcheck # deprecated
46+
- rowserrcheck # deprecated
47+
- sqlclosecheck # deprecated
48+
- wastedassign # deprecated
49+
- golint # deprecated
50+
- interfacer # deprecated
51+
- maligned # deprecated
4152

4253
run:
4354
skip-dirs:
4455
- test
45-
46-
issues:
47-
exclude-rules:
48-
- linters:
49-
- gosec
50-
text: "G[501]"

Makefile

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
PROJECT_PATH=${PWD}
2+
GOLANGCI_LINT_VERSION=1.51.0
23

34
.PHONY: generate
45
generate:
@@ -17,8 +18,5 @@ test:
1718

1819
.PHONY: lint
1920
lint:
20-
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
21-
22-
.PHONY: lint-local
23-
lint-local:
24-
golangci-lint run
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

bin/lint-check.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
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

parser-type.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ import (
2121
"github.com/haproxytech/config-parser/v4/errors"
2222
)
2323

24-
//nolint:golint,revive,interfacebloat
25-
type ParserInterface interface {
24+
type ParserInterface interface { //nolint:revive
2625
Init()
2726
Parse(line string, parts []string, comment string) (changeState string, err error)
2827
PreParse(line string, parts []string, preComments []string, comment string) (changeState string, err error)

parser.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ const (
5959

6060
var DefaultSectionName = "" //nolint:gochecknoglobals
6161

62-
//nolint:interfacebloat
6362
type Parser interface {
6463
LoadData(path string) error
6564
Process(reader io.Reader) error

parsers/errorfile.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import (
2626

2727
// 200, 400, 401, 403, 404, 405, 407, 408, 410,
2828
// 413, 425, 429, 500, 501, 502, 503, and 504
29-
var errorFileAllowedCode = map[string]struct{}{
29+
var errorFileAllowedCode = map[string]struct{}{ //nolint:gochecknoglobals
3030
"200": {},
3131
"400": {},
3232
"401": {},

spoe/types/types.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
//nolint:godot
1817
package types
1918

2019
//name:spoe-section

writer.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ limitations under the License.
1717
package parser
1818

1919
import (
20-
"crypto/md5"
20+
//nolint:gosec
21+
"crypto/md5" // G501: Blocklisted import crypto/md5: weak cryptographic primitive
2122
"fmt"
2223
"io"
2324
"strings"

0 commit comments

Comments
 (0)