Skip to content

Commit

Permalink
Add verify-go-version target
Browse files Browse the repository at this point in the history
  • Loading branch information
kishen-v committed Dec 15, 2023
1 parent e0689f4 commit 5078660
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ IMG ?= controller:latest
# Produce CRDs that work back to Kubernetes 1.11 (no version conversion)
CRD_OPTIONS ?= "crd:crdVersions=v1"

SHELL=/bin/bash

# Directories.
REPO_ROOT := $(shell git rev-parse --show-toplevel)
ARTIFACTS ?= $(REPO_ROOT)/_artifacts
Expand Down Expand Up @@ -483,7 +485,7 @@ define checkdiff
git --no-pager diff --name-only FETCH_HEAD
endef

ALL_VERIFY_CHECKS = boilerplate shellcheck modules gen conversions
ALL_VERIFY_CHECKS = boilerplate shellcheck modules gen conversions go-version

.PHONY: verify
verify: $(addprefix verify-,$(ALL_VERIFY_CHECKS)) ## Run all verify-* targets
Expand Down Expand Up @@ -539,6 +541,26 @@ verify-security: ## Verify code and images for vulnerabilities
exit 1; \
fi

.SILENT:
.PHONY: verify-go-version
verify-go-version: ## Confirms the availability of minor/patch release.
available_version=$$(curl -s "https://go.dev/dl/?mode=json" | jq ".[1].version" | tr -d '"'); \
avl_minor_patch_version=$$(echo $$available_version | awk -F'.' '{print $$(NF-1),$$(NF)}'); \
IFS=' ' read -r available_minor available_patch <<< "$$avl_minor_patch_version"; \
current_minor_patch_version=$$(echo $(GO_VERSION)| awk -F'.' '{print $$(NF-1),$$(NF)}'); \
IFS=' ' read -r current_minor current_patch <<< "$$current_minor_patch_version"; \
if [ $$current_minor -le $$available_minor ]; then \
if [ $$current_patch -lt $$available_patch ] || [ $$current_minor -lt $$available_minor ]; then \
echo "::warning ::Update GO_VERSION to $$available_version"; \
echo "$$available_version is available on go.dev, the version in Makefile is $(GO_VERSION)".; \
echo "Consider bumping the version, run make update-go VERSION=$$available_version to update across all files."; \
else \
echo "Golang version is up to date."; \
fi \
else \
echo "Golang version is up to date."; \
fi

## --------------------------------------
## Cleanup / Verification
## --------------------------------------
Expand Down Expand Up @@ -607,7 +629,7 @@ go-version: ## Print the go version we use to compile our binaries and images

.PHONY: serve
serve: ## Build the CAPIBM book and serve it locally to validate changes in documentation.
make -C docs/book/ serve
$(MAKE) -C docs/book/ serve

## --------------------------------------
## Update Go Version
Expand Down

0 comments on commit 5078660

Please sign in to comment.