Skip to content

Commit

Permalink
add linter rules, update github actions (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
miparnisari authored Feb 19, 2024
1 parent 3037838 commit bfebb53
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 15 deletions.
25 changes: 10 additions & 15 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,40 +12,35 @@ jobs:
steps:

- name: Set up Go
uses: actions/setup-go@v2
uses: actions/setup-go@v5
with:
stable: 'false'
go-version: '1.21'

- name: Checkout
uses: actions/checkout@v1
uses: actions/checkout@v4
with:
fetch-depth: 1

- name: Cache Go modules
uses: actions/cache@v1
uses: actions/cache@v4
with:
path: ~/go/pkg/mod
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-build-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.OS }}-build-${{ env.cache-name }}-
${{ runner.OS }}-build-
${{ runner.OS }}-
- name: Lint
uses: golangci/golangci-lint-action@v2
uses: golangci/golangci-lint-action@v4
with:
version: v1.54.2
args: --timeout 10m

- name: Vet
if: matrix.os == 'ubuntu-latest'
run: go vet -v ./...
version: latest
args: -v -c .golangci.yaml

- name: Build
env:
CGO_ENABLED: 0
run: go build -ldflags "-s -w" ./...

- name: Test
run: go test -v -race ./...
run: go test -v -count=1 -race ./...
36 changes: 36 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
run:
timeout: 10m
allow-parallel-runners: true

linters:
enable:
- errname
- stylecheck
- importas
- errcheck
- gosimple
- govet
- ineffassign
- mirror
- staticcheck
- tagalign
- testifylint
- typecheck
- unused
- unconvert
- wastedassign
- whitespace
- gocritic
- exhaustive
- noctx
- promlinter
# TODO these fail on windows
# - gofmt
# - goimports

linters-settings:
govet:
enable-all: true
disable:
- shadow
- fieldalignment

0 comments on commit bfebb53

Please sign in to comment.