-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Configure linter * Update CONTRIBUTING.md * Lowercase for log message * Rename stats -> metrics * Update CI workflow * Enable imports linter
- Loading branch information
1 parent
707fc82
commit acc6276
Showing
31 changed files
with
333 additions
and
182 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,110 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
branches: [ master ] | ||
pull_request: | ||
branches: [ master ] | ||
|
||
jobs: | ||
test: | ||
runs-on: ${{ matrix.runner }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
go: | ||
- 1.18 | ||
arch: | ||
- amd64 | ||
runner: | ||
- ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Install Go | ||
uses: actions/setup-go@v3 | ||
with: | ||
go-version: ${{ matrix.go }} | ||
|
||
- name: Get Go environment | ||
id: go-env | ||
run: | | ||
echo "::set-output name=cache::$(go env GOCACHE)" | ||
echo "::set-output name=modcache::$(go env GOMODCACHE)" | ||
- name: Set up cache | ||
uses: actions/cache@v3 | ||
with: | ||
path: | | ||
${{ steps.go-env.outputs.cache }} | ||
${{ steps.go-env.outputs.modcache }} | ||
key: test-${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | ||
restore-keys: | | ||
test-${{ runner.os }}-go- | ||
- name: Build | ||
env: | ||
GOARCH: ${{ matrix.arch }} | ||
GOFLAGS: ${{ matrix.flags }} | ||
run: go build ./... | ||
|
||
- name: Test | ||
env: | ||
GOARCH: ${{ matrix.arch }} | ||
GOFLAGS: ${{ matrix.flags }} | ||
LOG_LEVEL: error | ||
run: go test -v ./... | ||
|
||
lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Install Go | ||
uses: actions/setup-go@v3 | ||
with: | ||
go-version: 1.18 | ||
|
||
- name: Lint | ||
uses: golangci/golangci-lint-action@v3 | ||
with: | ||
version: v1.45.2 | ||
only-new-issues: true | ||
args: --timeout 5m | ||
|
||
# Check if there are any dirty changes after go mod tidy & make gen-doc | ||
dirty-changes: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Install Go | ||
uses: actions/setup-go@v3 | ||
with: | ||
go-version: 1.18 | ||
|
||
- name: Get Go environment | ||
id: go-env | ||
run: | | ||
echo "::set-output name=cache::$(go env GOCACHE)" | ||
echo "::set-output name=modcache::$(go env GOMODCACHE)" | ||
- name: Set up cache | ||
uses: actions/cache@v3 | ||
with: | ||
path: | | ||
${{ steps.go-env.outputs.cache }} | ||
${{ steps.go-env.outputs.modcache }} | ||
key: dirty-changes-${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | ||
restore-keys: | | ||
dirty-changes-${{ runner.os }}-go- | ||
- name: Download dependencies | ||
run: go mod download && go mod tidy | ||
|
||
- name: Generate doc | ||
run: make gen-doc | ||
|
||
- name: Check git diff | ||
run: git diff --exit-code |
This file was deleted.
Oops, something went wrong.
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,84 @@ | ||
linters-settings: | ||
govet: | ||
enable: | ||
- composites | ||
dupl: | ||
threshold: 120 | ||
goconst: | ||
min-len: 2 | ||
min-occurrences: 3 | ||
misspell: | ||
locale: US | ||
gocritic: | ||
enabled-tags: | ||
- diagnostic | ||
- experimental | ||
- opinionated | ||
- performance | ||
- style | ||
disabled-checks: | ||
- whyNoLint | ||
- commentFormatting # insane-doc syntax requires "//>" format | ||
- paramTypeCombine | ||
- ptrToRefParam # we use interface pointer in many places | ||
- unnamedResult | ||
- sprintfQuotedString | ||
- tooManyResultsChecker | ||
gosec: | ||
excludes: | ||
- G304 # Potential file inclusion via variable -- it's ok for this project | ||
stylecheck: | ||
checks: | ||
- '-ST1021' # insane-doc syntax requires "//>" format | ||
|
||
linters: | ||
disable-all: true | ||
enable: | ||
- deadcode | ||
- depguard | ||
- dogsled | ||
- dupl | ||
- goconst | ||
- gocritic | ||
- goimports | ||
- gosimple | ||
- govet | ||
- ineffassign | ||
- misspell | ||
- nakedret | ||
- prealloc | ||
- structcheck | ||
- stylecheck | ||
- typecheck | ||
- unconvert | ||
- unparam | ||
- unused | ||
- varcheck | ||
- whitespace | ||
# Do not enable: | ||
# - staticcheck (does not work with golangci-lint 1.46.2 and go 1.18.2) | ||
# - gosec (not worth it in scope of this project) | ||
# - gochecknoglobals (we know when it is ok to use globals) | ||
# - gochecknoinits (we know when it is ok to use inits) | ||
# - errcheck | ||
|
||
issues: | ||
exclude-use-default: false | ||
exclude-rules: | ||
# Disable linters that are annoying in tests. | ||
- path: _test\.go | ||
linters: | ||
- gocyclo | ||
- errcheck | ||
- dupl | ||
- gosec | ||
- goconst | ||
|
||
# Ignore shadowing of err. | ||
- linters: [ govet ] | ||
text: 'declaration of "(err|ctx)"' | ||
|
||
run: | ||
build-tags: | ||
- e2e | ||
- fuzz |
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
Oops, something went wrong.