-
Notifications
You must be signed in to change notification settings - Fork 260
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1600 from metal3-io-bot/cherry-pick-1394-to-relea…
…se-0.5 [release-0.5] 🌱 Add golangci-lint github workflow
- Loading branch information
Showing
52 changed files
with
547 additions
and
537 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
name: golangci-lint | ||
|
||
on: | ||
pull_request: | ||
types: [opened, edited, synchronize, reopened] | ||
|
||
# Remove all permissions from GITHUB_TOKEN except metadata. | ||
permissions: {} | ||
|
||
jobs: | ||
golangci: | ||
name: lint | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
working-directory: | ||
- "" | ||
- test | ||
- apis | ||
- pkg/hardwareutils | ||
steps: | ||
- uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 | ||
- name: Calculate go version | ||
id: vars | ||
run: echo "go_version=$(make go-version)" >> $GITHUB_OUTPUT | ||
- name: Set up Go | ||
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0 | ||
with: | ||
go-version: ${{ steps.vars.outputs.go_version }} | ||
- name: golangci-lint-${{matrix.working-directory}} | ||
uses: golangci/golangci-lint-action@3a919529898de77ec3da873e3063ca4b10e7f5cc # v3.7.0 | ||
with: | ||
version: v1.54.2 | ||
working-directory: ${{matrix.working-directory}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,160 @@ | ||
run: | ||
deadline: 5m | ||
skip-dirs: | ||
- mock* | ||
skip-files: | ||
- "zz_generated.*\\.go$" | ||
- ".*conversion.*\\.go$" | ||
linters: | ||
disable-all: true | ||
enable: | ||
- asciicheck | ||
- bodyclose | ||
- dogsled | ||
# - errcheck | ||
# - errorlint | ||
- exportloopref | ||
# - goconst | ||
# - gocritic | ||
# - godot | ||
# - gofmt | ||
# - goimports | ||
# - gosimple | ||
# - govet | ||
# - importas | ||
# - gosec | ||
# - ineffassign | ||
# - misspell | ||
# - nakedret | ||
# - nilerr | ||
# - noctx | ||
# - nolintlint | ||
# - prealloc | ||
# - predeclared | ||
# - revive | ||
# - rowserrcheck | ||
# - staticcheck | ||
# - stylecheck | ||
# - thelper | ||
# - typecheck | ||
# - unconvert | ||
# - unused | ||
# - whitespace | ||
# Run with --fast=false for more extensive checks | ||
fast: true | ||
|
||
linters-settings: | ||
gosec: | ||
go: "1.20" | ||
severity: medium | ||
confidence: medium | ||
concurrency: 8 | ||
importas: | ||
no-unaliased: true | ||
alias: | ||
# Kubernetes | ||
- pkg: k8s.io/api/core/v1 | ||
alias: corev1 | ||
- pkg: k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1 | ||
alias: apiextensionsv1 | ||
- pkg: k8s.io/apimachinery/pkg/apis/meta/v1 | ||
alias: metav1 | ||
- pkg: k8s.io/apimachinery/pkg/api/errors | ||
alias: k8serrors | ||
- pkg: k8s.io/apimachinery/pkg/util/errors | ||
alias: kerrors | ||
- pkg: k8s.io/component-base/logs/api/v1 | ||
alias: logsv1 | ||
# Controller Runtime | ||
- pkg: sigs.k8s.io/controller-runtime | ||
alias: ctrl | ||
# BMO | ||
- pkg: github.com/metal3-io/baremetal-operator/apis/metal3.io/v1alpha1 | ||
alias: metal3api | ||
nolintlint: | ||
allow-unused: false | ||
allow-leading-space: false | ||
require-specific: true | ||
staticcheck: | ||
go: "1.20" | ||
stylecheck: | ||
go: "1.20" | ||
gocritic: | ||
enabled-tags: | ||
- experimental | ||
disabled-checks: | ||
- appendAssign | ||
- dupImport # https://github.com/go-critic/go-critic/issues/845 | ||
- evalOrder | ||
- ifElseChain | ||
- octalLiteral | ||
- regexpSimplify | ||
- sloppyReassign | ||
- truncateCmp | ||
- typeDefFirst | ||
- unnamedResult | ||
- unnecessaryDefer | ||
- whyNoLint | ||
- wrapperFunc | ||
unused: | ||
go: "1.20" | ||
issues: | ||
exclude-rules: | ||
- path: test/e2e | ||
linters: | ||
- gosec | ||
- path: _test\.go | ||
linters: | ||
- unused | ||
# Specific exclude rules for deprecated fields that are still part of the codebase. | ||
# These should be removed as the referenced deprecated item is removed from the project. | ||
- linters: | ||
- staticcheck | ||
text: "SA1019:" | ||
# Disable linters for conversion | ||
- linters: | ||
- staticcheck | ||
text: "SA1019:" | ||
path: .*(api|types)\/.*\/conversion.*\.go$ | ||
# Dot imports for gomega or ginkgo are allowed | ||
# within test files. | ||
- path: _test\.go | ||
text: should not use dot imports | ||
- path: (test|e2e)/.*.go | ||
text: should not use dot imports | ||
- linters: | ||
- revive | ||
text: "exported: exported method .*\\.(Reconcile|SetupWithManager|SetupWebhookWithManager) should have comment or be unexported" | ||
# Exclude some packages or code to require comments, for example test code, or fake clients. | ||
- linters: | ||
- revive | ||
text: exported (method|function|type|const) (.+) should have comment or be unexported | ||
source: (func|type).*Fake.* | ||
- linters: | ||
- revive | ||
text: exported (method|function|type|const) (.+) should have comment or be unexported | ||
path: fake_\.go | ||
- linters: | ||
- revive | ||
text: exported (method|function|type|const) (.+) should have comment or be unexported | ||
path: .*(api|types)\/.*\/conversion.*\.go$ | ||
- linters: | ||
- revive | ||
text: "var-naming: don't use underscores in Go names;" | ||
path: .*(api|types)\/.*\/conversion.*\.go$ | ||
- linters: | ||
- revive | ||
text: "receiver-naming: receiver name" | ||
path: .*(api|types)\/.*\/conversion.*\.go$ | ||
- linters: | ||
- stylecheck | ||
text: "ST1003: should not use underscores in Go names;" | ||
path: .*(api|types)\/.*\/conversion.*\.go$ | ||
- linters: | ||
- stylecheck | ||
text: "ST1016: methods on the same type should have the same receiver name" | ||
path: .*(api|types)\/.*\/conversion.*\.go$ | ||
include: | ||
- EXC0002 # include "missing comments" issues from golangci-lint | ||
max-issues-per-linter: 0 | ||
max-same-issues: 0 |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -105,5 +105,4 @@ func main() { | |
} | ||
|
||
fmt.Fprint(os.Stdout, result) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.