-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
114 lines (102 loc) · 3.46 KB
/
Makefile
File metadata and controls
114 lines (102 loc) · 3.46 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
SHELL := /bin/bash
PACKAGE ?= gitops-stack
XRD_DIR := apis/gitopsstacks
COMPOSITION := $(XRD_DIR)/composition.yaml
DEFINITION := $(XRD_DIR)/definition.yaml
EXAMPLE_DEFAULT := examples/gitopsstacks/standard.yaml
RENDER_TESTS := $(wildcard tests/test-*)
E2E_TESTS := $(wildcard tests/e2etest-*)
clean:
rm -rf _output
rm -rf .up
build:
up project build
# Examples list - mirrors GitHub Actions workflow
# Format: example_path::observed_resources_path (observed_resources_path is optional)
EXAMPLES := \
examples/gitopsstacks/minimal.yaml:: \
examples/gitopsstacks/standard.yaml:: \
examples/gitopsstacks/standard.yaml::examples/test/mocks/observed-resources/standard/steps/1/ \
examples/gitopsstacks/standard.yaml::examples/test/mocks/observed-resources/standard/steps/2/
# Render all examples (parallel execution, output shown per-job when complete)
render\:all:
@tmpdir=$$(mktemp -d); \
pids=""; \
for entry in $(EXAMPLES); do \
example=$${entry%%::*}; \
observed=$${entry#*::}; \
outfile="$$tmpdir/$$(echo $$entry | tr '/:' '__')"; \
( \
if [ -n "$$observed" ]; then \
echo "=== Rendering $$example with observed-resources $$observed ==="; \
up composition render --xrd=$(DEFINITION) $(COMPOSITION) $$example --observed-resources=$$observed; \
else \
echo "=== Rendering $$example ==="; \
up composition render --xrd=$(DEFINITION) $(COMPOSITION) $$example; \
fi; \
echo "" \
) > "$$outfile" 2>&1 & \
pids="$$pids $$!:$$outfile"; \
done; \
failed=0; \
for pair in $$pids; do \
pid=$${pair%%:*}; \
outfile=$${pair#*:}; \
if ! wait $$pid; then failed=1; fi; \
cat "$$outfile"; \
done; \
rm -rf "$$tmpdir"; \
exit $$failed
# Validate all examples (parallel execution, output shown per-job when complete)
validate\:all:
@tmpdir=$$(mktemp -d); \
pids=""; \
for entry in $(EXAMPLES); do \
example=$${entry%%::*}; \
observed=$${entry#*::}; \
outfile="$$tmpdir/$$(echo $$entry | tr '/:' '__')"; \
( \
if [ -n "$$observed" ]; then \
echo "=== Validating $$example with observed-resources $$observed ==="; \
up composition render --xrd=$(DEFINITION) $(COMPOSITION) $$example \
--observed-resources=$$observed --include-full-xr --quiet | \
crossplane beta validate $(XRD_DIR) --error-on-missing-schemas -; \
else \
echo "=== Validating $$example ==="; \
up composition render --xrd=$(DEFINITION) $(COMPOSITION) $$example \
--include-full-xr --quiet | \
crossplane beta validate $(XRD_DIR) --error-on-missing-schemas -; \
fi; \
echo "" \
) > "$$outfile" 2>&1 & \
pids="$$pids $$!:$$outfile"; \
done; \
failed=0; \
for pair in $$pids; do \
pid=$${pair%%:*}; \
outfile=$${pair#*:}; \
if ! wait $$pid; then failed=1; fi; \
cat "$$outfile"; \
done; \
rm -rf "$$tmpdir"; \
exit $$failed
# Shorthand aliases
.PHONY: render validate
render: ; @$(MAKE) 'render:all'
validate: ; @$(MAKE) 'validate:all'
# Single example targets
render\:%:
@example="examples/gitopsstacks/$*.yaml"; \
up composition render --xrd=$(DEFINITION) $(COMPOSITION) $$example
validate\:%:
@example="examples/gitopsstacks/$*.yaml"; \
up composition render --xrd=$(DEFINITION) $(COMPOSITION) $$example \
--include-full-xr --quiet | \
crossplane beta validate $(XRD_DIR) --error-on-missing-schemas -
test:
up test run $(RENDER_TESTS)
e2e:
up test run $(E2E_TESTS) --e2e
publish:
@if [ -z "$(tag)" ]; then echo "Error: tag is not set. Usage: make publish tag=<version>"; exit 1; fi
up project build --push --tag $(tag)