-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
makefile enhancements #95
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,32 @@ | ||
SHELL := /bin/bash | ||
|
||
MKFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST))) | ||
MKFILE_PATH := $(abspath $(firstword $(MAKEFILE_LIST))) | ||
PROJECT_PATH := $(patsubst %/,%,$(dir $(MKFILE_PATH))) | ||
GO ?= go | ||
|
||
all: help | ||
|
||
.PHONY : help | ||
help: Makefile | ||
@sed -n 's/^##//p' $< | ||
|
||
# Ginkgo tool | ||
GINKGO = $(PROJECT_PATH)/bin/ginkgo | ||
$(GINKGO): | ||
# In order to make sure the version of the ginkgo cli installed | ||
# is the same as the version of go.mod, | ||
# instead of calling go-install-tool, | ||
# running go install from the current module will pick version from current go.mod file. | ||
GOBIN=$(PROJECT_PATH)/bin go install github.com/onsi/ginkgo/v2/ginkgo | ||
|
||
.PHONY: ginkgo | ||
ginkgo: $(GINKGO) ## Download ginkgo locally if necessary. | ||
|
||
KIND = $(PROJECT_PATH)/bin/kind | ||
KIND_VERSION = v0.22.0 | ||
$(KIND): | ||
$(call go-install-tool,$(KIND),sigs.k8s.io/kind@$(KIND_VERSION)) | ||
# The help target prints out all targets with their descriptions organized | ||
# beneath their categories. The categories are represented by '##@' and the | ||
# target descriptions by '##'. The awk commands is responsible for reading the | ||
# entire set of makefiles included in this invocation, looking for lines of the | ||
# file as xyz: ## something, and then pretty-format the target and help. Then, | ||
# if there's a line with ##@ something, that gets pretty-printed as a category. | ||
# More info on the usage of ANSI control characters for terminal formatting: | ||
# https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_parameters | ||
# More info on the awk command: | ||
# http://linuxcommand.org/lc3_adv_awk.php | ||
|
||
.PHONY: kind | ||
kind: $(KIND) ## Download kind locally if necessary. | ||
.PHONY : help | ||
help: ## Display this help. | ||
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-30s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) | ||
|
||
KUSTOMIZE = $(PROJECT_PATH)/bin/kustomize | ||
$(KUSTOMIZE): | ||
$(call go-install-tool,$(KUSTOMIZE),sigs.k8s.io/kustomize/kustomize/[email protected]) | ||
include ./make/tools/*.mk | ||
|
||
.PHONY: kustomize | ||
kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary. | ||
##@ Development | ||
|
||
## test: Run unit tests | ||
.PHONY : test | ||
test: clean-cov fmt vet $(GINKGO) | ||
test: clean-cov fmt vet $(GINKGO) ## Run unit tests | ||
mkdir -p $(PROJECT_PATH)/coverage | ||
# Shuffle both the order in which specs within a suite run, and the order in which different suites run | ||
# You can always rerun a given ordering later by passing the --seed flag a matching seed. | ||
|
@@ -51,9 +38,9 @@ test: clean-cov fmt vet $(GINKGO) | |
--coverprofile cover.out \ | ||
./pkg/... ./cmd/... | ||
|
||
## install: Build and install kuadrantctl binary ($GOBIN or GOPATH/bin) | ||
|
||
.PHONY : install | ||
install: fmt vet | ||
install: fmt vet ## Build and install kuadrantctl binary ($GOBIN or GOPATH/bin) | ||
@set -e; \ | ||
GIT_SHA=$$(git rev-parse --short=7 HEAD 2>/dev/null) || { \ | ||
GIT_HASH=$${GITHUB_SHA:-NO_SHA}; \ | ||
|
@@ -79,28 +66,30 @@ prepare-local-cluster: $(KIND) ## Deploy locally kuadrant operator from the curr | |
env-setup: | ||
$(MAKE) gateway-api-install | ||
|
||
## local-setup: Sets up Kind cluster with GatewayAPI manifests and istio GW, nothing Kuadrant. Build and install kuadrantctl binary | ||
.PHONY: local-setup | ||
local-setup: | ||
local-setup: ## Sets up Kind cluster with GatewayAPI manifests | ||
$(MAKE) prepare-local-cluster | ||
$(MAKE) env-setup | ||
|
||
## local-cleanup: Delete local cluster | ||
.PHONY: local-cleanup | ||
local-cleanup: ## Delete local cluster | ||
$(MAKE) kind-delete-cluster | ||
|
||
.PHONY : fmt | ||
fmt: | ||
fmt: ## Run go fmt ./... | ||
$(GO) fmt ./... | ||
|
||
.PHONY : vet | ||
vet: | ||
vet: ## Run go vet ./... | ||
$(GO) vet ./... | ||
|
||
.PHONY: clean-cov | ||
clean-cov: ## Remove coverage reports | ||
rm -rf $(PROJECT_PATH)/coverage | ||
|
||
.PHONY: run-lint | ||
run-lint: $(GOLANGCI-LINT) ## Run linter tool (golangci-lint) | ||
$(GOLANGCI-LINT) run --timeout 2m | ||
|
||
# Include last to avoid changing MAKEFILE_LIST used above | ||
include ./make/*.mk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
GINKGO = $(PROJECT_PATH)/bin/ginkgo | ||
$(GINKGO): | ||
# In order to make sure the version of the ginkgo cli installed | ||
# is the same as the version of go.mod, | ||
# instead of calling go-install-tool, | ||
# running go install from the current module will pick version from current go.mod file. | ||
GOBIN=$(PROJECT_PATH)/bin go install github.com/onsi/ginkgo/v2/ginkgo | ||
|
||
.PHONY: ginkgo | ||
ginkgo: $(GINKGO) ## Download ginkgo locally if necessary. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
KIND = $(PROJECT_PATH)/bin/kind | ||
KIND_VERSION = v0.22.0 | ||
$(KIND): | ||
$(call go-install-tool,$(KIND),sigs.k8s.io/kind@$(KIND_VERSION)) | ||
|
||
.PHONY: kind | ||
kind: $(KIND) ## Download kind locally if necessary. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
KUSTOMIZE = $(PROJECT_PATH)/bin/kustomize | ||
$(KUSTOMIZE): | ||
$(call go-install-tool,$(KUSTOMIZE),sigs.k8s.io/kustomize/kustomize/[email protected]) | ||
|
||
.PHONY: kustomize | ||
kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,8 @@ | ||
|
||
GOLANGCI-LINT=$(PROJECT_PATH)/bin/golangci-lint | ||
$(GOLANGCI-LINT): | ||
mkdir -p $(PROJECT_PATH)/bin | ||
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(PROJECT_PATH)/bin v1.55.2 | ||
|
||
.PHONY: golangci-lint | ||
golangci-lint: $(GOLANGCI-LINT) | ||
|
||
.PHONY: run-lint | ||
run-lint: $(GOLANGCI-LINT) | ||
$(GOLANGCI-LINT) run --timeout 2m | ||
golangci-lint: $(GOLANGCI-LINT) ## Download golangci-lint |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
very fancy 🧐