-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
workflows: add common Go linter, fix #21
This tries to unify golangci-lint settings we use across ~20 Go repositories and simplify maintenance. In general, we have two sources of golangci.yml files copied across different repositories: neofs-node and neo-go. They differ: * neofs-node doesn't care about tests, neo-go does * neofs-node has additional settings for gofmt/gomodguard/revive * neo-go has additional settings for issues with exclusions * neo-go doesn't use exhaustive * neofs-node doesn't use bodyclose/contextcheck/decorder/errorlint The golangci.yml added here: * cares about tests * uses additional rules from neofs-node, they're useful * drops neo-go settings from the 'issues' section, they seem to be useless * enables all linters from both worlds Which practically means that it causes some pain below the spine for just about any repository. But likely those can be fixed. Signed-off-by: Roman Khimov <[email protected]>
- Loading branch information
1 parent
d48bb4e
commit 1cda416
Showing
4 changed files
with
140 additions
and
0 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,41 @@ | ||
name: Go linter | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
ref: | ||
description: 'Ref to test [default: latest master; examples: 0a4ff9d3e4a9ab432fd5812eb18c98e03b5a7432' | ||
required: false | ||
default: '' | ||
workdir: | ||
description: 'Working directory' | ||
required: false | ||
default: '.' | ||
|
||
jobs: | ||
linter: | ||
name: Lint | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ github.event.inputs.ref }} | ||
|
||
- name: Checkout .github repository | ||
uses: actions/checkout@v4 | ||
with: | ||
repository: nspcc-dev/.github | ||
path: nspcc-gh | ||
|
||
- uses: actions/setup-go@v5 | ||
with: | ||
go-version-file: ${{ github.event.inputs.workdir }}/go.mod | ||
cache-dependency-path: ${{ github.event.inputs.workdir }}/go.sum | ||
|
||
- name: golangci-lint | ||
uses: golangci/golangci-lint-action@v6 | ||
with: | ||
version: latest | ||
working-directory: ${{ github.event.inputs.workdir }} | ||
args: --config=${{ github.workspace }}/nspcc-gh/.golangci.yml |
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,76 @@ | ||
# This file contains all available configuration options | ||
# with their default values. | ||
|
||
# options for analysis running | ||
run: | ||
# timeout for analysis, e.g. 30s, 5m, default is 1m | ||
timeout: 5m | ||
|
||
# include test files or not, default is true | ||
tests: true | ||
|
||
# output configuration options | ||
output: | ||
# colored-line-number|line-number|json|tab|checkstyle|code-climate, default is "colored-line-number" | ||
formats: | ||
- format: tab | ||
|
||
# all available settings of specific linters | ||
linters-settings: | ||
exhaustive: | ||
# indicates that switch statements are to be considered exhaustive if a | ||
# 'default' case is present, even if all enum members aren't listed in the | ||
# switch | ||
default-signifies-exhaustive: true | ||
gofmt: | ||
rewrite-rules: | ||
- pattern: 'interface{}' | ||
replacement: 'any' | ||
gomodguard: | ||
blocked: | ||
modules: | ||
- github.com/pkg/errors: | ||
reason: "Obsolete after the 1.13 release; use the standard `errors` package" | ||
revive: | ||
rules: | ||
- name: duplicated-imports | ||
|
||
linters: | ||
enable: | ||
# mandatory linters | ||
- govet | ||
- revive | ||
|
||
# some default golangci-lint linters | ||
- errcheck | ||
- gosimple | ||
- godot | ||
- ineffassign | ||
- staticcheck | ||
- typecheck | ||
- unused | ||
|
||
# extra linters | ||
# - goconst | ||
# - goerr113 | ||
# - gomnd | ||
# - nonamedreturns | ||
# - unparam | ||
- bidichk | ||
- bodyclose | ||
- contextcheck | ||
- copyloopvar | ||
- decorder | ||
- durationcheck | ||
- errorlint | ||
- exhaustive | ||
- gofmt | ||
- goimports | ||
- gomodguard | ||
- intrange | ||
- misspell | ||
- predeclared | ||
- reassign | ||
- whitespace | ||
disable-all: true | ||
fast: false |
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,5 @@ | ||
{ | ||
"name": "Go linter", | ||
"description": "Run golangci-lint.", | ||
"iconName": "octicon cpu" | ||
} |
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,18 @@ | ||
name: Go linter | ||
|
||
on: | ||
push: | ||
branches: [ $default-branch ] | ||
paths-ignore: | ||
- '**/*.sh' | ||
- '**/*.md' | ||
pull_request: | ||
branches: [ $default-branch ] | ||
types: [opened, synchronize] | ||
paths-ignore: | ||
- '**/*.sh' | ||
- '**/*.md' | ||
|
||
jobs: | ||
lint: | ||
uses: nspcc-dev/.github/.github/workflows/go-linter.yml@master |