-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathMakefile
More file actions
177 lines (146 loc) · 6.3 KB
/
Copy pathMakefile
File metadata and controls
177 lines (146 loc) · 6.3 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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
PKG_TARGETS = $(subst packages/,,$(wildcard packages/*))
# Help target
.PHONY: help
help:
@echo "Jumpstarter Makefile Help"
@echo "=========================="
@echo ""
@echo "Build targets:"
@echo " build - Build all packages"
@echo " protobuf-gen - Generate code from protobuf definitions"
@echo " sync - Sync all packages and extras"
@echo ""
@echo "Documentation targets:"
@echo " docs - Build HTML documentation with warnings as errors"
@echo " docs-singlehtml - Build single HTML page documentation"
@echo " docs-all - Build multiversion documentation"
@echo " docs-serve - Build and serve documentation locally"
@echo " docs-serve-all - Build and serve multiversion documentation locally"
@echo " docs-linkcheck - Check documentation links"
@echo ""
@echo "Testing targets:"
@echo " test - Run all package tests and documentation tests"
@echo " pkg-test-all - Run tests for all packages"
@echo " pkg-test-<pkg> - Run tests for a specific package"
@echo " docs-test - Run documentation tests"
@echo ""
@echo "Linting and type checking:"
@echo " ty - Run ty type checking on all packages"
@echo " pkg-ty-all - Run ty on all packages"
@echo " pkg-ty-<pkg> - Run ty on a specific package"
@echo " lint - Run ruff linter"
@echo " lint-fix - Run ruff linter with auto-fix"
@echo ""
@echo "Cleaning targets:"
@echo " clean - Run all clean targets"
@echo " clean-venv - Clean virtual environment"
@echo " clean-build - Clean build artifacts"
@echo " clean-test - Clean test artifacts"
@echo " clean-docs - Clean documentation build"
default: help
docs-singlehtml: docs-generate-crds docs-generate-grpc
uv run --isolated --all-packages --group docs $(MAKE) -C docs singlehtml
docs-generate-crds:
uv run --isolated --all-packages --group docs python3 docs/source/reference/generate-crd-docs.py
docs-generate-grpc:
uv run --isolated --all-packages --group docs python3 docs/source/reference/generate_grpc_docs.py
docs: docs-generate-crds docs-generate-grpc
uv run --isolated --all-packages --group docs $(MAKE) -C docs html SPHINXOPTS="-W --keep-going -n"
docs-all: docs-generate-crds docs-generate-grpc
uv run --isolated --all-packages --group docs $(MAKE) -C docs multiversion
docs-serve: clean-docs docs-generate-crds docs-generate-grpc
uv run --isolated --all-packages --group docs $(MAKE) -C docs serve
docs-serve-all: clean-docs docs-all
uv run --isolated --all-packages --group docs $(MAKE) -C docs serve-multiversion
docs-check-grpc:
@TMPDIR1=$$(mktemp -d) && TMPDIR2=$$(mktemp -d) && \
trap 'rm -rf "$$TMPDIR1" "$$TMPDIR2"' EXIT && \
uv run --isolated --all-packages --group docs python3 -c \
"import sys; sys.path.insert(0, 'docs/source/reference'); from generate_grpc_docs import main; main(output_dir='$$TMPDIR1')" && \
uv run --isolated --all-packages --group docs python3 -c \
"import sys; sys.path.insert(0, 'docs/source/reference'); from generate_grpc_docs import main; main(output_dir='$$TMPDIR2')" && \
diff -r "$$TMPDIR1/" "$$TMPDIR2/"
docs-test-grpc:
uv run --isolated --all-packages --group docs pytest --cov=docs/source/reference --cov-report=xml:docs/source/reference/coverage.xml docs/source/reference/generate_grpc_docs_test.py
docs-test: docs-generate-crds docs-generate-grpc
uv run --isolated --all-packages --group docs $(MAKE) -C docs doctest
docs-linkcheck: docs-generate-crds docs-generate-grpc
uv run --isolated --all-packages --group docs $(MAKE) -C docs linkcheck
ifdef LOGS_DIR
pkg-test-%: packages/%
@mkdir -p $(LOGS_DIR)
@rm -f $(LOGS_DIR)/$*.failed
@bash -c 'set -o pipefail; \
PYTHONUNBUFFERED=1 uv run --isolated --directory $< pytest 2>&1 | tee $(LOGS_DIR)/$*.log; \
rc=$$?; \
if [ $$rc -ne 0 ] && [ $$rc -ne 5 ]; then \
touch $(LOGS_DIR)/$*.failed; \
fi; \
true'
else
pkg-test-%: packages/%
uv run --isolated --directory $< pytest || [ $$? -eq 5 ]
endif
pkg-ty-%: packages/%
uv run --isolated --directory $< ty check .
pkg-test-all: $(addprefix pkg-test-,$(PKG_TARGETS))
ifdef LOGS_DIR
test-report:
@failed=0; \
for f in $(LOGS_DIR)/*.failed; do \
[ -f "$$f" ] || continue; \
pkg=$$(basename "$$f" .failed); \
echo ""; \
echo "========== FAILED: $$pkg =========="; \
cat "$(LOGS_DIR)/$$pkg.log"; \
failed=1; \
done; \
[ $$failed -eq 0 ] && echo "All package tests passed." || exit 1
endif
pkg-ty-all: $(addprefix pkg-ty-,$(PKG_TARGETS))
build:
uv build --all --out-dir dist
protobuf-gen:
podman run --volume "$(shell pwd):/workspace" --workdir /workspace docker.io/bufbuild/buf:latest generate
# Fix Python imports: convert absolute imports to relative imports
# In jumpstarter/client/v1: from jumpstarter.v1 import -> from ...v1 import
find packages/jumpstarter-protocol/jumpstarter_protocol/jumpstarter/client/v1 -name "*_pb2*.py" -type f -exec sed -i.bak \
-e 's|^from jumpstarter\.v1 import|from ...v1 import|g' \
-e 's|^from jumpstarter\.client\.v1 import|from . import|g' \
{} \; -exec rm {}.bak \;
# In jumpstarter/v1: from jumpstarter.v1 import -> from . import
find packages/jumpstarter-protocol/jumpstarter_protocol/jumpstarter/v1 -name "*_pb2*.py" -type f -exec sed -i.bak \
-e 's|^from jumpstarter\.v1 import|from . import|g' \
{} \; -exec rm {}.bak \;
sync:
uv sync --all-packages --all-extras
clean-venv:
-rm -rf ./.venv
-find . -type d -name __pycache__ -exec rm -r {} \+
clean-build:
-rm -rf dist
clean-test:
-rm -f .coverage
-rm -f coverage.xml
-rm -rf htmlcov
clean-docs:
uv run --isolated --all-packages --group docs $(MAKE) -C docs clean
clean: clean-docs clean-venv clean-build clean-test
ifdef LOGS_DIR
test: pkg-test-all docs-test docs-test-grpc test-report
else
test: pkg-test-all docs-test docs-test-grpc
endif
ty: pkg-ty-all
lint:
uv run ruff check
lint-fix:
uv run ruff check --fix
.PHONY: default help docs docs-all docs-serve docs-serve-all docs-clean docs-test \
docs-check-grpc docs-test-grpc docs-linkcheck docs-generate-grpc pkg-test-all pkg-test-all-parallel pkg-ty-all build generate sync \
clean clean-venv clean-build clean-test clean-all test test-report test-all ty-all docs \
lint lint-fix \
pkg-ty-jumpstarter \
pkg-ty-jumpstarter-cli-admin \
pkg-ty-jumpstarter-kubernetes \
pkg-ty-jumpstarter-protocol