-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CLOUDP-236398: Adding golangci and code-health action (#3)
- Loading branch information
1 parent
e1e42ca
commit d372e28
Showing
5 changed files
with
212 additions
and
16 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,17 @@ | ||
{ | ||
"problemMatcher": [ | ||
{ | ||
"owner": "actionlint", | ||
"pattern": [ | ||
{ | ||
"regexp": "^(?:\\x1b\\[\\d+m)?(.+?)(?:\\x1b\\[\\d+m)*:(?:\\x1b\\[\\d+m)*(\\d+)(?:\\x1b\\[\\d+m)*:(?:\\x1b\\[\\d+m)*(\\d+)(?:\\x1b\\[\\d+m)*: (?:\\x1b\\[\\d+m)*(.+?)(?:\\x1b\\[\\d+m)* \\[(.+?)\\]$", | ||
"file": 1, | ||
"line": 2, | ||
"column": 3, | ||
"message": 4, | ||
"code": 5 | ||
} | ||
] | ||
} | ||
] | ||
} |
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,60 @@ | ||
name: 'Code Health Tools' | ||
on: | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- 'tools/**' | ||
pull_request: {} | ||
workflow_dispatch: {} | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout CLI | ||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 | ||
- name: Install Go | ||
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 | ||
with: | ||
go-version-file: 'tools/cli/go.mod' | ||
- name: Build CLI | ||
run: | | ||
pushd tools/cli | ||
make build | ||
lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 | ||
with: | ||
sparse-checkout: | | ||
.github | ||
tools | ||
- name: Install Go | ||
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 | ||
with: | ||
go-version-file: 'tools/cli/go.mod' | ||
cache: false # see https://github.com/golangci/golangci-lint-action/issues/807 | ||
- name: golangci-lint | ||
uses: golangci/golangci-lint-action@3cfe3a4abbb849e10058ce4af15d205b6da42804 | ||
with: | ||
version: v1.56.2 | ||
working-directory: tools/cli | ||
- name: Checkout GitHub actions | ||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 | ||
with: | ||
sparse-checkout: | | ||
.github | ||
- name: Download actionlint | ||
id: get_actionlint | ||
run: bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash) | ||
shell: bash | ||
- name: Check workflow files | ||
run: | | ||
echo "::add-matcher::.github/actionlint-matcher.json" | ||
${{ steps.get_actionlint.outputs.executable }} -color | ||
shell: bash |
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,116 @@ | ||
linters-settings: | ||
gocritic: | ||
enabled-tags: | ||
- diagnostic | ||
- experimental | ||
- opinionated | ||
- performance | ||
- style | ||
govet: | ||
check-shadowing: true | ||
enable: | ||
- fieldalignment | ||
|
||
revive: | ||
# see https://github.com/mgechev/revive#available-rules for details. | ||
ignore-generated-header: true | ||
severity: warning | ||
rules: | ||
- name: blank-imports | ||
- name: context-as-argument | ||
- name: context-keys-type | ||
- name: dot-imports | ||
- name: error-return | ||
- name: error-strings | ||
- name: error-naming | ||
- name: errorf | ||
- name: exported | ||
- name: indent-error-flow | ||
- name: if-return | ||
- name: increment-decrement | ||
- name: var-naming | ||
- name: var-declaration | ||
- name: package-comments | ||
- name: range | ||
- name: receiver-naming | ||
- name: time-naming | ||
- name: unexported-return | ||
- name: indent-error-flow | ||
- name: errorf | ||
- name: empty-block | ||
- name: superfluous-else | ||
- name: struct-tag | ||
- name: unused-parameter | ||
- name: unreachable-code | ||
- name: redefines-builtin-id | ||
misspell: | ||
locale: US | ||
lll: | ||
line-length: 120 | ||
nestif: | ||
# minimal complexity of if statements to report, 5 by default | ||
min-complexity: 7 | ||
gomnd: | ||
settings: | ||
mnd: | ||
# don't include the "operation" and "assign" | ||
checks: [case, return] | ||
funlen: | ||
lines: 360 | ||
statements: 120 | ||
linters: | ||
disable-all: true | ||
enable: | ||
- dogsled | ||
- errcheck | ||
- funlen | ||
- gocritic | ||
- gofmt | ||
- goimports | ||
- revive | ||
- gomnd | ||
- goprintffuncname | ||
- gosec | ||
- gosimple | ||
- govet | ||
- ineffassign | ||
- lll | ||
- misspell | ||
- nakedret | ||
- nolintlint | ||
- rowserrcheck | ||
- exportloopref | ||
- staticcheck | ||
- stylecheck | ||
- typecheck | ||
- unconvert | ||
- unused | ||
- whitespace | ||
- thelper | ||
- testifylint | ||
- exhaustive | ||
- makezero | ||
- noctx | ||
- tenv | ||
- prealloc | ||
- predeclared | ||
- whitespace | ||
|
||
# don't enable: | ||
# - deadcode | ||
# - varcheck | ||
# - structcheck | ||
# - depguard # Go linter that checks if package imports are in a list of acceptable packages [fast: true, auto-fix: false] | ||
# - gocyclo # we already have funlen lint | ||
# - dupl # we have a lot of duplicate test cases | ||
# - gochecknoinits # we need the init function for the provider | ||
# - gochecknoglobals # we need some global variables | ||
# - unparam # Forces to create global variables when one variable is repeated in different functions | ||
# - goerr113 # It does not allow you to return an error, you need to save the error in a variable to do it | ||
# - goconst | ||
# - gocognit | ||
|
||
run: | ||
timeout: 10m | ||
tests: true | ||
modules-download-mode: readonly |
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