-
Notifications
You must be signed in to change notification settings - Fork 5
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
- Loading branch information
1 parent
e1e42ca
commit 8f033c8
Showing
5 changed files
with
235 additions
and
12 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,68 @@ | ||
name: 'Code Health Tools' | ||
|
||
# Set of validations run on each pull request and merged commits to master. | ||
on: | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- 'tools/**' | ||
paths-ignore: # https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#example-excluding-paths | ||
- '*.md' | ||
pull_request: {} | ||
workflow_dispatch: {} | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout CLI | ||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 | ||
with: | ||
path: tools/cli | ||
- 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: Download actionlint | ||
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,135 @@ | ||
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 | ||
# Too many unusued parameters, skipping this check for now | ||
#- name: unused-parameter | ||
- name: unreachable-code | ||
- name: redefines-builtin-id | ||
maligned: | ||
suggest-new: true | ||
misspell: | ||
locale: US | ||
ignore-words: | ||
- cancelled | ||
lll: | ||
# Default is 120. '\t' is counted as 1 character. | ||
# set our project to 500, as we are adding open api field description in the schema. | ||
# also, for anyone using vscode, use the following configs: | ||
# "rewrap.wrappingColumn": 500 ... requires the rewrap plugin | ||
# "editor.rulers": [500] | ||
line-length: 500 | ||
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 | ||
|
||
# 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 | ||
issues: | ||
exclude: | ||
- declaration of ".*" shadows declaration at line .* | ||
exclude-rules: | ||
- linters: | ||
- staticcheck | ||
text: "SA1019:" # d.GetOkExists is deprecated: usage is discouraged due to undefined behaviors and may be removed in a future version of the SDK | ||
- linters: | ||
- gocritic | ||
text: "^hugeParam: req is heavy" | ||
|
||
run: | ||
timeout: 10m | ||
tests: true | ||
build-tags: | ||
- integration | ||
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