-
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.
Merge pull request #34 from nspcc-dev/add-linter
workflows: add common Go linter, fix #21
- Loading branch information
Showing
4 changed files
with
149 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,43 @@ | ||
name: Go linter | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
ref: | ||
type: string | ||
description: 'Ref to test [default: latest master; examples: 0a4ff9d3e4a9ab432fd5812eb18c98e03b5a7432' | ||
required: false | ||
default: '' | ||
workdir: | ||
type: string | ||
description: 'Working directory' | ||
required: false | ||
default: '.' | ||
|
||
jobs: | ||
linter: | ||
name: Lint | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ 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: ${{ inputs.workdir }}/go.mod | ||
cache-dependency-path: ${{ inputs.workdir }}/go.sum | ||
|
||
- name: golangci-lint | ||
uses: golangci/golangci-lint-action@v6 | ||
with: | ||
version: latest | ||
working-directory: ${{ 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,83 @@ | ||
# 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 | ||
|
||
issues: | ||
include: | ||
- EXC0002 # should have a comment | ||
- EXC0003 # test/Test ... consider calling this | ||
- EXC0004 # govet | ||
- EXC0005 # C-style breaks |
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 |