From 3e4e9bb85fef71805a8198462a8d5d89aa08643d Mon Sep 17 00:00:00 2001 From: Darren Kelly Date: Fri, 12 Jan 2024 14:02:43 +0000 Subject: [PATCH] chore: update lint config --- .github/CONTRIBUTING.md | 2 +- .github/workflows/lint-go.yaml | 5 ++--- .golangci.pull-request.yml | 13 ------------- .golangci.yml | 12 +++++++----- Makefile | 26 +++++++++++++++++++------- README.md | 2 ++ 6 files changed, 31 insertions(+), 29 deletions(-) delete mode 100644 .golangci.pull-request.yml diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index bce99d7af..653615891 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -61,4 +61,4 @@ current development landscape. ### Code Linting - We employ `golangci-lint` for code linting in our development process. It ensures that code adheres to established standards, and any changes that do not pass the linting checks will trigger an error during the Continuous Integration (CI) process. -- You can run it locally by installing the `golangci-lint` binary and running `golangci-lint run` in the root directory of the repository. +- You can run it locally by installing the `golangci-lint` binary and running `make lint` in the root directory of the repository. diff --git a/.github/workflows/lint-go.yaml b/.github/workflows/lint-go.yaml index 7a782008f..bdea07482 100644 --- a/.github/workflows/lint-go.yaml +++ b/.github/workflows/lint-go.yaml @@ -23,9 +23,8 @@ jobs: uses: golangci/golangci-lint-action@v3 with: version: v1.54 - # use the default if on main branch, otherwise use the pull request config - args: --timeout=30m --config=${{ github.event_name == 'pull_request' && '.golangci.pull-request.yml' || '.golangci.yml' }} - only-new-issues: ${{ github.event_name == 'pull_request' }} + args: --timeout=30m + only-new-issues: true skip-cache: true skip-pkg-cache: true skip-build-cache: true diff --git a/.golangci.pull-request.yml b/.golangci.pull-request.yml deleted file mode 100644 index 4626647a3..000000000 --- a/.golangci.pull-request.yml +++ /dev/null @@ -1,13 +0,0 @@ -# Please refer to the official golangci-lint config documentation for more details: -# https://golangci-lint.run/usage/configuration/ -# https://github.com/golangci/golangci-lint/blob/master/.golangci.reference.yml - -linters: - enable-all: true - -run: - timeout: 10m - tests: false - -issues: - max-issues-per-linter: 1000 diff --git a/.golangci.yml b/.golangci.yml index f6ec24a8d..4626647a3 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,11 +1,13 @@ +# Please refer to the official golangci-lint config documentation for more details: +# https://golangci-lint.run/usage/configuration/ +# https://github.com/golangci/golangci-lint/blob/master/.golangci.reference.yml + +linters: + enable-all: true + run: timeout: 10m tests: false -linters: - disable: - - errcheck - - unused - issues: max-issues-per-linter: 1000 diff --git a/Makefile b/Makefile index 60e01cee8..117eb5d2f 100644 --- a/Makefile +++ b/Makefile @@ -13,12 +13,15 @@ export GO111MODULE=on .PHONY: thor disco all clean test -thor:| go_version_check +help: + @egrep -h '\s#@\s' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?#@ "}; {printf "\033[36m %-30s\033[0m %s\n", $$1, $$2}' + +thor:| go_version_check #@ Build the `thor` executable @echo "building $@..." @go build -v -o $(CURDIR)/bin/$@ -ldflags "-X main.version=$(THOR_VERSION) -X main.gitCommit=$(GIT_COMMIT) -X main.gitTag=$(GIT_TAG)" ./cmd/thor @echo "done. executable created at 'bin/$@'" -disco:| go_version_check +disco:| go_version_check #@ Build the `disco` executable @echo "building $@..." @go build -v -o $(CURDIR)/bin/$@ -ldflags "-X main.version=$(DISCO_VERSION) -X main.gitCommit=$(GIT_COMMIT) -X main.gitTag=$(GIT_TAG)" ./cmd/disco @echo "done. executable created at 'bin/$@'" @@ -37,16 +40,25 @@ go_version_check: fi \ fi -all: thor disco +all: thor disco #@ Build the `thor` and `disco` executables -clean: +clean: #@ Clean the build artifacts -rm -rf \ $(CURDIR)/bin/thor \ -$(CURDIR)/bin/disco +$(CURDIR)/bin/disco -test:| go_version_check +test:| go_version_check #@ Run the tests @go test -cover $(PACKAGES) -test-coverage:| go_version_check +test-coverage:| go_version_check #@ Run the tests with coverage @go test -race -coverprofile=coverage.out -covermode=atomic $(PACKAGES) @go tool cover -html=coverage.out + +lint_command_check: + @command -v golangci-lint || (echo "golangci-lint not found, please install it from https://golangci-lint.run/usage/install/") + +lint: | go_version_check lint_command_check #@ Run 'golangci-lint' on new code changes + @golangci-lint run --new + +lint-all: | go_version_check lint_command_check #@ Run 'golangci-lint' on the entire codebase + @golangci-lint run diff --git a/README.md b/README.md index 3ecaa84e3..05db7599d 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,8 @@ git clone https://github.com/vechain/thor.git cd thor ``` +To see a list of all available commands, run `make help` + ### Building To build the main app `thor`, just run