From 1a0dfc5c09bcc50ec451a9254c81b7cabfe8ca8d Mon Sep 17 00:00:00 2001 From: Patrick Ohly Date: Thu, 1 Jun 2023 18:06:50 +0200 Subject: [PATCH] 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. --- .github/workflows/lint.yml | 24 ++++++++++++++++++++++++ .github/workflows/test.yml | 12 ------------ .golangci.yaml | 6 ++++++ 3 files changed, 30 insertions(+), 12 deletions(-) create mode 100644 .github/workflows/lint.yml create mode 100644 .golangci.yaml diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 00000000..b2582a79 --- /dev/null +++ b/.github/workflows/lint.yml @@ -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 }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 870d1a2f..fe8a775a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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 diff --git a/.golangci.yaml b/.golangci.yaml new file mode 100644 index 00000000..0d77d65f --- /dev/null +++ b/.golangci.yaml @@ -0,0 +1,6 @@ +linters: + disable-all: true + enable: # sorted alphabetical + - gofmt + - misspell + - revive