Skip to content

Commit 21f6c0b

Browse files
Gustedzeripathlunnytechknowlogick
authored
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 <[email protected]> * Consistency Co-authored-by: zeripath <[email protected]> Co-authored-by: Lunny Xiao <[email protected]> Co-authored-by: techknowlogick <[email protected]>
1 parent 42670e6 commit 21f6c0b

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

Makefile

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ COMMA := ,
2727
XGO_VERSION := go-1.17.x
2828
MIN_GO_VERSION := 001016000
2929
MIN_NODE_VERSION := 012017000
30+
MIN_GOLANGCI_LINT_VERSION := 001043000
3031

3132
DOCKER_IMAGE ?= gitea/gitea
3233
DOCKER_TAG ?= latest
@@ -765,12 +766,22 @@ pr\#%: clean-all
765766
$(GO) run contrib/pr/checkout.go $*
766767

767768
.PHONY: golangci-lint
768-
golangci-lint:
769+
golangci-lint: golangci-lint-check
770+
golangci-lint run --timeout 10m
771+
772+
.PHONY: golangci-lint-check
773+
golangci-lint-check:
774+
$(eval GOLANGCI_LINT_VERSION := $(shell printf "%03d%03d%03d" $(shell golangci-lint --version | grep -Eo '[0-9]+\.[0-9.]+' | tr '.' ' ');))
775+
$(eval MIN_GOLANGCI_LINT_VER_FMT := $(shell printf "%g.%g.%g" $(shell echo $(MIN_GOLANGCI_LINT_VERSION) | grep -o ...)))
769776
@hash golangci-lint > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
777+
echo "Downloading golangci-lint v${MIN_GOLANGCI_LINT_VER_FMT}"; \
770778
export BINARY="golangci-lint"; \
771-
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(GOPATH)/bin v1.37.0; \
779+
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); \
780+
elif [ "$(GOLANGCI_LINT_VERSION)" -lt "$(MIN_GOLANGCI_LINT_VERSION)" ]; then \
781+
echo "Downloading newer version of golangci-lint v${MIN_GOLANGCI_LINT_VER_FMT}"; \
782+
export BINARY="golangci-lint"; \
783+
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); \
772784
fi
773-
golangci-lint run --timeout 10m
774785

775786
.PHONY: docker
776787
docker:

0 commit comments

Comments
 (0)