Repository navigation
Expand file tree
/
Copy pathjustfile
More file actions
94 lines (78 loc) · 4.02 KB
/
Copy pathjustfile
File metadata and controls
94 lines (78 loc) · 4.02 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
default: install lint test
# Install/refresh deps: upgrade the lockfile, sync all extras + the lint group.
install:
uv lock --upgrade
uv sync --all-extras --frozen --group lint
# Autofix lint: eof-fixer, ruff format, ruff check --fix, ty type-check.
lint:
uv run eof-fixer .
uv run ruff format
uv run ruff check --fix
uv run ty check
# CI lint (no autofix) — the same checks as `lint`.
lint-ci:
uv run eof-fixer . --check
uv run ruff format --check
uv run ruff check --no-fix
uv run ty check
adr_check_source := "https://raw.githubusercontent.com/modern-python/.github/main/tests/test_adr_citations.py"
# Tracks main on purpose: the shared check is unpinned.
adr-check:
#!/usr/bin/env sh
set -eu
dir="$(mktemp -d .adr-check.XXXXXX)"
trap 'rm -rf "$dir"' EXIT
curl -fsSL "{{ adr_check_source }}" -o "$dir/test_adr_citations.py"
uv run --no-sync pytest --rootdir=. --noconftest -o addopts= "$dir/test_adr_citations.py"
# Run pytest with NO coverage (targeted runs won't trip the gate). Passes args through.
test *args:
uv run --no-sync pytest {{ args }}
# Run the thread_race tests only, selected by marker across the whole suite. Passes args through.
test-race *args:
uv run --no-sync pytest -m thread_race {{ args }}
# Run the python code blocks in docs/ as tests (Sybil, wired in conftest.py). Kept out of
# test-ci so doc examples never count toward library coverage. Passes args through.
test-docs *args:
uv run --no-sync pytest docs {{ args }}
# Packages the docs import that no modern-di-<page> package depends on.
docs_integration_extras := "faststream[kafka,nats] flask[async] aiogram-dialog sqlalchemy[asyncio] asyncpg redis pydantic-ai-slim[openai]"
# Run every page under docs/, the framework pages under docs/integrations/ included, with the latest
# modern-di-<page> release of every integration and the extras above installed and modern-di pinned to
# this checkout, so no block skips for a missing package. Builds a throwaway venv; uv.lock is untouched.
test-docs-integrations *args:
#!/usr/bin/env sh
set -eu
dir="$(mktemp -d)"
trap 'rm -rf "$dir"' EXIT
echo "modern-di @ file://$PWD" > "$dir/overrides.txt"
packages="$(ls docs/integrations/*.md | sed -e 's#.*/##' -e 's#[.]md$##' | grep -vx writing-integrations | sed 's#^#modern-di-#')"
uv venv --quiet "$dir/venv"
uv pip install --quiet --python "$dir/venv" --overrides "$dir/overrides.txt" \
--editable . pytest pytest-asyncio sybil {{ docs_integration_extras }} $packages
uv pip list --python "$dir/venv" | grep '^modern-di'
"$dir/venv/bin/python" -m pytest docs --docs-integrations {{ args }}
# The gated full run: 100% line and branch coverage of modern_di required. CI runs this.
test-ci:
uv run --no-sync pytest --cov --cov-report term-missing --cov-report xml
# Run the guard-tier benchmark suite (zero-dep; pytest-benchmark). Excludes the
# comparative tier, whose deps live in benchmarks/comparative and are not in this env.
bench:
uv run --no-sync pytest benchmarks/ --ignore=benchmarks/comparative --benchmark-only
# Comparative cross-framework benchmarks (isolated env: dishka, that-depends,
# dependency-injector, wireup + editable modern-di). First run resolves deps.
bench-compare:
uv run --project benchmarks/comparative pytest benchmarks/comparative/ --benchmark-only
# Run the comparative tier N times and print the published markdown ratio table.
# This is what generates the table in docs/introduction/performance.md — never hand-assemble it.
bench-report runs="5":
uv run --no-sync python benchmarks/report.py --runs {{ runs }}
# Build + publish to PyPI. Version comes from the git tag ($GITHUB_REF_NAME); no pyproject bump.
# Auth via PyPI Trusted Publishing (OIDC); uv publish auto-detects the CI id-token.
publish:
rm -rf dist
uv version $GITHUB_REF_NAME
uv build
uv publish
# Build the docs site, failing on broken links / nav warnings; CI runs this on every PR.
docs-build:
uvx --with-requirements docs/requirements.txt mkdocs build --strict