Skip to content

Commit 44ec617

Browse files
🌱 Golang CI for clean code.
Included golangci for clean code. Signed-off-by: naveen <[email protected]>
1 parent f7cb554 commit 44ec617

File tree

4 files changed

+188
-5
lines changed

4 files changed

+188
-5
lines changed

.github/workflows/codeql-analysis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
strategy:
3232
fail-fast: false
3333
matrix:
34-
language: [ 'javascript' ]
34+
language: [ 'javascript','go' ]
3535

3636
steps:
3737
- name: Checkout repository

.github/workflows/golangci.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: golangci-lint
2+
on:
3+
push:
4+
branches: [ main ]
5+
pull_request:
6+
branches: [ main ]
7+
8+
permissions: read-all
9+
10+
jobs:
11+
lint:
12+
name: Run golangci lint
13+
- uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579 #v2.4.0
14+
# https://github.com/mvdan/github-actions-golang#how-do-i-set-up-caching-between-builds
15+
- uses: actions/cache@937d24475381cd9c75ae6db12cb4e79714b926ed #v2.1.7
16+
with:
17+
# In order:
18+
# * Module download cache
19+
# * Build cache (Linux)
20+
# * Build cache (Mac)
21+
# * Build cache (Windows)
22+
path: |
23+
~/go/pkg/mod
24+
~/.cache/go-build
25+
~/Library/Caches/go-build
26+
%LocalAppData%\go-build
27+
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
28+
restore-keys: |
29+
${{ runner.os }}-go-
30+
- uses: actions/setup-go@424fc82d43fa5a37540bae62709ddcc23d9520d4 #v2.1.5
31+
with:
32+
go-version: '1.17.x'
33+
- uses: golangci/golangci-lint-action@5c56cd6c9dc07901af25baab6f2b0d9f3b7c3018
34+
with:
35+
version: v1.44.0
36+
only-new-issues: true

.github/workflows/tests.yaml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,9 @@ jobs:
1414
strategy:
1515
matrix:
1616
os: [ ubuntu-latest ]
17-
1817
steps:
1918
- uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579 #v2.4.0
20-
# https://github.com/mvdan/github-actions-golang#how-do-i-set-up-caching-between-builds
19+
# https://github.com/mvdan/github-actions-golang#how-do-i-set-up-caching-between-builds
2120
- uses: actions/cache@937d24475381cd9c75ae6db12cb4e79714b926ed #v2.1.7
2221
with:
2322
# In order:
@@ -37,6 +36,4 @@ jobs:
3736
with:
3837
go-version: '1.17.x'
3938
- name: Run Go tests
40-
run: go test ./...
41-
- name: Run Go tests w/ `-race`
4239
run: go test -race ./...

.golangci.yml

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
---
2+
run:
3+
concurrency: 6
4+
deadline: 5m
5+
issues:
6+
new-from-rev: ""
7+
include:
8+
# revive `package-comments` and `exported` rules.
9+
- EXC0012
10+
- EXC0013
11+
- EXC0014
12+
- EXC0015
13+
linters:
14+
disable-all: true
15+
enable:
16+
- asciicheck
17+
- bodyclose
18+
- deadcode
19+
- depguard
20+
- dogsled
21+
- errcheck
22+
- errorlint
23+
- exhaustive
24+
- exportloopref
25+
- gci
26+
- gochecknoinits
27+
- gocognit
28+
- goconst
29+
- gocritic
30+
- gocyclo
31+
- godot
32+
- godox
33+
- goerr113
34+
- gofmt
35+
- gofumpt
36+
- goheader
37+
- goimports
38+
- gomodguard
39+
- goprintffuncname
40+
- gosec
41+
- gosimple
42+
- govet
43+
- ineffassign
44+
- lll
45+
- makezero
46+
- misspell
47+
- nakedret
48+
- nestif
49+
- noctx
50+
- nolintlint
51+
- paralleltest
52+
- predeclared
53+
- revive
54+
- rowserrcheck
55+
- sqlclosecheck
56+
- staticcheck
57+
- structcheck
58+
- stylecheck
59+
- thelper
60+
- tparallel
61+
- typecheck
62+
- unconvert
63+
- unparam
64+
- unused
65+
- varcheck
66+
- whitespace
67+
- wrapcheck
68+
linters-settings:
69+
errcheck:
70+
check-type-assertions: true
71+
check-blank: true
72+
govet:
73+
enable:
74+
- fieldalignment
75+
godox:
76+
keywords:
77+
- BUG
78+
- FIXME
79+
- HACK
80+
gci:
81+
local-prefixes: github.com/ossf/scorecard-action
82+
gocritic:
83+
enabled-checks:
84+
# Diagnostic
85+
- appendAssign
86+
- argOrder
87+
- badCond
88+
- caseOrder
89+
- codegenComment
90+
- commentedOutCode
91+
- deprecatedComment
92+
- dupArg
93+
- dupBranchBody
94+
- dupCase
95+
- dupSubExpr
96+
- exitAfterDefer
97+
- flagDeref
98+
- flagName
99+
- nilValReturn
100+
- offBy1
101+
- sloppyReassign
102+
- weakCond
103+
- octalLiteral
104+
105+
# Performance
106+
- appendCombine
107+
- equalFold
108+
- hugeParam
109+
- indexAlloc
110+
- rangeExprCopy
111+
- rangeValCopy
112+
113+
# Style
114+
- assignOp
115+
- boolExprSimplify
116+
- captLocal
117+
- commentFormatting
118+
- commentedOutImport
119+
- defaultCaseOrder
120+
- docStub
121+
- elseif
122+
- emptyFallthrough
123+
- emptyStringTest
124+
- hexLiteral
125+
- ifElseChain
126+
- methodExprCall
127+
- regexpMust
128+
- singleCaseSwitch
129+
- sloppyLen
130+
- stringXbytes
131+
- switchTrue
132+
- typeAssertChain
133+
- typeSwitchVar
134+
- underef
135+
- unlabelStmt
136+
- unlambda
137+
- unslice
138+
- valSwap
139+
- wrapperFunc
140+
- yodaStyleExpr
141+
142+
# Opinionated
143+
- builtinShadow
144+
- importShadow
145+
- initClause
146+
- nestingReduce
147+
- paramTypeCombine
148+
- ptrToRefParam
149+
- typeUnparen
150+
- unnecessaryBlock

0 commit comments

Comments
 (0)