Skip to content

Commit 698e97a

Browse files
committed
github actions
1 parent 27f5d4b commit 698e97a

File tree

7 files changed

+281
-0
lines changed

7 files changed

+281
-0
lines changed

.github/workflows/actions.yml

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: golangci-lint
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
7+
8+
permissions:
9+
contents: read
10+
pull-requests: read
11+
12+
env:
13+
GO_VERSION: stable
14+
GOLANGCI_LINT_VERSION: v1.59
15+
16+
jobs:
17+
detect-modules:
18+
runs-on: ubuntu-latest
19+
outputs:
20+
modules: ${{ steps.set-modules.outputs.modules }}
21+
steps:
22+
- uses: actions/checkout@v4
23+
- uses: actions/setup-go@v5
24+
with:
25+
go-version: ${{ env.GO_VERSION }}
26+
- id: set-modules
27+
run: echo "modules=$(go list -m -json | jq -s '.' | jq -c '[.[].Dir]')" >> $GITHUB_OUTPUT
28+
29+
golangci:
30+
name: lint
31+
needs: detect-modules
32+
runs-on: ubuntu-latest
33+
strategy:
34+
matrix:
35+
modules: ${{ fromJSON(needs.detect-modules.outputs.modules) }}
36+
fail-fast: false
37+
steps:
38+
- uses: actions/checkout@v4
39+
- uses: actions/setup-go@v5
40+
with:
41+
go-version: ${{ env.GO_VERSION }}
42+
- name: golangci-lint ${{ matrix.modules }}
43+
uses: golangci/golangci-lint-action@v6
44+
with:
45+
version: ${{ env.GOLANGCI_LINT_VERSION }}
46+
working-directory: ${{ matrix.modules }}
47+
48+
gotest:
49+
name: tests
50+
needs: detect-modules
51+
runs-on: ubuntu-latest
52+
strategy:
53+
matrix:
54+
modules: ${{ fromJSON(needs.detect-modules.outputs.modules) }}
55+
fail-fast: false
56+
steps:
57+
- uses: actions/checkout@v4
58+
- uses: actions/setup-go@v5
59+
with:
60+
go-version: ${{ env.GO_VERSION }}
61+
- name: Test with the Go CLI
62+
run: go test -race ${{ matrix.modules }}/...

closer/.golangci.yml

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
output:
2+
formats:
3+
- format: colored-line-number
4+
print-issued-lines: true
5+
print-linter-name: true
6+
7+
linters-settings:
8+
gocognit:
9+
min-complexity: 10
10+
goconst:
11+
min-len: 2
12+
min-occurrences: 2
13+
gosec:
14+
excludes:
15+
# _ instead of err checks
16+
- G104
17+
govet:
18+
enable-all: true
19+
nakedret:
20+
max-func-lines: 10
21+
nolintlint:
22+
require-specific: true
23+
prealloc:
24+
range-loops: true
25+
revive:
26+
rules:
27+
- name: unexported-return
28+
disabled: true
29+
staticcheck:
30+
# SA5001: Allow to ignore returned error before deferring *.Close()
31+
checks: ["all", "-SA5001"]
32+
33+
linters:
34+
disable-all: true
35+
enable:
36+
- bodyclose
37+
- errcheck
38+
- errorlint
39+
- exportloopref
40+
- gocheckcompilerdirectives
41+
- gocognit
42+
- goconst
43+
- goimports
44+
- gosec
45+
- gosimple
46+
- govet
47+
- ineffassign
48+
- makezero
49+
- mnd
50+
- nakedret
51+
- noctx
52+
- nolintlint
53+
- nosprintfhostport
54+
- prealloc
55+
- revive
56+
- staticcheck
57+
- tenv
58+
- testpackage
59+
- typecheck
60+
- unconvert
61+
- unused
62+
- wastedassign
63+
64+
issues:
65+
exclude-rules:
66+
- path: '(.+)_test\.go'
67+
linters:
68+
- gocognit

