diff --git a/Makefile b/Makefile index a39ac6e..8d2f8a6 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,42 @@ +# Usage +# ==================================================================================== +# Generic Makefile to be used across repositories building a crossplane configuration +# package +# +# Available targets: +# +# - `yamllint` +# Runs yamllint for all files in `api`-folder recursively +# +# - `render` +# Runs crossplane render to render the output of the composition. Usefule for quick +# feedback in order to test templating. +# Important note: +# Claims need following annotations in order for render to work (adjust the paths +# if necessary): +# render.crossplane.io/composition-path: apis/pat/composition.yaml +# render.crossplane.io/function-path: examples/functions.yaml +# +# - `e2e` +# Runs full end-to-end test, including creating cluster, setting up the configuration +# and testing if create, import and delete work as expected. +# Available options: +# UPTEST_SKIP_DELETE (default `false`) skips the deletion of any resources created during the test +# UPTEST_SKIP_UPDATE (default `false`) skips testing the update of the claims +# UPTEST_SKIP_IMPORT (default `true`) skips testing the import of resources +# Example: +# `make e2e UPTEST_SKIP_DELETE=true` + # 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 @@ -13,8 +50,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 @@ -39,6 +74,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 @@ -62,69 +106,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}' diff --git a/apis/composition.yaml b/apis/pat/composition.yaml similarity index 100% rename from apis/composition.yaml rename to apis/pat/composition.yaml diff --git a/build b/build index 9bfe371..615e99a 160000 --- a/build +++ b/build @@ -1 +1 @@ -Subproject commit 9bfe371c2286b578d3e5e0ffa86becaca14bf56f +Subproject commit 615e99af8f85f07ab37c63786ae8d49aff8a7740 diff --git a/examples/app-claim.yaml b/examples/app-claim.yaml index 9eb6285..bffffd9 100644 --- a/examples/app-claim.yaml +++ b/examples/app-claim.yaml @@ -2,7 +2,7 @@ apiVersion: platform.upbound.io/v1alpha1 kind: App metadata: annotations: - render.crossplane.io/composition-path: apis/composition.yaml + render.crossplane.io/composition-path: apis/pat/composition.yaml render.crossplane.io/function-path: examples/functions.yaml name: configuration-app namespace: default diff --git a/project.mk b/project.mk new file mode 100644 index 0000000..bc14eda --- /dev/null +++ b/project.mk @@ -0,0 +1,4 @@ +PROJECT_NAME := configuration-app +UPTEST_INPUT_MANIFESTS := examples/app-claim.yaml +UPTEST_SKIP_IMPORT := true +UPTEST_SKIP_UPDATE := true