-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
83 lines (69 loc) · 2.94 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
APPS=$(subst _,-,$(patsubst cdk/app_%.py,%,$(wildcard cdk/app_*.py)))
IT_APPS=$(subst _,-,$(patsubst cdk/app_%.py,%,$(wildcard cdk/app_*_it.py)))
RECREATE=
SHELL=/usr/bin/env bash
TOX=tox $(TOX_OPTS)
TOX_OPTS?=
VENV_TOX_LOG_LOCK=.venv/.tox-info.json
.PHONY: help bootstrap install-cdk install-node tox unit-tests venv
.DEFAULT_GOAL := help
help: Makefile
@echo
@echo "Usage: make [options] target ..."
@echo
@echo "Options:"
@echo " Run 'make -h' to list options."
@echo
@echo "Targets:"
@sed -n 's/^##//p' $< | column -t -s ':' | sed -e 's/^/ /'
@echo
@printf " where APP is one of the following:\n$(patsubst %,\n - %,$(APPS))\n"
@echo
# Set the tox --recreate option when setup.py is newer than the tox log lock
# file in the virtualenv, as that indicates it was updated since the last time
# tox was run. This allows us to develop more quickly by avoiding unnecessary
# environment recreation, while ensuring that the environment is recreated when
# necessary (i.e., when dependencies change).
$(VENV_TOX_LOG_LOCK): setup.py
$(eval RECREATE := --recreate)
# Rules that run a tox command should depend on this to make sure the virtualenv
# is updated when necessary, without unnecessarily specifying the tox --recreate
# option explicitly.
venv: $(VENV_TOX_LOG_LOCK)
tox:
@if [[ -z $${TOX_ENV_DIR} ]]; then \
echo "ERROR: For tox.ini use only" >&2; \
exit 1; \
fi
# NOTE: Intended only for use from tox.ini.
# Install Node.js within the tox virtualenv.
install-node: tox
nodeenv --node lts --python-virtualenv
# NOTE: Intended only for use from tox.ini
# Install the CDK CLI within the tox virtualenv.
install-cdk: install-node
npm install --location global "aws-cdk@latest"
## bootstrap: Bootstrap the CDK toolkit
bootstrap:
$(TOX) $(RECREATE) -e dev -- bootstrap \
--toolkit-stack-name CDKToolkitV2 \
--custom-permissions-boundary mcp-tenantOperator \
--template cdk/bootstrap-template.yaml
## unit-tests: Run unit tests
unit-tests: venv
$(TOX) $(RECREATE)
## APP-integration-tests: Run integration tests for a CDK app (depends on deploy-APP-it)
$(patsubst %-it,%-integration-tests,$(IT_APPS)): venv
$(TOX) $(RECREATE) -e integration -- $(wildcard tests/integration/test_$(subst -integration-tests,,$@)*.py)
## synth-APP: Synthesize a CDK app
$(patsubst %,synth-%,$(APPS)): venv
$(TOX) $(RECREATE) -e dev -- synth --all --app $(subst -,_,$(patsubst synth-%,cdk/app_%.py,$@))
## diff-APP: Diff a CDK app
$(patsubst %,diff-%,$(APPS)): venv
$(TOX) $(RECREATE) -e dev -- diff --all --app $(subst -,_,$(patsubst diff-%,cdk/app_%.py,$@))
## deploy-APP: Deploy a CDK app
$(patsubst %,deploy-%,$(APPS)): venv
$(TOX) $(RECREATE) -e dev -- deploy --all --app $(subst -,_,$(patsubst deploy-%,cdk/app_%.py,$@)) --progress events --require-approval never
## destroy-APP: Destroy a CDK app
$(patsubst %,destroy-%,$(APPS)): venv
$(TOX) $(RECREATE) -e dev -- destroy --all --app $(subst -,_,$(patsubst destroy-%,cdk/app_%.py,$@)) --progress events --force