Skip to content

Commit

Permalink
Add linting to CI
Browse files Browse the repository at this point in the history
Signed-off-by: Paul Balogh <[email protected]>
  • Loading branch information
javaducky committed Jan 22, 2024
1 parent c419d9c commit 18f1716
Show file tree
Hide file tree
Showing 3 changed files with 137 additions and 15 deletions.
15 changes: 0 additions & 15 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,6 @@ on:
pull_request:

jobs:
check-modules:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Go(lang)
uses: actions/setup-go@v5
with:
go-version: 1.21.x
- name: Check module dependencies
run: |
go version
test -z "$(go mod tidy && git status go.* --porcelain)"
go mod verify
run-unit-tests:
runs-on: ubuntu-latest
steps:
Expand Down
42 changes: 42 additions & 0 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Lint

on:
push:
pull_request:

jobs:
check-modules:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Go(lang)
uses: actions/setup-go@v5
with:
go-version: 1.21.x
- name: Check module dependencies
run: |
go version
test -z "$(go mod tidy && git status go.* --porcelain)"
go mod verify
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: 1.21.x
- name: Retrieve golangci-lint version
run: |
echo "Version=$(head -n 1 "${GITHUB_WORKSPACE}/.golangci.yml" | tr -d '# ')" >> $GITHUB_OUTPUT
id: version
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: ${{ steps.version.outputs.Version }}
only-new-issues: true
95 changes: 95 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# v1.55.2
# Please don't remove the first line. It is used in CI to determine the golangci-lint version.
run:
timeout: 5m

issues:
exclude-rules:
- path: _(test|gen)\.go
linters:
- cyclop
- dupl
- gocognit
- funlen
- lll
- path: (cmd|env|migrations)\/
linters:
- gochecknoglobals

linters-settings:
govet:
check-shadowing: true
funlen:
lines: 80
statements: 60
forbidigo:
forbid:
- '^(fmt\\.Print(|f|ln)|print|println)$'

linters:
disable-all: true
enable:
- asasalint
- asciicheck
- bidichk
- bodyclose
- contextcheck
- cyclop
- dogsled
- dupl
- durationcheck
- errcheck
- errchkjson
- errname
- errorlint
- exhaustive
- exportloopref
- forbidigo
- forcetypeassert
- funlen
- gocheckcompilerdirectives
- gochecknoglobals
- gocognit
- goconst
- gocritic
- gofmt
- gofumpt
- goimports
- gomoddirectives
- goprintffuncname
- gosec
- gosimple
- govet
- importas
- ineffassign
- interfacebloat
- lll
- makezero
- misspell
- nakedret
- nestif
- nilerr
- nilnil
- noctx
- nolintlint
- nosprintfhostport
- paralleltest
- prealloc
- predeclared
- promlinter
- revive
- reassign
- rowserrcheck
- sqlclosecheck
- staticcheck
- stylecheck
- tenv
- tparallel
- typecheck
- unconvert
- unparam
- unused
- usestdlibvars
- wastedassign
- whitespace
fast: false

0 comments on commit 18f1716

Please sign in to comment.