crossplane
/
Makefile
197 строк · 7.2 Кб
1# ====================================================================================
2# Setup Project
3
4PROJECT_NAME := crossplane5PROJECT_REPO := github.com/crossplane/$(PROJECT_NAME)6
7PLATFORMS ?= linux_amd64 linux_arm64 linux_arm linux_ppc64le darwin_amd64 darwin_arm64 windows_amd648# -include will silently skip missing files, which allows us
9# to load those files with a target in the Makefile. If only
10# "include" was used, the make command would fail and refuse
11# to run a target until the include commands succeeded.
12-include build/makelib/common.mk13
14# ====================================================================================
15# Setup Output
16
17S3_BUCKET ?= crossplane.releases18-include build/makelib/output.mk19
20# ====================================================================================
21# Setup Go
22
23# Set a sane default so that the nprocs calculation below is less noisy on the initial
24# loading of this file
25NPROCS ?= 126
27# each of our test suites starts a kube-apiserver and running many test suites in
28# parallel can lead to high CPU utilization. by default we reduce the parallelism
29# to half the number of CPU cores.
30GO_TEST_PARALLEL := $(shell echo $$(( $(NPROCS) / 2 )))31
32GO_STATIC_PACKAGES = $(GO_PROJECT)/cmd/crossplane $(GO_PROJECT)/cmd/crank33GO_TEST_PACKAGES = $(GO_PROJECT)/test/e2e34GO_LDFLAGS += -X $(GO_PROJECT)/internal/version.version=$(VERSION)35GO_SUBDIRS += cmd internal apis36GO111MODULE = on37GOLANGCILINT_VERSION = 1.56.238GO_LINT_ARGS ?= "--fix"39
40-include build/makelib/golang.mk41
42# ====================================================================================
43# Setup Kubernetes tools
44
45USE_HELM3 = true46HELM3_VERSION = v3.14.047KIND_VERSION = v0.21.048-include build/makelib/k8s_tools.mk49
50# ====================================================================================
51# Setup Helm
52
53HELM_BASE_URL = https://charts.crossplane.io54HELM_S3_BUCKET = crossplane.charts55HELM_CHARTS = crossplane56HELM_CHART_LINT_ARGS_crossplane = --set nameOverride='',imagePullSecrets=''57HELM_DOCS_ENABLED = true58HELM_VALUES_TEMPLATE_SKIPPED = true59-include build/makelib/helm.mk60
61# ====================================================================================
62# Setup Images
63# Due to the way that the shared build logic works, images should
64# all be in folders at the same level (no additional levels of nesting).
65
66REGISTRY_ORGS ?= docker.io/crossplane xpkg.upbound.io/crossplane67IMAGES = crossplane68-include build/makelib/imagelight.mk69
70# ====================================================================================
71# Targets
72
73# run `make help` to see the targets and options
74
75# We want submodules to be set up the first time `make` is run.
76# We manage the build/ folder and its Makefiles as a submodule.
77# The first time `make` is run, the includes of build/*.mk files will
78# all fail, and this target will be run. The next time, the default as defined
79# by the includes will be run instead.
80fallthrough: submodules81@echo Initial setup complete. Running make again . . .82@make83
84manifests:85@$(WARN) Deprecated. Please run make generate instead.86
87CRD_DIR = cluster/crds88
89crds.clean:90@$(INFO) cleaning generated CRDs91@find $(CRD_DIR) -name '*.yaml' -exec sed -i.sed -e '1,1d' {} \; || $(FAIL)92@find $(CRD_DIR) -name '*.yaml.sed' -delete || $(FAIL)93@$(OK) cleaned generated CRDs94
95generate.run: gen-kustomize-crds gen-chart-license96
97gen-chart-license:98@cp -f LICENSE cluster/charts/crossplane/LICENSE99
100generate.done: crds.clean101
102gen-kustomize-crds:103@$(INFO) Adding all CRDs to Kustomize file for local development104@rm cluster/kustomization.yaml105@echo "# This kustomization can be used to remotely install all Crossplane CRDs" >> cluster/kustomization.yaml106@echo "# by running kubectl apply -k https://github.com/crossplane/crossplane//cluster?ref=master" >> cluster/kustomization.yaml107@echo "resources:" >> cluster/kustomization.yaml108@find $(CRD_DIR) -type f -name '*.yaml' | sort | \109while read filename ;\110do echo "- $${filename#*/}" >> cluster/kustomization.yaml \111; done112@$(OK) All CRDs added to Kustomize file for local development113
114# Generate a coverage report for cobertura applying exclusions on
115# - generated file
116cobertura:117@cat $(GO_TEST_OUTPUT)/coverage.txt | \118grep -v zz_generated.deepcopy | \119$(GOCOVER_COBERTURA) > $(GO_TEST_OUTPUT)/cobertura-coverage.xml120
121e2e-tag-images:122@$(INFO) Tagging E2E test images123@docker tag $(BUILD_REGISTRY)/$(PROJECT_NAME)-$(TARGETARCH) crossplane-e2e/$(PROJECT_NAME):latest || $(FAIL)124@$(OK) Tagged E2E test images125
126# NOTE(negz): There's already a go.test.integration target, but it's weird.
127# This relies on make build building the e2e binary.
128E2E_TEST_FLAGS ?=129
130# TODO(negz): Ideally we'd just tell the E2E tests which CLI tools to invoke.
131# https://github.com/kubernetes-sigs/e2e-framework/issues/282
132E2E_PATH = $(WORK_DIR)/e2e133
134e2e-run-tests:135@$(INFO) Run E2E tests136@mkdir -p $(E2E_PATH)137@ln -sf $(KIND) $(E2E_PATH)/kind138@ln -sf $(HELM) $(E2E_PATH)/helm139@PATH="$(E2E_PATH):${PATH}" $(GO_TEST_OUTPUT)/e2e $(E2E_TEST_FLAGS) || $(FAIL)140@$(OK) Run E2E tests141
142e2e.init: build e2e-tag-images143
144e2e.run: $(KIND) $(HELM3) e2e-run-tests145
146# Update the submodules, such as the common build scripts.
147submodules:148@git submodule sync149@git submodule update --init --recursive150
151# Install CRDs into a cluster. This is for convenience.
152install-crds: $(KUBECTL) reviewable153$(KUBECTL) apply -f $(CRD_DIR)154
155# Uninstall CRDs from a cluster. This is for convenience.
156uninstall-crds:157$(KUBECTL) delete -f $(CRD_DIR)158
159# NOTE(hasheddan): the build submodule currently overrides XDG_CACHE_HOME in
160# order to force the Helm 3 to use the .work/helm directory. This causes Go on
161# Linux machines to use that directory as the build cache as well. We should
162# adjust this behavior in the build submodule because it is also causing Linux
163# users to duplicate their build cache, but for now we just make it easier to
164# identify its location in CI so that we cache between builds.
165go.cachedir:166@go env GOCACHE167
168# This is for running out-of-cluster locally, and is for convenience. Running
169# this make target will print out the command which was used. For more control,
170# try running the binary directly with different arguments.
171run: go.build172@$(INFO) Running Crossplane locally out-of-cluster . . .173@# To see other arguments that can be provided, run the command with --help instead174$(GO_OUT_DIR)/$(PROJECT_NAME) core start --debug175
176.PHONY: manifests cobertura submodules fallthrough test-integration run install-crds uninstall-crds gen-kustomize-crds e2e-tests-compile e2e.test.images177
178# ====================================================================================
179# Special Targets
180
181define CROSSPLANE_MAKE_HELP182Crossplane Targets:183cobertura Generate a coverage report for cobertura applying exclusions on generated files.
184submodules Update the submodules, such as the common build scripts.
185run Run crossplane locally, out-of-cluster. Useful for development.
186
187endef
188# The reason CROSSPLANE_MAKE_HELP is used instead of CROSSPLANE_HELP is because the crossplane
189# binary will try to use CROSSPLANE_HELP if it is set, and this is for something different.
190export CROSSPLANE_MAKE_HELP191
192crossplane.help:193@echo "$$CROSSPLANE_MAKE_HELP"194
195help-special: crossplane.help196
197.PHONY: crossplane.help help-special198