Skip to content

Commit

Permalink
Replace linters with golangci-lint (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisnovakovic authored Feb 19, 2024
1 parent 6c88ae7 commit 67691df
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 29 deletions.
28 changes: 13 additions & 15 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,33 @@ on:
pull_request:
workflow_dispatch:

permissions:
contents: read
pull-requests: read
checks: write

jobs:
test:
name: Test and lint
strategy:
fail-fast: false
matrix:
go: [ '1.18', '1.17' ]
go: [ '1.22', '1.21' ]
os: [ 'windows-latest', 'ubuntu-latest', 'macOS-latest' ]
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
- uses: actions/checkout@v4

- uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go }}
check-latest: true

- name: Run go fmt (Go ${{ matrix.go }})
if: runner.os != 'Windows'
run: diff -u <(echo -n) <(gofmt -d -s .)

- name: Run go vet
run: make vet

- name: Run staticcheck (Go ${{ matrix.go }})
uses: dominikh/[email protected]
- name: Run golangci-lint (Go ${{ matrix.go }})
uses: golangci/golangci-lint-action@v4
with:
version: "2022.1"
install-go: false
cache-key: ${{ matrix.go }}
version: v1.56

- name: Run Unit tests (Go ${{ matrix.go }})
run: make test
8 changes: 8 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
run:
timeout: 5m

issues:
exclude-rules:
- path: _test\.go
linters:
- errcheck
15 changes: 1 addition & 14 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,5 @@ help: ## Outputs the help.
test: ## Runs all unit, integration and example tests.
go test -race -v ./...

.PHONY: vet
vet: ## Runs go vet (to detect suspicious constructs).
go vet ./...

.PHONY: fmt
fmt: ## Runs go fmt (to check for go coding guidelines).
gofmt -d -s .

.PHONY: staticcheck
staticcheck: ## Runs static analysis to prevend bugs, foster code simplicity, performance and editor integration.
go install honnef.co/go/tools/cmd/[email protected]
staticcheck ./...

.PHONY: all
all: test vet fmt staticcheck ## Runs all source code quality targets (like test, vet, fmt, staticcheck)
all: test

0 comments on commit 67691df

Please sign in to comment.