Skip to content

Commit 2251dcb

Browse files
committed
Add lint CI
1 parent cd7dc44 commit 2251dcb

File tree

4 files changed

+193
-0
lines changed

4 files changed

+193
-0
lines changed

.gitattributes

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# set line endings got go files. Mostly needed for golang-ci
2+
*.go text eol=lf
3+
4+
# go.sum merges can just concat. Cuts down on merge conflicts
5+
go.sum merge=union

.github/actionlint-matcher.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"problemMatcher": [
3+
{
4+
"owner": "actionlint",
5+
"pattern": [
6+
{
7+
"regexp": "^(?:\\x1b\\[\\d+m)?(.+?)(?:\\x1b\\[\\d+m)*:(?:\\x1b\\[\\d+m)*(\\d+)(?:\\x1b\\[\\d+m)*:(?:\\x1b\\[\\d+m)*(\\d+)(?:\\x1b\\[\\d+m)*: (?:\\x1b\\[\\d+m)*(.+?)(?:\\x1b\\[\\d+m)* \\[(.+?)\\]$",
8+
"file": 1,
9+
"line": 2,
10+
"column": 3,
11+
"message": 4,
12+
"code": 5
13+
}
14+
]
15+
}
16+
]
17+
}

.github/workflows/lint.yml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: lint
2+
3+
permissions:
4+
contents: read
5+
pull-requests: read
6+
7+
on:
8+
push:
9+
branches: [main, master]
10+
pull_request:
11+
branches: '**'
12+
merge_group:
13+
types: [checks_requested]
14+
15+
jobs:
16+
golangci:
17+
strategy:
18+
fail-fast: false
19+
name: lint
20+
runs-on: windows-latest
21+
steps:
22+
- uses: actions/checkout@v4
23+
- uses: actions/setup-go@v5
24+
with:
25+
go-version-file: './go.mod'
26+
check-latest: true
27+
28+
- name: golangci-lint
29+
uses: golangci/golangci-lint-action@4696ba8babb6127d732c3c6dde519db15edab9ea
30+
with:
31+
skip-save-cache: true
32+
33+
govulncheck:
34+
strategy:
35+
fail-fast: false
36+
name: govulncheck
37+
runs-on: windows-latest
38+
steps:
39+
- uses: actions/checkout@v4
40+
41+
- id: govulncheck
42+
uses: golang/govulncheck-action@v1
43+
with:
44+
go-version-file: './go.mod'
45+
check-latest: true
46+
go-package: ./...
47+
48+
actionlint:
49+
runs-on: ubuntu-latest
50+
steps:
51+
- uses: actions/checkout@v4
52+
- name: Set up Go 1.x
53+
uses: actions/setup-go@v5
54+
with:
55+
go-version-file: './go.mod'
56+
check-latest: true
57+
cache: false
58+
- name: install actionlint
59+
run: go install github.com/rhysd/actionlint/cmd/actionlint@latest
60+
- name: actionlint
61+
run: |
62+
echo "::add-matcher::.github/actionlint-matcher.json"
63+
actionlint -color
64+
65+
66+
# This job is here as a github status check -- it allows us to move
67+
# the merge dependency from being on all the jobs to this single
68+
# one.
69+
lint_mergeable:
70+
runs-on: ubuntu-latest
71+
steps:
72+
- run: true
73+
needs:
74+
- golangci
75+
- govulncheck
76+
- actionlint

.golangci.yml

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
run:
2+
timeout: 5m
3+
4+
linters:
5+
enable:
6+
- bodyclose
7+
- containedctx
8+
- gofmt
9+
- govet
10+
- ineffassign
11+
- misspell
12+
- noctx
13+
- perfsprint
14+
- rowserrcheck
15+
- sloglint
16+
- sqlclosecheck
17+
- staticcheck
18+
- usetesting
19+
- unconvert
20+
- unused
21+
- gocritic
22+
- nakedret
23+
- predeclared
24+
- revive
25+
- exhaustive
26+
disable:
27+
- errcheck
28+
- gosec
29+
- gosimple
30+
31+
linters-settings:
32+
errcheck:
33+
exclude-functions: [github.com/go-kit/kit/log:Log]
34+
gofmt:
35+
simplify: false
36+
gocritic:
37+
disabled-checks:
38+
- ifElseChain
39+
- elseif
40+
sloglint:
41+
kv-only: true
42+
context: "all"
43+
key-naming-case: snake
44+
static-msg: true
45+
revive:
46+
rules:
47+
- name: superfluous-else
48+
severity: warning
49+
disabled: false
50+
arguments:
51+
- "preserveScope"
52+
- name: package-comments
53+
disabled: false
54+
- name: context-as-argument
55+
disabled: false
56+
- name: context-keys-type
57+
disabled: false
58+
- name: error-return
59+
disabled: false
60+
- name: errorf
61+
disabled: false
62+
- name: unreachable-code
63+
disabled: false
64+
- name: early-return
65+
disabled: false
66+
- name: confusing-naming
67+
disabled: false
68+
- name: defer
69+
disabled: false
70+
staticcheck:
71+
checks: ["all"]
72+
73+
issues:
74+
exclude-rules:
75+
# False positive: https://github.com/kunwardeep/paralleltest/issues/8.
76+
- linters:
77+
- paralleltest
78+
text: "does not use range value in test Run"
79+
# We prefer fmt.Sprintf over string concatenation for readability
80+
- linters: [perfsprint]
81+
text: "fmt.Sprintf can be replaced with string concatenation"
82+
- linters: [perfsprint]
83+
text: "fmt.Sprintf can be replaced with faster hex.EncodeToString"
84+
- linters: [perfsprint]
85+
text: "fmt.Sprintf can be replaced with faster strconv.FormatBool"
86+
- linters: [perfsprint]
87+
text: "fmt.Sprintf can be replaced with faster strconv.FormatInt"
88+
- linters: [perfsprint]
89+
text: "fmt.Sprintf can be replaced with faster strconv.FormatUint"
90+
- linters: [perfsprint]
91+
text: "fmt.Sprintf can be replaced with faster strconv.Itoa"
92+
- linters: [perfsprint]
93+
text: "fmt.Sprint can be replaced with faster strconv.Itoa"
94+
exclude-dirs:
95+
- test-cmds

0 commit comments

Comments
 (0)