Skip to content

Commit 4a90126

Browse files
authored
ci: align linter versions using make lint in CI (#18)
- Replace golangci-lint-action with make install-lint + make lint to ensure CI uses the same version as local development - Pin golangci-lint to v2.8.0 in Makefile - Migrate .golangci.yml to v2.8.0 schema: - Move issues.exclude-dirs to linters.exclusions.paths - Move issues.exclude-rules to linters.exclusions.rules - Remove redundant nolint:funlen directive from parser_test.go
1 parent 7c9c294 commit 4a90126

File tree

4 files changed

+35
-39
lines changed

4 files changed

+35
-39
lines changed

.github/workflows/pre-main.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@ jobs:
4949
- name: Install Shfmt
5050
uses: mfinelli/setup-shfmt@031e887e39d899d773a7e9b6dd6472c2c23ff50d # v3.0.1
5151

52+
- name: Install golangci-lint
53+
run: make install-lint
54+
5255
- name: Golangci-lint
53-
uses: golangci/golangci-lint-action@v7
54-
with:
55-
version: latest
56-
args: --timeout 10m0s
56+
run: make lint
5757

5858
- name: Checkmake
5959
run: checkmake --config=.checkmake Makefile

.golangci.yml

Lines changed: 30 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,36 @@ linters:
2424
- unconvert
2525
- unparam
2626
- whitespace
27+
exclusions:
28+
paths:
29+
- cmd/l2discovery
30+
rules:
31+
# Ignore magic numbers, inline strings and function length in tests.
32+
- path: _test\.go
33+
linters:
34+
- mnd
35+
- goconst
36+
- funlen
37+
- path: config/config.go
38+
linters:
39+
- mnd
40+
- path: _scaling.go
41+
linters:
42+
- gocritic
43+
- path: hugepages.go
44+
linters:
45+
- mnd
46+
- path: scheduling.go
47+
linters:
48+
- mnd
49+
# Ignore line length for string assignments (do not try and wrap regex definitions)
50+
- linters:
51+
- lll
52+
source: "^(.*= (\".*\"|`.*`))$"
53+
# https://github.com/go-critic/go-critic/issues/926
54+
- linters:
55+
- gocritic
56+
text: "unnecessaryDefer:"
2757
settings:
2858
dupl:
2959
threshold: 100
@@ -72,35 +102,3 @@ formatters:
72102
enable:
73103
- gofmt
74104
- goimports
75-
76-
issues:
77-
exclude-dirs:
78-
- cmd/l2discovery
79-
# Excluding configuration per-path, per-linter, per-text and per-source
80-
exclude-rules:
81-
# Ignore magic numbers, inline strings and function length in tests.
82-
- path: _test\.go
83-
linters:
84-
- mnd
85-
- goconst
86-
- funlen
87-
- path: config/config.go
88-
linters:
89-
- mnd
90-
- path: _scaling.go
91-
linters:
92-
- gocritic
93-
- path: hugepages.go
94-
linters:
95-
- mnd
96-
- path: scheduling.go
97-
linters:
98-
- mnd
99-
# Ignore line length for string assignments (do not try and wrap regex definitions)
100-
- linters:
101-
- lll
102-
source: "^(.*= (\".*\"|`.*`))$"
103-
# https://github.com/go-critic/go-critic/issues/926
104-
- linters:
105-
- gocritic
106-
text: "unnecessaryDefer:"

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
GOLANGCI_VERSION=latest
1+
GOLANGCI_VERSION=v2.8.0
22
GO_PACKAGES=$(shell go list ./... | grep -v vendor)
33

44
.PHONY: all clean test build build-l2discovery lint install-lint vet fmt image launch

pkg/parser/parser_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,6 @@ supports-priv-flags: no`,
5353
})
5454
}
5555
}
56-
57-
//nolint:funlen
5856
func TestParseLspci(t *testing.T) {
5957
type args struct {
6058
output string

0 commit comments

Comments
 (0)