-
Notifications
You must be signed in to change notification settings - Fork 34
Expand file tree
/
Copy pathMakefile
More file actions
128 lines (108 loc) · 3.69 KB
/
Copy pathMakefile
File metadata and controls
128 lines (108 loc) · 3.69 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
PKG_TARGETS = $(subst packages/,,$(wildcard packages/*))
# Help target
.PHONY: help
help:
@echo "Jumpstarter Python 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 "Testing targets:"
@echo " test - Run all package tests"
@echo " pkg-test-all - Run tests for all packages"
@echo " pkg-test-<pkg> - Run tests for a specific package"
@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 ""
@echo "Note: Documentation targets are in the root Makefile."
default: help
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: sync $(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 cd .. && pwd):/workspace" --workdir /workspace/python 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
-rm -rf .uv-cache
clean: clean-venv clean-build clean-test
ifdef LOGS_DIR
test: pkg-test-all test-report
else
test: pkg-test-all
endif
ty: pkg-ty-all
lint:
uv run ruff check
lint-fix:
uv run ruff check --fix
.PHONY: default help pkg-test-all pkg-ty-all build generate sync \
clean clean-venv clean-build clean-test test test-report ty \
lint lint-fix \
pkg-ty-jumpstarter \
pkg-ty-jumpstarter-cli-admin \
pkg-ty-jumpstarter-kubernetes \
pkg-ty-jumpstarter-protocol