Repository navigation
Expand file tree
/
Copy pathjustfile
More file actions
195 lines (156 loc) · 6.85 KB
/
Copy pathjustfile
File metadata and controls
195 lines (156 loc) · 6.85 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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
# Task runner entry points for Muru. Run `just` to list them.
set shell := ["bash", "-euo", "pipefail", "-c"]
# Crates that build without a Python interpreter (muru-py needs one).
default_crates := "--workspace --exclude muru-py"
venv_python := justfile_directory() / ".venv" / "bin" / "python"
# List the available recipes.
default:
@just --list --unsorted
# Check every prerequisite and print install commands for what is missing.
doctor *args:
sh scripts/doctor.sh {{args}}
# Install Rust components, cargo tools, Python interpreters and the dev environment.
bootstrap:
rustup show active-toolchain >/dev/null
rustup component add rustfmt clippy llvm-tools-preview
just _cargo-tool cargo-nextest cargo-llvm-cov cargo-deny cargo-audit
uv python install 3.11 3.12 3.13 3.14 3.14t 3.15 3.15t
uv sync
uv run pre-commit install
uv run pre-commit install --hook-type commit-msg
just dev
# Optional extras for the conformance suites (h2spec, Autobahn) and fuzzing.
bootstrap-conformance:
bash packaging/dev/fetch-h2spec.sh
bootstrap-fuzz:
rustup toolchain install nightly
just _cargo-tool cargo-fuzz
# Build the extension into the development virtualenv. Run again after `uv sync`, which removes it.
dev:
cd packages/muru && uv run --project ../.. maturin develop
# Formatting, lints, types and repository text checks.
lint: lint-text lint-rust lint-python
lint-text:
sh scripts/check-no-em-dashes.sh
uv run python scripts/check-user-text.py
uv run python scripts/check-user-docs.py
uv run python scripts/check-layout.py $(git ls-files --cached --others --exclude-standard '*.py' '*.rs')
lint-rust:
cargo fmt --all --check
cargo clippy {{default_crates}} --all-targets -- -D warnings
PYO3_PYTHON="{{venv_python}}" cargo clippy -p muru-py --all-targets -- -D warnings
lint-python:
uv run ruff format --check .
uv run ruff check .
uv run mypy
# Apply formatters.
fmt:
cargo fmt --all
uv run ruff format .
uv run ruff check --fix .
# Rust unit tests and Python unit tests.
test: test-rust test-python
# The extension's own tests link against the development virtualenv's
# libpython, which Linux finds through LD_LIBRARY_PATH.
test-rust:
cargo nextest run {{default_crates}}
PYO3_PYTHON="{{venv_python}}" LD_LIBRARY_PATH="$("{{venv_python}}" -c 'import sysconfig; print(sysconfig.get_config_var("LIBDIR"))')" cargo nextest run -p muru-py
test-python:
uv run pytest
# Integration scenarios that need no Docker or network (builds muructl and the extension first).
test-integration: dev
cargo build -p muructl
uv run pytest tests/integration
# WSGI, ASGI, HTTP and WebSocket conformance suites (builds muructl and the extension first).
conformance: dev
cargo build -p muructl
uv run pytest tests/conformance
# Container scenarios and the Autobahn WebSocket suite (needs a container runtime).
test-docker:
uv run pytest tests/integration tests/conformance -m requires_docker
# Linux suites inside the development container.
test-linux:
@echo "not yet implemented: runs the Linux suites in images/dev with the source bind-mounted"
# Run one fuzz target.
fuzz target:
cargo +nightly fuzz run {{target}}
# Performance scenarios (Linux only for representative numbers).
bench *args:
uv run --group bench python bench/run.py {{args}}
# Regenerate the configuration reference and JSON Schemas from muru-config.
reference:
MURU_UPDATE_REFERENCE=1 cargo test -p muru-config --test reference
# Build the documentation with warnings as errors. Every page is read
# again (-E), as CI reads them: Sphinx reports a page's warnings only when
# it reads the page, so a build that reused the pages of an earlier one
# would pass with a warning that fails in CI.
docs:
uv run sphinx-build -W --keep-going -E -b html docs docs/_build/html
# Build the LaTeX source for the PDF, which Read the Docs turns into the PDF (no TeX needed here).
docs-latex:
uv run sphinx-build -W --keep-going -E -b latex docs docs/_build/latex
# Check documentation links.
docs-linkcheck:
uv run sphinx-build -b linkcheck docs docs/_build/linkcheck
# Build the documentation and open it in the browser.
docs-open: docs
#!/usr/bin/env bash
set -euo pipefail
page="docs/_build/html/index.html"
if [[ "$(uname -s)" == "Darwin" ]]; then
open "$page"
elif command -v xdg-open >/dev/null 2>&1; then
xdg-open "$page"
else
echo "open $page in a browser"
fi
# Linux virtual machine for Linux-only tests: starts the muru instance, or creates it when there is none.
vm-up:
#!/usr/bin/env bash
set -euo pipefail
if limactl list -q | grep -qx muru; then
limactl start muru
else
limactl start --name muru packaging/dev/lima.yaml
fi
# Copy the source into the VM, build there, and run the unit and integration suites.
vm-test *args:
limactl shell muru -- bash -lc "bash '{{justfile_directory()}}/packaging/dev/vm-run.sh' '{{justfile_directory()}}' test {{args}}"
# Copy the source into the VM, build there, and run the benchmarks (see bench/README.md).
vm-bench *args:
limactl shell muru -- bash -lc "bash '{{justfile_directory()}}/packaging/dev/vm-run.sh' '{{justfile_directory()}}' bench {{args}}"
vm-shell:
limactl shell muru
# Print the project version.
version:
@grep -m1 '^version = ' Cargo.toml | cut -d'"' -f2
# Set the project version (Cargo.toml is the only place it is stated).
bump version:
#!/usr/bin/env bash
set -euo pipefail
[[ "{{version}}" =~ ^[0-9]+\.[0-9]+\.[0-9]+([a-z0-9.+-]*)?$ ]] || { echo "not a version: {{version}}" >&2; exit 1; }
sed -i.bak -E 's/^version = "[^"]+"/version = "{{version}}"/' Cargo.toml && rm Cargo.toml.bak
if command -v cargo >/dev/null 2>&1 && [[ -f Cargo.lock ]]; then cargo update --workspace --offline >/dev/null; fi
echo "version is now $(just version)"
# Preview the changelog that the fragments would produce.
changelog-draft:
uv run towncrier build --draft --version "$(just version-pep440)"
# Build the changelog from the fragments, for the release pull request.
changelog:
uv run towncrier build --yes --version "$(just version-pep440)"
# Print the project version in PEP 440 form, as PyPI shows it.
version-pep440:
@uv run python -c "from packaging.version import Version; print(Version('$(just version)'))"
# Remove build output.
clean:
cargo clean
rm -rf docs/_build .nox .pytest_cache .mypy_cache .ruff_cache
# Remove the dev profile's build output only, which is where builds pile up.
mostlyclean:
cargo clean --profile dev
# Install a cargo tool with cargo-binstall when available, otherwise from source.
_cargo-tool +tools:
for tool in {{tools}}; do \
if command -v "$tool" >/dev/null 2>&1; then continue; fi; \
if command -v cargo-binstall >/dev/null 2>&1; then cargo binstall -y "$tool"; else cargo install --locked "$tool"; fi; \
done