-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Draft: Add go linter tool and unit testing for Pr build process (#13)
* Add go linter tool * Add unit-test workflow Signed-off-by: Nathalia <[email protected]>
- Loading branch information
Showing
3 changed files
with
77 additions
and
1 deletion.
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,26 @@ | ||
name: PR Build | ||
|
||
on: | ||
pull_request: {} | ||
|
||
jobs: | ||
analysis: | ||
name: PR Build | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: "Checkout code" | ||
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v3.0.2 | ||
|
||
- name: "Setup Go" | ||
uses: actions/setup-go@b22fbbc2921299758641fab08929b4ac52b32923 # v3.2.0 | ||
with: | ||
go-version-file: 'go.mod' | ||
|
||
- name: "Lint" | ||
uses: golangci/golangci-lint-action@537aa1903e5d359d0b27dbc19ddd22c5087f3fbc # v3.2.0 | ||
with: | ||
version: v1.47.2 | ||
|
||
- name: "Unit test" | ||
run: make test |
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,45 @@ | ||
[output] | ||
format = "colored-line-number" | ||
|
||
[linters] | ||
enable = [ | ||
# Visit https://golangci-lint.run/usage/linters/ | ||
# for the full, current list of available linters. | ||
|
||
# Default linters | ||
"deadcode", # Finds unused code | ||
"errcheck", # Detect unchecked errors | ||
"gosimple", # Suggest code simplifications | ||
"govet", # Reports suspicious constructs | ||
"ineffassign", # Detects unused variable assignments | ||
"staticcheck", # go vet on steroids | ||
# "structcheck", # Find unused struct fields | ||
"typecheck", # Standard Go type checks | ||
"unused", # Detect unused constants, variables, functions and types | ||
"varcheck", # Find unused global variables and constants | ||
|
||
# Suggested additional linters | ||
"gocyclo", # or "cyclop", # Detect cyclomatic complexity | ||
"goconst", # Detect repeated values that can be made constants | ||
"gofumpt", # Or "gofmt", # Enforce standard formatting | ||
"goimports", # Ensure standard import formatting/ordering | ||
"misspell", # Fix spelling errors | ||
"revive", # General purpose linter | ||
"unconvert", # Detect unnecessary type conversions | ||
"unparam", # Detect unused function parameters | ||
|
||
# Optional | ||
"bodyclose", # Check whether HTTP response bodies are closed | ||
# "goerr113", # Enforce standard error handling practices | ||
# "depguard", # Forbid certain package imports | ||
# "dupl", # Detect duplicate code | ||
# "errchkjson", # some JSON-specific checks | ||
# "gomnd", # Magic number detection | ||
"nakedret", # Detect naked returns | ||
# "rowserrcheck", # Check whether Err of rows is checked | ||
# "sqlclosecheck", # Ensure sql.Rows and sql.Stmt are closed | ||
"tparallel", # Detects inappropriate use of t.Parallel() | ||
] | ||
|
||
[issues] | ||
exclude-use-default = 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