Skip to content

Commit

Permalink
github: run golangci-lint via action
Browse files Browse the repository at this point in the history
The main advantage is that issues get posted as annotations, which makes them
easier to find when looking at a diff for a PR.

While at it, golangci-lint gets invoked so that it runs in its default
configuration plus the linters that were enabled explicitly before (misspell,
gofmt, revive as replacement for golint).

It also gets applied to the examples package.
  • Loading branch information
pohly committed Jun 1, 2023
1 parent 06c84ff commit 2a4075d
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 12 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Run lint

on: [ push, pull_request ]

permissions:
contents: read

jobs:
lint:
strategy:
matrix:
path:
- .
- examples
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Lint
uses: golangci/golangci-lint-action@v2
with:
# version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
version: latest
working-directory: ${{ matrix.path }}
12 changes: 0 additions & 12 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,6 @@ jobs:
go test -v -race ./...
- name: Test examples
run: cd examples && go test -v -race ./...
lint:
runs-on: ubuntu-latest
steps:
- name: Install Go
uses: actions/setup-go@v1
- name: Checkout code
uses: actions/checkout@v2
- name: Lint
run: |
docker run --rm -v `pwd`:/go/src/k8s.io/klog -w /go/src/k8s.io/klog \
golangci/golangci-lint:v1.50.1 golangci-lint run --disable-all -v \
-E govet -E misspell -E gofmt -E ineffassign -E golint
apidiff:
runs-on: ubuntu-latest
if: github.base_ref
Expand Down
6 changes: 6 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
linters:
disable-all: true
enable: # sorted alphabetical
- gofmt
- misspell
- revive

0 comments on commit 2a4075d

Please sign in to comment.