-
Notifications
You must be signed in to change notification settings - Fork 163
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 #196 from henrybear327/ci/add_fmt
[CI] Introduce fmt and linter CI pipeline
- Loading branch information
Showing
11 changed files
with
170 additions
and
35 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,35 @@ | ||
--- | ||
name: Static analysis | ||
on: [push, pull_request] | ||
permissions: read-all | ||
jobs: | ||
run: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-go@v5 | ||
with: | ||
go-version: 1.22 | ||
- name: golangci-lint | ||
uses: golangci/golangci-lint-action@v4 | ||
with: | ||
version: v1.57.1 | ||
args: --config tools/.golangci.yaml | ||
- run: | | ||
set -euo pipefail | ||
make verify | ||
- run: | | ||
set -euo pipefail | ||
make fmt | ||
DIFF=$(git status --porcelain) | ||
if [ -n "$DIFF" ]; then | ||
echo "These files were modified:" | ||
echo | ||
echo "$DIFF" | ||
echo | ||
exit 1 | ||
fi |
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 |
---|---|---|
|
@@ -24,3 +24,4 @@ test: | |
go vet ./... | ||
@echo Testing | ||
go test ./... -skip TestConfig_Load | ||
|
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
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
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
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
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,104 @@ | ||
--- | ||
run: | ||
timeout: 30m | ||
issues: | ||
max-same-issues: 0 | ||
# Excluding configuration per-path, per-linter, per-text and per-source | ||
exclude-rules: | ||
# exclude ineffassing linter for generated files for conversion | ||
- path: conversion\.go | ||
linters: [ineffassign] | ||
exclude-files: | ||
- ^zz_generated.* | ||
linters: | ||
disable-all: true | ||
enable: # please keep this alphabetized | ||
# Don't use soon to deprecated[1] linters that lead to false | ||
# https://github.com/golangci/golangci-lint/issues/1841 | ||
# - deadcode | ||
# - structcheck | ||
# - varcheck | ||
- goimports | ||
- ineffassign | ||
- nakedret | ||
- revive | ||
- staticcheck | ||
- stylecheck | ||
- unconvert # Remove unnecessary type conversions | ||
- unparam | ||
- unused | ||
linters-settings: # please keep this alphabetized | ||
goimports: | ||
local-prefixes: go.etcd.io # Put imports beginning with prefix after 3rd-party packages. | ||
nakedret: | ||
# Align with https://github.com/alexkohler/nakedret/blob/v1.0.2/cmd/nakedret/main.go#L10 | ||
max-func-lines: 5 | ||
revive: | ||
ignore-generated-header: false | ||
severity: error | ||
confidence: 0.8 | ||
enable-all-rules: false | ||
rules: | ||
- name: blank-imports | ||
severity: error | ||
disabled: false | ||
- name: context-as-argument | ||
severity: error | ||
disabled: false | ||
- name: dot-imports | ||
severity: error | ||
disabled: false | ||
- name: error-return | ||
severity: error | ||
disabled: false | ||
- name: error-naming | ||
severity: error | ||
disabled: false | ||
- name: if-return | ||
severity: error | ||
disabled: false | ||
- name: increment-decrement | ||
severity: error | ||
disabled: false | ||
- name: var-declaration | ||
severity: error | ||
disabled: false | ||
- name: package-comments | ||
severity: error | ||
disabled: false | ||
- name: range | ||
severity: error | ||
disabled: false | ||
- name: receiver-naming | ||
severity: error | ||
disabled: false | ||
- name: time-naming | ||
severity: error | ||
disabled: false | ||
- name: indent-error-flow | ||
severity: error | ||
disabled: false | ||
- name: errorf | ||
severity: error | ||
disabled: false | ||
- name: context-keys-type | ||
severity: error | ||
disabled: false | ||
- name: error-strings | ||
severity: error | ||
disabled: false | ||
# TODO: enable the following rules | ||
- name: var-naming | ||
disabled: true | ||
- name: exported | ||
disabled: true | ||
- name: unexported-return | ||
disabled: true | ||
staticcheck: | ||
checks: | ||
- all | ||
- -SA1019 # TODO(fix) Using a deprecated function, variable, constant or field | ||
- -SA2002 # TODO(fix) Called testing.T.FailNow or SkipNow in a goroutine, which isn’t allowed | ||
stylecheck: | ||
checks: | ||
- ST1019 # Importing the same package multiple times. |