From 86e9bb41f6bd8c503c590d001e18ce3109cb64f6 Mon Sep 17 00:00:00 2001 From: Fabian Holler Date: Tue, 19 Apr 2022 18:29:32 +0200 Subject: [PATCH 1/2] ci: run golangci-lint Add a github action workflow to run golangci-lint. golangci-lint is configured to only show new issues from PRs. When all existing issues in the main branch are fixed (or excluded), only-new-issues could be set to false. ci: add golangci.yml config file add a config file to be able to include the integrationtests, this prevents that code used only in integrationtests is reported as unused --- .github/workflows/golangci-lint.yml | 26 ++++++++++++++++++++++++++ .golangci.yml | 3 +++ 2 files changed, 29 insertions(+) create mode 100644 .github/workflows/golangci-lint.yml create mode 100644 .golangci.yml diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml new file mode 100644 index 0000000..c1eac69 --- /dev/null +++ b/.github/workflows/golangci-lint.yml @@ -0,0 +1,26 @@ +name: golangci-lint +on: + push: + branches: + - main + pull_request: + branches: + - "*" + +permissions: + contents: read +jobs: + golangci: + name: lint + runs-on: ubuntu-latest + steps: + - uses: actions/setup-go@v3 + with: + go-version: 1.18 + - uses: actions/checkout@v3 + - name: golangci-lint + uses: golangci/golangci-lint-action@v3 + with: + version: v1.45 + + only-new-issues: true diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 0000000..4341bcf --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,3 @@ +run: + build-tags: + - integration From e0895b3ba0b49cd26429343db25c58da593d6d83 Mon Sep 17 00:00:00 2001 From: Fabian Holler Date: Wed, 20 Apr 2022 11:32:44 +0200 Subject: [PATCH 2/2] make: add check target Add a makefile target called "check" that runs golangci-lint make: remove vet target The vet target is not needed anymore, "go vet" is also run via the check target by golangci-lint Add install for `golangci-lint` --- .github/workflows/golangci-lint.yml | 1 - CONTRIBUTING.md | 3 ++- Makefile | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index c1eac69..35800e1 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -22,5 +22,4 @@ jobs: uses: golangci/golangci-lint-action@v3 with: version: v1.45 - only-new-issues: true diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 75a32b7..766e98b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,7 +1,8 @@ ## Prerequisites 1. Go: [https://golang.org/dl/](https://golang.org/dl/) -1. Golint `go get -u -v github.com/golang/lint/golint` +1. `golint`: `go get -u -v github.com/golang/lint/golint` +1. `golangci-lint` (Optional for `make check`): [installation docs](https://golangci-lint.run/usage/install/) ## Contributing diff --git a/Makefile b/Makefile index b3ca59d..f601fad 100644 --- a/Makefile +++ b/Makefile @@ -10,10 +10,10 @@ list: ## list Makefile targets fmt: ## Run go fmt against code go fmt ./... -.PHONY: vet -vet: ## Run go vet against code - go vet ./... - .PHONY: tests tests: ## Run all tests and requires a running rabbitmq-server env AMQP_URL=amqp://guest:guest@127.0.0.1:5672/ go test -cpu 1,2 -race -v -tags integration + +.PHONY: check +check: + golangci-lint run ./...