summaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
authorGusted <williamzijl7@hotmail.com>2021-11-17 05:41:01 +0000
committerGitHub <noreply@github.com>2021-11-17 13:41:01 +0800
commit21f6c0be0886aa5ecd92a65e6d1e2ef247fc73c9 (patch)
tree381aafd76fe885a0be7582c2b7911bbacc36d517 /Makefile
parent42670e6b1c8f6dc34785a2efdacf22b749ce7a28 (diff)
downloadgitea-21f6c0be0886aa5ecd92a65e6d1e2ef247fc73c9.tar.gz
gitea-21f6c0be0886aa5ecd92a65e6d1e2ef247fc73c9.zip
Update golangci-lint in Makefile (#17647)
* Update golangci-lint in Makefile - Partially resolvess #17596 - Download specific version(v1.43.0) by default. - If current installed version is older than the minium version, it will download the mininium required version. - Update the install script to avoid deprecated error `golangci/golangci-lint err this script is deprecated, please do not use it anymore. check https://github.com/goreleaser/godownloader/issues/207` * Simplify golangci-lint version check * Fix version conversion * Add version that's downloading Co-authored-by: zeripath <art27@cantab.net> * Consistency Co-authored-by: zeripath <art27@cantab.net> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile17
1 files changed, 14 insertions, 3 deletions
diff --git a/Makefile b/Makefile
index 6337268c0f..ecd91680ee 100644
--- a/Makefile
+++ b/Makefile
@@ -27,6 +27,7 @@ COMMA := ,
XGO_VERSION := go-1.17.x
MIN_GO_VERSION := 001016000
MIN_NODE_VERSION := 012017000
+MIN_GOLANGCI_LINT_VERSION := 001043000
DOCKER_IMAGE ?= gitea/gitea
DOCKER_TAG ?= latest
@@ -765,12 +766,22 @@ pr\#%: clean-all
$(GO) run contrib/pr/checkout.go $*
.PHONY: golangci-lint
-golangci-lint:
+golangci-lint: golangci-lint-check
+ golangci-lint run --timeout 10m
+
+.PHONY: golangci-lint-check
+golangci-lint-check:
+ $(eval GOLANGCI_LINT_VERSION := $(shell printf "%03d%03d%03d" $(shell golangci-lint --version | grep -Eo '[0-9]+\.[0-9.]+' | tr '.' ' ');))
+ $(eval MIN_GOLANGCI_LINT_VER_FMT := $(shell printf "%g.%g.%g" $(shell echo $(MIN_GOLANGCI_LINT_VERSION) | grep -o ...)))
@hash golangci-lint > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
+ echo "Downloading golangci-lint v${MIN_GOLANGCI_LINT_VER_FMT}"; \
export BINARY="golangci-lint"; \
- curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(GOPATH)/bin v1.37.0; \
+ curl -sfL "https://raw.githubusercontent.com/golangci/golangci-lint/v${MIN_GOLANGCI_LINT_VER_FMT}/install.sh" | sh -s -- -b $(GOPATH)/bin v$(MIN_GOLANGCI_LINT_VER_FMT); \
+ elif [ "$(GOLANGCI_LINT_VERSION)" -lt "$(MIN_GOLANGCI_LINT_VERSION)" ]; then \
+ echo "Downloading newer version of golangci-lint v${MIN_GOLANGCI_LINT_VER_FMT}"; \
+ export BINARY="golangci-lint"; \
+ curl -sfL "https://raw.githubusercontent.com/golangci/golangci-lint/v${MIN_GOLANGCI_LINT_VER_FMT}/install.sh" | sh -s -- -b $(GOPATH)/bin v$(MIN_GOLANGCI_LINT_VER_FMT); \
fi
- golangci-lint run --timeout 10m
.PHONY: docker
docker: