Skip to content

Commit

Permalink
Switch to build-module targets for e2e, uptest, render and yamllint a…
Browse files Browse the repository at this point in the history
…nd pull out project-specifc settings
  • Loading branch information
kaessert committed Oct 8, 2024
1 parent c89db02 commit 550b284
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 67 deletions.
83 changes: 17 additions & 66 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Project Setup
PROJECT_NAME := configuration-app

# Include project.mk for project specific settings
include project.mk

ifndef PROJECT_NAME
$(error PROJECT_NAME is not set. Please create `project.mk` and set it there.)
endif

PROJECT_REPO := github.com/upbound/$(PROJECT_NAME)

# NOTE(hasheddan): the platform is insignificant here as Configuration package
Expand All @@ -13,8 +20,6 @@ PLATFORMS ?= linux_amd64

UP_VERSION = v0.34.0
UP_CHANNEL = stable
UPTEST_VERSION = v1.1.2
UPTEST_CLAIMS ?= examples/app-claim.yaml
CROSSPLANE_CLI_VERSION = v1.17.1

-include build/makelib/k8s_tools.mk
Expand All @@ -39,6 +44,15 @@ KIND_CLUSTER_NAME ?= uptest-$(PROJECT_NAME)
-include build/makelib/local.xpkg.mk
-include build/makelib/controlplane.mk

# ====================================================================================
# Testing

UPTEST_VERSION = v1.1.2
UPTEST_LOCAL_DEPLOY_TARGET = local.xpkg.deploy.configuration.$(PROJECT_NAME)
UPTEST_DEFAULT_TIMEOUT = 2400s

-include build/makelib/uptest.mk

# ====================================================================================
# Targets

Expand All @@ -62,69 +76,6 @@ submodules:
# machinery sets UP to point to tool cache.
build.init: $(UP)

# ====================================================================================
# End to End Testing

UPTEST_EXTRA_ARGS ?=

UPTEST_COMMAND = SKIP_DEPLOY_ARGO=$(SKIP_DEPLOY_ARGO) \
KUBECTL=$(KUBECTL) \
CHAINSAW=$(CHAINSAW) \
CROSSPLANE_CLI=$(CROSSPLANE_CLI) \
CROSSPLANE_NAMESPACE=$(CROSSPLANE_NAMESPACE) \
YQ=$(YQ) \
$(UPTEST) e2e $(UPTEST_CLAIMS) \
--data-source="${UPTEST_DATASOURCE_PATH}" \
--setup-script=$(SETUP_SCRIPT) \
--default-timeout=2400s \
--skip-update \
--skip-import \
$(UPTEST_EXTRA_ARGS)

# This target requires the following environment variables to be set:
# - To ensure the proper functioning of the end-to-end test resource pre-deletion hook, it is crucial to arrange your resources appropriately.
# You can check the basic implementation here: https://github.com/upbound/uptest/blob/main/internal/templates/01-delete.yaml.tmpl.
# - UPTEST_DATASOURCE_PATH (optional), see https://github.com/upbound/uptest#injecting-dynamic-values-and-datasource
SETUP_SCRIPT ?= test/setup.sh
uptest: $(UPTEST) $(KUBECTL) $(CHAINSAW) $(CROSSPLANE_CLI) $(YQ)
@$(INFO) running automated tests
$(UPTEST_COMMAND) || $(FAIL)
@$(OK) running automated tests

# Run uptest together with all dependencies. Use `make e2e UPTEST_EXTRA_ARGS=--skip-delete` to skip deletion of resources.
e2e: build controlplane.down controlplane.up local.xpkg.deploy.configuration.$(PROJECT_NAME) uptest #

render: $(CROSSPLANE_CLI) ${YQ}
@indir="./examples"; \
for file in $$(find $$indir -type f -name '*.yaml' ); do \
doc_count=$$(grep -c '^---' "$$file"); \
if [[ $$doc_count -gt 0 ]]; then \
continue; \
fi; \
COMPOSITION=$$(${YQ} eval '.metadata.annotations."render.crossplane.io/composition-path"' $$file); \
FUNCTION=$$(${YQ} eval '.metadata.annotations."render.crossplane.io/function-path"' $$file); \
ENVIRONMENT=$$(${YQ} eval '.metadata.annotations."render.crossplane.io/environment-path"' $$file); \
OBSERVE=$$(${YQ} eval '.metadata.annotations."render.crossplane.io/observe-path"' $$file); \
if [[ "$$ENVIRONMENT" == "null" ]]; then \
ENVIRONMENT=""; \
fi; \
if [[ "$$OBSERVE" == "null" ]]; then \
OBSERVE=""; \
fi; \
if [[ "$$COMPOSITION" == "null" || "$$FUNCTION" == "null" ]]; then \
continue; \
fi; \
ENVIRONMENT=$${ENVIRONMENT=="null" ? "" : $$ENVIRONMENT}; \
OBSERVE=$${OBSERVE=="null" ? "" : $$OBSERVE}; \
$(CROSSPLANE_CLI) render $$file $$COMPOSITION $$FUNCTION $${ENVIRONMENT:+-e $$ENVIRONMENT} $${OBSERVE:+-o $$OBSERVE} -x; \
done

yamllint: ## Static yamllint check
@$(INFO) running yamllint
@yamllint ./apis || $(FAIL)
@$(OK) running yamllint

.PHONY: uptest e2e render yamllint

help.local:
@grep -E '^[a-zA-Z_-]+.*:.*?## .*$$' Makefile | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
2 changes: 1 addition & 1 deletion build
Submodule build updated 1 files
+90 −0 makelib/uptest.mk
4 changes: 4 additions & 0 deletions project.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
PROJECT_NAME := configuration-app
UPTEST_INPUT_MANIFESTS := examples/app-claim.yaml
UPTEST_SKIP_IMPORT := true
UPTEST_SKIP_UPDATE := true

0 comments on commit 550b284

Please sign in to comment.