Skip to content

Commit 1a0dfc5

Browse files
committed
github: run golangci-lint via action
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.
1 parent ef25537 commit 1a0dfc5

File tree

3 files changed

+30
-12
lines changed

3 files changed

+30
-12
lines changed

.github/workflows/lint.yml

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Run lint
2+
3+
on: [ push, pull_request ]
4+
5+
permissions:
6+
contents: read
7+
8+
jobs:
9+
lint:
10+
strategy:
11+
matrix:
12+
path:
13+
- .
14+
- examples
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v2
19+
- name: Lint
20+
uses: golangci/golangci-lint-action@v2
21+
with:
22+
# version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
23+
version: latest
24+
working-directory: ${{ matrix.path }}

.github/workflows/test.yml

-12
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,6 @@ jobs:
2020
go test -v -race ./...
2121
- name: Test examples
2222
run: cd examples && go test -v -race ./...
23-
lint:
24-
runs-on: ubuntu-latest
25-
steps:
26-
- name: Install Go
27-
uses: actions/setup-go@v1
28-
- name: Checkout code
29-
uses: actions/checkout@v2
30-
- name: Lint
31-
run: |
32-
docker run --rm -v `pwd`:/go/src/k8s.io/klog -w /go/src/k8s.io/klog \
33-
golangci/golangci-lint:v1.50.1 golangci-lint run --disable-all -v \
34-
-E govet -E misspell -E gofmt -E ineffassign -E golint
3523
apidiff:
3624
runs-on: ubuntu-latest
3725
if: github.base_ref

.golangci.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
linters:
2+
disable-all: true
3+
enable: # sorted alphabetical
4+
- gofmt
5+
- misspell
6+
- revive

0 commit comments

Comments
 (0)