From aa0c389d2b9681a4a068337a89846d8bb404bbf0 Mon Sep 17 00:00:00 2001 From: mmetc <92726601+mmetc@users.noreply.github.com> Date: Tue, 9 Jul 2024 14:49:55 +0200 Subject: [PATCH] make: remove redundant go version check (#3118) It's already done by the toolchain with go.mod --- Makefile | 19 +++++++------------ mk/check_go_version.ps1 | 19 ------------------- mk/goversion.mk | 36 ------------------------------------ 3 files changed, 7 insertions(+), 67 deletions(-) delete mode 100644 mk/check_go_version.ps1 delete mode 100644 mk/goversion.mk diff --git a/Makefile b/Makefile index 324be04683d..97eb7ba0eea 100644 --- a/Makefile +++ b/Makefile @@ -25,10 +25,6 @@ BUILD_STATIC ?= 0 # List of plugins to build PLUGINS ?= $(patsubst ./cmd/notification-%,%,$(wildcard ./cmd/notification-*)) -# Can be overriden, if you can deal with the consequences -BUILD_REQUIRE_GO_MAJOR ?= 1 -BUILD_REQUIRE_GO_MINOR ?= 21 - #-------------------------------------- GO = go @@ -128,10 +124,10 @@ endif #-------------------------------------- .PHONY: build -build: pre-build goversion crowdsec cscli plugins ## Build crowdsec, cscli and plugins +build: build-info crowdsec cscli plugins ## Build crowdsec, cscli and plugins -.PHONY: pre-build -pre-build: ## Sanity checks and build information +.PHONY: build-info +build-info: ## Print build information $(info Building $(BUILD_VERSION) ($(BUILD_TAG)) $(BUILD_TYPE) for $(GOOS)/$(GOARCH)) ifneq (,$(RE2_FAIL)) @@ -195,11 +191,11 @@ clean: clean-debian clean-rpm testclean ## Remove build artifacts ) .PHONY: cscli -cscli: goversion ## Build cscli +cscli: ## Build cscli @$(MAKE) -C $(CSCLI_FOLDER) build $(MAKE_FLAGS) .PHONY: crowdsec -crowdsec: goversion ## Build crowdsec +crowdsec: ## Build crowdsec @$(MAKE) -C $(CROWDSEC_FOLDER) build $(MAKE_FLAGS) .PHONY: generate @@ -223,11 +219,11 @@ testenv: @echo 'NOTE: You need to run "make localstack" in a separate shell, "make localstack-stop" to terminate it' .PHONY: test -test: testenv goversion ## Run unit tests with localstack +test: testenv ## Run unit tests with localstack $(GOTEST) $(LD_OPTS) ./... .PHONY: go-acc -go-acc: testenv goversion ## Run unit tests with localstack + coverage +go-acc: testenv ## Run unit tests with localstack + coverage go-acc ./... -o coverage.out --ignore database,notifications,protobufs,cwversion,cstest,models -- $(LD_OPTS) check_docker: @@ -305,5 +301,4 @@ else include test/bats.mk endif -include mk/goversion.mk include mk/help.mk diff --git a/mk/check_go_version.ps1 b/mk/check_go_version.ps1 deleted file mode 100644 index 6060cb22751..00000000000 --- a/mk/check_go_version.ps1 +++ /dev/null @@ -1,19 +0,0 @@ -##This must be called with $(MINIMUM_SUPPORTED_GO_MAJOR_VERSION) $(MINIMUM_SUPPORTED_GO_MINOR_VERSION) in this order -$min_major=$args[0] -$min_minor=$args[1] -$goversion = (go env GOVERSION).replace("go","").split(".") -$goversion_major=$goversion[0] -$goversion_minor=$goversion[1] -$err_msg="Golang version $goversion_major.$goversion_minor is not supported, please use least $min_major.$min_minor" - -if ( $goversion_major -gt $min_major ) { - exit 0; -} -elseif ($goversion_major -lt $min_major) { - Write-Output $err_msg; - exit 1; -} -elseif ($goversion_minor -lt $min_minor) { - Write-Output $(GO_VERSION_VALIDATION_ERR_MSG); - exit 1; -} diff --git a/mk/goversion.mk b/mk/goversion.mk deleted file mode 100644 index 73e9a72e232..00000000000 --- a/mk/goversion.mk +++ /dev/null @@ -1,36 +0,0 @@ - -BUILD_GOVERSION = $(subst go,,$(shell $(GO) env GOVERSION)) - -go_major_minor = $(subst ., ,$(BUILD_GOVERSION)) -GO_MAJOR_VERSION = $(word 1, $(go_major_minor)) -GO_MINOR_VERSION = $(word 2, $(go_major_minor)) - -GO_VERSION_VALIDATION_ERR_MSG = Golang version ($(BUILD_GOVERSION)) is not supported, please use at least $(BUILD_REQUIRE_GO_MAJOR).$(BUILD_REQUIRE_GO_MINOR) - - -.PHONY: goversion -goversion: $(if $(findstring devel,$(shell $(GO) env GOVERSION)),goversion_devel,goversion_check) - - -.PHONY: goversion_devel -goversion_devel: - $(warning WARNING: You are using a development version of Golang ($(BUILD_GOVERSION)) which is not supported. For production environments, use a stable version (at least $(BUILD_REQUIRE_GO_MAJOR).$(BUILD_REQUIRE_GO_MINOR))) - $(info ) - - -.PHONY: goversion_check -goversion_check: -ifneq ($(OS), Windows_NT) - @if [ $(GO_MAJOR_VERSION) -gt $(BUILD_REQUIRE_GO_MAJOR) ]; then \ - exit 0; \ - elif [ $(GO_MAJOR_VERSION) -lt $(BUILD_REQUIRE_GO_MAJOR) ]; then \ - echo '$(GO_VERSION_VALIDATION_ERR_MSG)';\ - exit 1; \ - elif [ $(GO_MINOR_VERSION) -lt $(BUILD_REQUIRE_GO_MINOR) ] ; then \ - echo '$(GO_VERSION_VALIDATION_ERR_MSG)';\ - exit 1; \ - fi -else - # This needs Set-ExecutionPolicy -Scope CurrentUser Unrestricted - @$(CURDIR)/mk/check_go_version.ps1 $(BUILD_REQUIRE_GO_MAJOR) $(BUILD_REQUIRE_GO_MINOR) -endif