|
| 1 | +# Project Setup |
| 2 | +PROJECT_NAME := configuration-getting-started |
| 3 | +PROJECT_REPO := github.com/upbound/$(PROJECT_NAME) |
| 4 | + |
| 5 | +# NOTE(hasheddan): the platform is insignificant here as Configuration package |
| 6 | +# images are not architecture-specific. We constrain to one platform to avoid |
| 7 | +# needlessly pushing a multi-arch image. |
| 8 | +PLATFORMS ?= linux_amd64 |
| 9 | +-include build/makelib/common.mk |
| 10 | + |
| 11 | +# ==================================================================================== |
| 12 | +# Setup Kubernetes tools |
| 13 | + |
| 14 | +UP_VERSION = v0.30.0 |
| 15 | +UP_CHANNEL = stable |
| 16 | +UPTEST_VERSION = v0.11.1 |
| 17 | + |
| 18 | +-include build/makelib/k8s_tools.mk |
| 19 | +# ==================================================================================== |
| 20 | +# Setup XPKG |
| 21 | +XPKG_DIR = $(shell pwd) |
| 22 | +XPKG_IGNORE = .github/workflows/*.yaml,.github/workflows/*.yml,examples/*.yaml,.work/uptest-datasource.yaml |
| 23 | +XPKG_REG_ORGS ?= xpkg.upbound.io/upbound |
| 24 | +# NOTE(hasheddan): skip promoting on xpkg.upbound.io as channel tags are |
| 25 | +# inferred. |
| 26 | +XPKG_REG_ORGS_NO_PROMOTE ?= xpkg.upbound.io/upbound |
| 27 | +XPKGS = $(PROJECT_NAME) |
| 28 | +-include build/makelib/xpkg.mk |
| 29 | + |
| 30 | +CROSSPLANE_NAMESPACE = upbound-system |
| 31 | +CROSSPLANE_ARGS = "--enable-usages" |
| 32 | +-include build/makelib/local.xpkg.mk |
| 33 | +-include build/makelib/controlplane.mk |
| 34 | + |
| 35 | +# ==================================================================================== |
| 36 | +# Targets |
| 37 | + |
| 38 | +# run `make help` to see the targets and options |
| 39 | + |
| 40 | +# We want submodules to be set up the first time `make` is run. |
| 41 | +# We manage the build/ folder and its Makefiles as a submodule. |
| 42 | +# The first time `make` is run, the includes of build/*.mk files will |
| 43 | +# all fail, and this target will be run. The next time, the default as defined |
| 44 | +# by the includes will be run instead. |
| 45 | +fallthrough: submodules |
| 46 | + @echo Initial setup complete. Running make again . . . |
| 47 | + @make |
| 48 | + |
| 49 | +# Update the submodules, such as the common build scripts. |
| 50 | +submodules: |
| 51 | + @git submodule sync |
| 52 | + @git submodule update --init --recursive |
| 53 | + |
| 54 | +# We must ensure up is installed in tool cache prior to build as including the k8s_tools machinery prior to the xpkg |
| 55 | +# machinery sets UP to point to tool cache. |
| 56 | +build.init: $(UP) |
| 57 | + |
| 58 | +# ==================================================================================== |
| 59 | +# End to End Testing |
| 60 | + |
| 61 | +# This target requires the following environment variables to be set: |
| 62 | +# - UPTEST_CLOUD_CREDENTIALS, cloud credentials for the provider being tested, e.g. export UPTEST_CLOUD_CREDENTIALS=$(cat ~/.aws/credentials) |
| 63 | +# - To ensure the proper functioning of the end-to-end test resource pre-deletion hook, it is crucial to arrange your resources appropriately. |
| 64 | +# You can check the basic implementation here: https://github.com/upbound/uptest/blob/main/internal/templates/01-delete.yaml.tmpl. |
| 65 | +# - UPTEST_DATASOURCE_PATH (optional), see https://github.com/upbound/uptest#injecting-dynamic-values-and-datasource |
| 66 | +uptest: $(UPTEST) $(KUBECTL) $(KUTTL) |
| 67 | + @$(INFO) running automated tests |
| 68 | + @KUBECTL=$(KUBECTL) KUTTL=$(KUTTL) CROSSPLANE_NAMESPACE=$(CROSSPLANE_NAMESPACE) $(UPTEST) e2e examples/XAccountScaffold/xr.yaml,examples/XCluster/xr.yaml,examples/XCompositeCluster/xr.yaml,examples/XDatabase/xr.yaml,examples/XNetwork/xr.yaml,examples/XNodePool/xr.yaml,examples/XServiceAccount/xr.yaml,examples/XSubnetwork/xr.yaml --data-source="${UPTEST_DATASOURCE_PATH}" --setup-script=test/setup.sh --default-timeout=2400 || $(FAIL) |
| 69 | + @$(OK) running automated tests |
| 70 | + |
| 71 | +# This target requires the following environment variables to be set: |
| 72 | +# - UPTEST_CLOUD_CREDENTIALS, cloud credentials for the provider being tested, e.g. export UPTEST_CLOUD_CREDENTIALS=$(cat ~/.aws/credentials) |
| 73 | +e2e: build controlplane.up local.xpkg.deploy.configuration.$(PROJECT_NAME) uptest |
| 74 | + |
| 75 | +render: |
| 76 | + @indir="./examples"; \ |
| 77 | + for file in $$(find $$indir -type f -name '*.yaml' ); do \ |
| 78 | + doc_count=$$(grep -c '^---' "$$file"); \ |
| 79 | + if [[ $$doc_count -gt 0 ]]; then \ |
| 80 | + continue; \ |
| 81 | + fi; \ |
| 82 | + COMPOSITION=$$(yq eval '.metadata.annotations."render.crossplane.io/composition-path"' $$file); \ |
| 83 | + FUNCTION=$$(yq eval '.metadata.annotations."render.crossplane.io/function-path"' $$file); \ |
| 84 | + if [[ "$$COMPOSITION" == "null" || "$$FUNCTION" == "null" ]]; then \ |
| 85 | + continue; \ |
| 86 | + fi; \ |
| 87 | + crossplane beta render $$file $$COMPOSITION $$FUNCTION -x -r; \ |
| 88 | + done |
| 89 | + |
| 90 | +yamllint: |
| 91 | + @$(INFO) running yamllint |
| 92 | + @yamllint ./apis || $(FAIL) |
| 93 | + @$(OK) running yamllint |
| 94 | + |
| 95 | +.PHONY: uptest e2e render yamllint |
0 commit comments