Skip to content

Commit

Permalink
build: add linting action before publishing
Browse files Browse the repository at this point in the history
  • Loading branch information
clementnuss committed Nov 23, 2021
1 parent 7c6d8eb commit 4c0c74d
Show file tree
Hide file tree
Showing 2 changed files with 115 additions and 6 deletions.
26 changes: 20 additions & 6 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
name: Test and publish

on:
push:
branches: ['main']
on: [push, pull_request]

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: 1.17
stable: true

- name: Install golangci-lint
uses: golangci/[email protected]
with:
version: v1.43.0
skip-go-installation: true

test:
runs-on: ubuntu-latest
steps:
Expand All @@ -14,7 +27,8 @@ jobs:
go-version: 1.17
stable: true

- run: |
- name: Download K8s envtest - local K8s cluster control plane
run: |
go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest
mkdir -p local/envtest-bin/
setup-envtest use -p env 1.21.x --bin-dir local/envtest-bin > local/envtest-bin/env
Expand All @@ -35,7 +49,7 @@ jobs:
release-tagged:
if: "startsWith(github.ref, 'refs/tags/v')"
needs:
# - lint
- lint
- test
runs-on: ubuntu-latest
steps:
Expand All @@ -60,7 +74,7 @@ jobs:
release-untagged:
if: "!startsWith(github.ref, 'refs/tags/v')"
needs:
# - lint
- lint
- test
runs-on: ubuntu-latest
steps:
Expand Down
95 changes: 95 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
---
run:
tests: false
skip-dirs:
- .github
- build
- web
- .go
linters-settings:
dupl:
threshold: 100
funlen:
lines: 100
statements: 50
goconst:
min-len: 2
min-occurrences: 2
gocritic:
enabled-tags:
- diagnostic
- experimental
- opinionated
- performance
- style
disabled-checks:
- whyNoLint
- hugeParam
gocyclo:
min-complexity: 15
revive:
min-confidence: 0.8
govet:
check-shadowing: true
lll:
line-length: 140
misspell:
locale: US
nolintlint:
allow-leading-space: false
require-explanation: true
allow-no-explanation:
- gocognit
- funlen
- gocyclo

linters:
disable-all: true
enable:
- bodyclose
- deadcode
- depguard
- dogsled
- dupl
- errcheck
- funlen
- nolintlint
- gochecknoglobals
- gochecknoinits
- gocognit
- goconst
- gocritic
- gocyclo
- gofmt
- goimports
- revive
- goprintffuncname
- gosec
- gosimple
- govet
- ineffassign
- misspell
- nakedret
- prealloc
- rowserrcheck
- exportloopref
- staticcheck
- structcheck
- stylecheck
- typecheck
- unconvert
- unparam
- unused
- varcheck
- whitespace
- wsl

issues:
exclude:
# Very commonly not checked.
- 'Error return value of .(l.Sync|.*Close|.*.Write|.*Flush|os\.Remove(All)?|os\.(Un)?Setenv). is not checked'
- 'G104:.*'
- 'exported method (.*\.MarshalJSON|.*\.UnmarshalJSON) should have comment or be unexported'
- 'shadow: declaration of "err" shadows declaration.*'
max-same-issues: 0
exclude-use-default: false

0 comments on commit 4c0c74d

Please sign in to comment.