-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjustfile
More file actions
172 lines (151 loc) · 4.89 KB
/
justfile
File metadata and controls
172 lines (151 loc) · 4.89 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
# justfile for gp-sphinx
# https://just.systems/
set shell := ["bash", "-uc"]
# File patterns
py_files := "find . -type f -not -path '*/\\.*' | grep -i '.*[.]py$' 2> /dev/null"
doc_files := "find . -type f -not -path '*/\\.*' | grep -i '.*[.]rst$\\|.*[.]md$\\|.*[.]css$\\|.*[.]py$\\|mkdocs\\.yml\\|CHANGES\\|TODO\\|.*conf\\.py' 2> /dev/null"
all_files := "find . -type f -not -path '*/\\.*' | grep -i '.*[.]py$\\|.*[.]rst$\\|.*[.]md$\\|.*[.]css$\\|.*[.]py$\\|mkdocs\\.yml\\|CHANGES\\|TODO\\|.*conf\\.py' 2> /dev/null"
fast_test_addopts := "--tb=short --no-header --showlocals"
pytest_local_opts := "-o tmp_path_retention_policy=none"
pytest_full_basetemp := ".cache/pytest-full"
pytest_fast_basetemp := ".cache/pytest-fast"
pytest_watch_basetemp := ".cache/pytest-watch"
pytest_fast_watch_basetemp := ".cache/pytest-fast-watch"
# List all available commands
default:
@just --list
# Run tests with pytest
test *args:
#!/usr/bin/env bash
set -euo pipefail
mkdir -p .cache
cache_root="$(pwd)/{{ pytest_full_basetemp }}"
recipe_args="{{ args }}"
if [[ -n "${recipe_args// }" ]]; then
uv run pytest \
-s \
{{ pytest_local_opts }} \
--basetemp="${cache_root}" \
{{ args }}
else
uv run pytest \
-s \
{{ pytest_local_opts }} \
--basetemp="${cache_root}"
fi
# Run the fast local test lane without doctest-modules or integration tests
test-fast:
#!/usr/bin/env bash
set -euo pipefail
mkdir -p .cache
cache_root="$(pwd)/{{ pytest_fast_basetemp }}"
uv run pytest \
{{ pytest_local_opts }} \
-o "addopts={{ fast_test_addopts }}" \
--basetemp="${cache_root}" \
-q \
--capture=tee-sys \
tests \
-m "not integration"
# Run tests then start continuous testing with pytest-watcher
start:
#!/usr/bin/env bash
set -euo pipefail
mkdir -p .cache
cache_root="$(pwd)/{{ pytest_watch_basetemp }}"
just test
uv run ptw . \
--runner "uv run pytest -s {{ pytest_local_opts }} --basetemp=${cache_root}"
# Run the fast local test lane continuously with pytest-watcher
start-fast:
#!/usr/bin/env bash
set -euo pipefail
mkdir -p .cache
cache_root="$(pwd)/{{ pytest_fast_watch_basetemp }}"
just test-fast
uv run ptw . \
--runner "uv run pytest {{ pytest_local_opts }} -o \"addopts={{ fast_test_addopts }}\" --basetemp=${cache_root} -q --capture=tee-sys tests -m \"not integration\""
# Watch files and run tests on change (requires entr)
watch-test:
#!/usr/bin/env bash
set -euo pipefail
mkdir -p .cache
if command -v entr > /dev/null; then
{{ all_files }} | entr -c just test
else
just test
just _entr-warn
fi
# Build documentation
build-docs:
just -f docs/justfile html
# Watch files and rebuild docs on change
watch-docs:
#!/usr/bin/env bash
set -euo pipefail
if command -v entr > /dev/null; then
{{ doc_files }} | entr -c just build-docs
else
just build-docs
just _entr-warn
fi
# Serve documentation
serve-docs:
just -f docs/justfile serve
# Watch and serve docs simultaneously
dev-docs:
#!/usr/bin/env bash
set -euo pipefail
just watch-docs &
just serve-docs
# Start documentation server with auto-reload
start-docs:
just -f docs/justfile start
# Start documentation design mode (watches static files)
design-docs:
just -f docs/justfile design
# Format code with ruff
ruff-format:
uv run ruff format .
# Run ruff linter
ruff:
uv run ruff check .
# Watch files and run ruff on change
watch-ruff:
#!/usr/bin/env bash
set -euo pipefail
if command -v entr > /dev/null; then
{{ py_files }} | entr -c just ruff
else
just ruff
just _entr-warn
fi
# Run mypy type checker
mypy:
uv run mypy $({{ py_files }})
# Watch files and run mypy on change
watch-mypy:
#!/usr/bin/env bash
set -euo pipefail
if command -v entr > /dev/null; then
{{ py_files }} | entr -c just mypy
else
just mypy
just _entr-warn
fi
[private]
_entr-warn:
@echo "----------------------------------------------------------"
@echo " ! File watching functionality non-operational ! "
@echo " "
@echo "Install entr(1) to automatically run tasks on file change."
@echo "See https://eradman.com/entrproject/ "
@echo "----------------------------------------------------------"
# Bump every workspace version literal (pyproject, __init__.py, tests, scripts).
# Usage: just bump-version 0.0.1a8
bump-version new_version:
@echo "Bumping workspace version to {{new_version}}..."
uv run python scripts/ci/bump_version.py {{new_version}}
uv lock
uv run python scripts/ci/package_tools.py check-versions
@echo "Done. Review with: git diff"