Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,21 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: '1.17'
go-version: stable

- name: Lint
- name: Run go fmt
run: go fmt ./...

- name: Install goimports
run: go install golang.org/x/tools/cmd/goimports@latest

- name: Run goimports
run: goimports -w .

- name: Run golangci-lint
uses: golangci/golangci-lint-action@v3
with:
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
version: latest
args: --timeout=5m
- name: Run go mod tidy
run: go mod tidy && git diff --exit-code || (echo "Run 'go mod tidy' locally and commit changes." && exit 1)
20 changes: 20 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
repos:
- repo: https://github.com/dnephin/pre-commit-golang
rev: v0.5.1
hooks:
- id: go-fmt
args: [-s]
- id: go-imports
- id: golangci-lint
args: [--fix]
- id: go-unit-tests
- id: go-mod-tidy

- repo: local
hooks:
- id: go-build-test
name: go build and test
entry: bash -c 'go build ./... && go test ./...'
language: system
types: [go]
pass_filenames: false
Loading