-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathMakefile
More file actions
83 lines (72 loc) · 3.61 KB
/
Copy pathMakefile
File metadata and controls
83 lines (72 loc) · 3.61 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
.PHONY: integration-test
GENERATED_PROJECT := /tmp/starter-app-integration-test
## Generate a project from the template and run integration tests
integration-test:
rm -rf $(GENERATED_PROJECT)
copier copy --defaults --UNSAFE --vcs-ref=HEAD . $(GENERATED_PROJECT)
$(MAKE) _test-uv-lock-generated
$(MAKE) _test-discover
$(MAKE) _test-start-worker
$(MAKE) _test-start-worker-module
$(MAKE) _test-start-worker-importlib
$(MAKE) _test-start-examples
$(MAKE) _test-execute-help
$(MAKE) _test-execute-bad-json
$(MAKE) _test-wheel-contents
@echo ""
@echo "All integration tests passed."
_test-uv-lock-generated:
@echo "--- test: copier _tasks generated uv.lock"
@test -f $(GENERATED_PROJECT)/uv.lock \
&& echo "OK: uv.lock generated" \
|| (echo "FAIL: uv.lock was not generated by copier _tasks" && exit 1)
_test-discover:
@echo "--- test: workflow discovery"
cd $(GENERATED_PROJECT) && uv run python -c \
"from entrypoints.worker import discover_workflows; wfs = discover_workflows(); assert len(wfs) > 0, 'No workflows discovered'; print(f'OK: discovered {len(wfs)} workflow(s)')"
_test-start-worker:
@echo "--- test: entrypoints.worker discovers workflows before connecting"
cd $(GENERATED_PROJECT) && uv run python -m entrypoints.worker 2>&1 \
| grep -q "Discovered .* workflow(s)" \
&& echo "OK: worker discovered workflows" \
|| (echo "FAIL: worker did not print discovery message" && exit 1)
_test-start-worker-module:
@echo "--- test: python -m worker discovers workflows before connecting"
cd $(GENERATED_PROJECT) && uv run python -m worker 2>&1 \
| grep -q "Discovered .* workflow(s)" \
&& echo "OK: worker module discovered workflows" \
|| (echo "FAIL: worker module did not print discovery message" && exit 1)
_test-start-worker-importlib:
@echo "--- test: MISTRAL_WORKER_ENTRYPOINT with importlib entrypoint script"
cd $(GENERATED_PROJECT) && MISTRAL_WORKER_ENTRYPOINT=worker:main \
uv run python -c "import asyncio, importlib, inspect, os; \
m, f = os.environ['MISTRAL_WORKER_ENTRYPOINT'].split(':', 1); \
result = getattr(importlib.import_module(m), f)(); \
asyncio.run(result) if inspect.iscoroutine(result) else None" 2>&1 \
| grep -q "Discovered .* workflow(s)" \
&& echo "OK: MISTRAL_WORKER_ENTRYPOINT with importlib entrypoint script loaded and discovered workflows" \
|| (echo "FAIL: MISTRAL_WORKER_ENTRYPOINT with importlib entrypoint script did not discover workflows" && exit 1)
_test-start-examples:
@echo "--- test: examples.worker loads example workflows before connecting"
cd $(GENERATED_PROJECT) && uv run python -m examples.worker 2>&1 \
| grep -q "Starting worker with .* example(s)" \
&& echo "OK: examples worker started" \
|| (echo "FAIL: examples worker did not print start message" && exit 1)
_test-execute-help:
@echo "--- test: entrypoints.start --help"
cd $(GENERATED_PROJECT) && uv run python -m entrypoints.start --help > /dev/null 2>&1 \
&& echo "OK: --help works" \
|| (echo "FAIL: --help failed" && exit 1)
_test-execute-bad-json:
@echo "--- test: entrypoints.start rejects invalid JSON"
cd $(GENERATED_PROJECT) && uv run python -m entrypoints.start --workflow hello-world --input 'not-json' 2>&1 \
| grep -q "invalid JSON" \
&& echo "OK: bad JSON rejected" \
|| (echo "FAIL: bad JSON not rejected" && exit 1)
_test-wheel-contents:
@echo "--- test: built wheel ships the entrypoints package"
cd $(GENERATED_PROJECT) && rm -rf dist && uv build --wheel > /dev/null
cd $(GENERATED_PROJECT) && unzip -l dist/*.whl \
| grep -q "entrypoints/worker.py" \
&& echo "OK: wheel contains entrypoints package" \
|| (echo "FAIL: wheel is missing the entrypoints package" && exit 1)