ctxkey/.golangci.yml

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
output:
2+
formats:
3+
- format: colored-line-number
4+
print-issued-lines: true
5+
print-linter-name: true
6+
7+
linters-settings:
8+
gocognit:
9+
min-complexity: 10
10+
goconst:
11+
min-len: 2
12+
min-occurrences: 2
13+
gosec:
14+
excludes:
15+
# _ instead of err checks
16+
- G104
17+
govet:
18+
enable-all: true
19+
nakedret:
20+
max-func-lines: 10
21+
nolintlint:
22+
require-specific: true
23+
prealloc:
24+
range-loops: true
25+
revive:
26+
rules:
27+
- name: unexported-return
28+
disabled: true
29+
staticcheck:
30+
# SA5001: Allow to ignore returned error before deferring *.Close()
31+
checks: ["all", "-SA5001"]
32+
33+
linters:
34+
disable-all: true
35+
enable:
36+
- bodyclose
37+
- errcheck
38+
- errorlint
39+
- exportloopref
40+
- gocheckcompilerdirectives
41+
- gocognit
42+
- goconst
43+
- goimports
44+
- gosec
45+
- gosimple
46+
- govet
47+
- ineffassign
48+
- makezero
49+
- mnd
50+
- nakedret
51+
- noctx
52+
- nolintlint
53+
- nosprintfhostport
54+
- prealloc
55+
- revive
56+
- staticcheck
57+
- tenv
58+
- testpackage
59+
- typecheck
60+
- unconvert
61+
- unused
62+
- wastedassign
63+
64+
issues:
65+
exclude-rules:
66+
- path: 'ctxkey\.go'
67+
linters:
68+
- goimports
69+
- path: '(.+)_test\.go'
70+
linters:
71+
- gocognit

go.work

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
go 1.20
2+
3+
use (
4+
./closer
5+
./ctxkey
6+
./time
7+
)

go.work.sum

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
github.com/creack/pty v1.1.9 h1:uDmaGzcdjhF4i/plgjmEsriH11Y0o7RKapEf/LDaM3w=
2+
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
3+
github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY=
4+
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=

time/.golangci.yml

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
output:
2+
formats:
3+
- format: colored-line-number
4+
print-issued-lines: true
5+
print-linter-name: true
6+
7+
linters-settings:
8+
gocognit:
9+
min-complexity: 10
10+
goconst:
11+
min-len: 2
12+
min-occurrences: 2
13+
gosec:
14+
excludes:
15+
# _ instead of err checks
16+
- G104
17+
govet:
18+
enable-all: true
19+
nakedret:
20+
max-func-lines: 10
21+
nolintlint:
22+
require-specific: true
23+
prealloc:
24+
range-loops: true
25+
revive:
26+
rules:
27+
- name: unexported-return
28+
disabled: true
29+
staticcheck:
30+
# SA5001: Allow to ignore returned error before deferring *.Close()
31+
checks: ["all", "-SA5001"]
32+
33+
linters:
34+
disable-all: true
35+
enable:
36+
- bodyclose
37+
- errcheck
38+
- errorlint
39+
- exportloopref
40+
- gocheckcompilerdirectives
41+
- gocognit
42+
- goconst
43+
- goimports
44+
- gosec
45+
- gosimple
46+
- govet
47+
- ineffassign
48+
- makezero
49+
- mnd
50+
- nakedret
51+
- noctx
52+
- nolintlint
53+
- nosprintfhostport
54+
- prealloc
55+
- revive
56+
- staticcheck
57+
- tenv
58+
- testpackage
59+
- typecheck
60+
- unconvert
61+
- unused
62+
- wastedassign
63+
64+
issues:
65+
exclude-rules:
66+
- path: '(.+)_test\.go'
67+
linters:
68+
- gocognit

time/time_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
func TestDuration_MarshalJSON(t *testing.T) {
1313
t.Parallel()
1414

15+
//nolint:govet
1516
tests := []struct {
1617
name string
1718
d Duration

0 commit comments

Comments
 (0)