-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Linters: Add github action, update README
Github action will: 1. Lint 2. Format (err if any diff) 3. Run 'go mod tidy' (err if any diff)
- Loading branch information
Showing
2 changed files
with
59 additions
and
0 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,40 @@ | ||
name: Lint golang | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
go: | ||
name: Lint go files | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Setup go | ||
uses: actions/setup-go@v3 | ||
with: | ||
go-version: stable | ||
|
||
- name: Run golangci-lint | ||
uses: golangci/golangci-lint-action@v3 | ||
with: | ||
version: latest | ||
args: --timeout 5m | ||
|
||
- name: Install gofumpt | ||
env: | ||
GOFUMPT_VER: 0.5.0 | ||
run: | | ||
mkdir -v -p "$HOME/.local/bin" | ||
wget -O "$HOME/.local/bin/gofumpt" "https://github.com/mvdan/gofumpt/releases/download/v${GOFUMPT_VER}/gofumpt_v${GOFUMPT_VER}_linux_amd64" | ||
chmod 0700 "$HOME/.local/bin/gofumpt" | ||
- name: Run gofumpt | ||
run: | | ||
find . -type f -name '*.go' ! -name '*.pb.go' | xargs -n1 "$HOME/.local/bin/gofumpt" -w -lang=1.21 | ||
git diff --exit-code | ||
- name: go mod tidy | ||
run: | | ||
go mod tidy | ||
git diff --exit-code -- go.mod go.sum |
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