Skip to content

Commit

Permalink
Add linting to CI
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Shen <[email protected]>
  • Loading branch information
mjlshen authored and Matthew Barnes committed Mar 21, 2024
1 parent 5347c44 commit 1e89a14
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 0 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/ci-go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,23 @@ jobs:

- name: 'Test'
run: make test
lint:
permissions:
contents: 'read'
runs-on: 'ubuntu-latest'
steps:
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
with:
fetch-depth: 1

- name: 'Set up Go'
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
with:
go-version-file: 'go.work'
check-latest: true

- name: 'Lint'
uses: golangci/golangci-lint-action@3cfe3a4abbb849e10058ce4af15d205b6da42804 # v4.0.0
with:
version: 'v1.56.2'
args: '-v $(go list -f ''{{.Dir}}/...'' -m | xargs)'
21 changes: 21 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
run:
timeout: 10m
skip-dirs-use-default: true
modules-download-mode: readonly

issues:
# We want to make sure we get a full report every time. Setting these
# to zero disables the limit.
max-issues-per-linter: 0
max-same-issues: 0

linters:
disable-all: true
enable:
- errcheck
- gosimple
- govet
- ineffassign
- staticcheck
- typecheck
- unused
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
SHELL = /bin/bash

all: test lint

# There is currently no convenient way to run tests against a whole Go workspace
# https://github.com/golang/go/issues/50745
test:
go list -f '{{.Dir}}/...' -m | xargs go test -cover

# There is currently no convenient way to run golangci-lint against a whole Go workspace
# https://github.com/golang/go/issues/50745
MODULES := $(shell go list -f '{{.Dir}}/...' -m | xargs)
lint:
golangci-lint run -v $(MODULES)

0 comments on commit 1e89a14

Please sign in to comment.