-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
137 lines (101 loc) · 4.24 KB
/
Makefile
File metadata and controls
137 lines (101 loc) · 4.24 KB
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
TF ?= terraform
LOCALSTACK_COMPOSE_FILE ?= tests/localstack/docker-compose.yml
AWS_REGION ?= us-east-1
LOCALSTACK_ENDPOINT ?= http://localhost:4566
LOCAL_ENV = AWS_ACCESS_KEY_ID=test AWS_SECRET_ACCESS_KEY=test AWS_SESSION_TOKEN=test AWS_REGION=$(AWS_REGION) AWS_ENDPOINT_URL=$(LOCALSTACK_ENDPOINT)
.PHONY: fmt-check validate lint security qa plan verify up down test-k8s test-e2e-k8s docs docs-dev cli-build cli-check evm-cloud local local-up local-down local-status local-reset
# --- QA ---
fmt-check:
@echo "=== fmt ===" && $(TF) fmt -check -recursive && echo "PASS" || (echo "FAIL: run 'terraform fmt -recursive'" && exit 1)
validate:
@echo "=== validate ===" && $(TF) init -backend=false -no-color > /dev/null 2>&1 && $(TF) validate -no-color && echo "PASS"
lint:
@echo "=== tflint ===" && tflint --recursive --no-color 2>&1 && echo "PASS"
security:
@echo "=== checkov ===" && checkov -d . --framework terraform --compact --quiet --skip-path app/tests/golden 2>/dev/null && echo "PASS"
qa: fmt-check validate lint security
@echo "\n=== QA PASSED ==="
# --- LocalStack lifecycle ---
# Support `make local <up|down|status|reset>` without accidentally invoking
# LocalStack's `up` / `down` targets.
local:
@subcmd="$(word 2,$(MAKECMDGOALS))"; \
case "$$subcmd" in \
up) $(MAKE) local-up ARGS="$(ARGS)" ;; \
down) $(MAKE) local-down ;; \
status) $(MAKE) local-status ;; \
reset) $(MAKE) local-reset ARGS="$(ARGS)" ;; \
"") echo "Usage: make local <up|down|status|reset> [ARGS='...']"; exit 1 ;; \
*) echo "Unknown local subcommand: $$subcmd"; exit 1 ;; \
esac
up:
@if [ "$(firstword $(MAKECMDGOALS))" = "local" ]; then :; else \
docker compose -f $(LOCALSTACK_COMPOSE_FILE) up -d --wait > /dev/null; \
fi
down:
@if [ "$(firstword $(MAKECMDGOALS))" = "local" ]; then :; else \
docker compose -f $(LOCALSTACK_COMPOSE_FILE) down > /dev/null; \
fi
# --- Plan an example against LocalStack ---
# Usage: make plan EXAMPLE=minimal_rds
# make plan EXAMPLE=minimal_BYO_clickhouse
EXAMPLE ?= minimal_rds
EXAMPLE_DIR = examples/$(EXAMPLE)
TFVARS = $(shell ls $(EXAMPLE_DIR)/*.tfvars 2>/dev/null | grep -v auto.tfvars | grep -v secrets)
plan:
@test -d $(EXAMPLE_DIR) || (echo "Example '$(EXAMPLE)' not found. Available:" && ls examples/ && exit 1)
@test -n "$(TFVARS)" || (echo "No .tfvars found in $(EXAMPLE_DIR)" && exit 1)
docker compose -f $(LOCALSTACK_COMPOSE_FILE) up -d --wait
cd $(EXAMPLE_DIR) && $(TF) init -backend=false && $(LOCAL_ENV) $(TF) plan -var-file=$(notdir $(TFVARS)) || true
docker compose -f $(LOCALSTACK_COMPOSE_FILE) down
# --- Verify: QA + plan all examples ---
verify:
@$(MAKE) qa
@for dir in examples/*/; do \
example=$$(basename $$dir); \
echo "\n=== Planning $$example ==="; \
$(MAKE) plan EXAMPLE=$$example; \
done
# --- Kind-based K8s validation ---
# Requires: kind, kubectl, helm, terraform, docker
# Creates a throwaway kind cluster, applies EKS K8s modules, validates resources.
test-k8s:
@bash tests/kind/run.sh
# --- Kind-based deployer integration ---
# Requires: kind, kubectl, helm, jq, base64, python3, docker
# Creates ephemeral cluster, runs real deploy.sh, validates Helm releases + pods.
test-deploy:
@bash tests/kind/deployer-test.sh
# --- E2E k3s validation ---
# Requires: E2E_KUBECONFIG pointing to a persistent k3s VPS kubeconfig.
# See tests/e2e-k3s/README.md for setup instructions.
# Connects to persistent cluster, deploys via real deployer, validates, tears down.
test-e2e-k3s:
@bash tests/e2e-k3s/run.sh
# --- Documentation ---
docs:
cd documentation && npm run build
docs-dev:
cd documentation && npm run dev
# --- Local dev stack (kind + Anvil) ---
local-up:
@cargo run --manifest-path cli/Cargo.toml -- local up $(ARGS)
local-down:
@cargo run --manifest-path cli/Cargo.toml -- local down
local-status:
@cargo run --manifest-path cli/Cargo.toml -- local status
local-reset:
@cargo run --manifest-path cli/Cargo.toml -- local reset $(ARGS)
# --- CLI ---
cli-build:
cd cli && cargo build
cli-check:
cd cli && cargo check --locked && cargo clippy --locked -- -D warnings
evm-cloud:
@if [ -z "$(filter-out $@,$(MAKECMDGOALS))" ]; then \
cargo run --manifest-path cli/Cargo.toml -- --help; \
else \
cargo run --manifest-path cli/Cargo.toml -- $(filter-out $@,$(MAKECMDGOALS)); \
fi
%:
@: