|
1 | 1 | set windows-shell := ["powershell.exe", "-NoLogo", "-Command"]
|
2 | 2 | set unstable := true
|
3 | 3 |
|
| 4 | +# list all available commands |
4 | 5 | default:
|
5 | 6 | @just --list
|
6 | 7 |
|
| 8 | +# install build tooling |
7 | 9 | init python="python":
|
8 | 10 | pip install pipx
|
9 | 11 | pipx ensurepath
|
10 | 12 | pipx install poetry
|
11 | 13 | poetry env use {{ python }}
|
12 | 14 | poetry run pip install --upgrade pip setuptools wheel
|
13 | 15 |
|
| 16 | +# install git pre-commit hooks |
14 | 17 | install-precommit:
|
15 | 18 | poetry run pre-commit install
|
16 | 19 |
|
| 20 | +# update and install development dependencies |
17 | 21 | install *OPTS:
|
18 | 22 | poetry lock
|
19 | 23 | poetry install -E rich {{ OPTS }}
|
20 | 24 | poetry run pre-commit install
|
21 | 25 |
|
| 26 | +# install documentation dependencies |
22 | 27 | install-docs:
|
23 | 28 | poetry lock
|
24 | 29 | poetry install --with docs
|
25 | 30 |
|
| 31 | +# install translation dependencies |
26 | 32 | install-translate:
|
27 | 33 | poetry lock
|
28 | 34 | poetry install --with translate
|
29 | 35 |
|
| 36 | +# install a dependency to a specific version e.g. just pin-dependency Django~=5.1.0 |
30 | 37 | pin-dependency +PACKAGES:
|
31 | 38 | poetry run pip install -U {{ PACKAGES }}
|
32 | 39 |
|
| 40 | +# run static type checking |
33 | 41 | check-types:
|
34 | 42 | poetry run mypy django_typer
|
35 | 43 | poetry run pyright
|
36 | 44 |
|
| 45 | +# run package checks |
37 | 46 | check-package:
|
38 | 47 | poetry check
|
39 | 48 | poetry run pip check
|
40 | 49 |
|
| 50 | +# remove doc build artifacts |
41 | 51 | clean-docs:
|
42 | 52 | python -c "import shutil; shutil.rmtree('./doc/build', ignore_errors=True)"
|
43 | 53 |
|
| 54 | +# remove the virtual environment |
44 | 55 | clean-env:
|
45 | 56 | python -c "import shutil, sys; shutil.rmtree(sys.argv[1], ignore_errors=True)" $(poetry env info --path)
|
46 | 57 |
|
| 58 | +# remove all git ignored files |
47 | 59 | clean-git-ignored:
|
48 | 60 | git clean -fdX
|
49 | 61 |
|
50 | 62 | # remove all non repository artifacts
|
51 | 63 | clean: clean-docs clean-env clean-git-ignored
|
52 | 64 |
|
| 65 | +# build html documentation |
53 | 66 | build-docs-html: install-docs
|
54 | 67 | poetry run sphinx-build --fresh-env --builder html --doctree-dir ./doc/build/doctrees ./doc/source ./doc/build/html
|
55 | 68 |
|
| 69 | +# build pdf documentation |
56 | 70 | build-docs-pdf: install-docs
|
57 | 71 | poetry run sphinx-build --fresh-env --builder latexpdf --doctree-dir ./doc/build/doctrees ./doc/source ./doc/build/pdf
|
58 | 72 |
|
| 73 | +# build the docs |
59 | 74 | build-docs: build-docs-html
|
60 | 75 |
|
| 76 | +# build the wheel distribution |
61 | 77 | build-wheel:
|
62 | 78 | poetry build -f wheel
|
63 | 79 |
|
| 80 | +# build the source distribution |
64 | 81 | build-sdist:
|
65 | 82 | poetry build -f sdist
|
66 | 83 |
|
| 84 | +# build docs and package |
67 | 85 | build: build-docs-html
|
68 | 86 | poetry build
|
69 | 87 |
|
| 88 | +# open the html documentation |
70 | 89 | open-docs:
|
71 | 90 | poetry run python -c "import webbrowser; webbrowser.open('file://$(pwd)/doc/build/html/index.html')"
|
72 | 91 |
|
| 92 | +# build and open the documentation |
73 | 93 | docs: build-docs-html open-docs
|
74 | 94 |
|
| 95 | +# serve the documentation, with auto-reload |
75 | 96 | docs-live:
|
76 | 97 | poetry run sphinx-autobuild doc/source doc/build --open-browser --watch django_typer --port 8000 --delay 1
|
77 | 98 |
|
| 99 | +# check the documentation links for broken links |
78 | 100 | check-docs-links:
|
79 | 101 | -poetry run sphinx-build -b linkcheck -Q -D linkcheck_timeout=10 ./doc/source ./doc/build
|
80 | 102 | poetry run python ./doc/broken_links.py
|
81 | 103 |
|
| 104 | +# lint the documentation |
82 | 105 | check-docs:
|
83 | 106 | poetry run doc8 --ignore-path ./doc/build --max-line-length 100 -q ./doc
|
84 | 107 |
|
| 108 | +# lint the code |
85 | 109 | check-lint:
|
86 | 110 | poetry run ruff check --select I
|
87 | 111 | poetry run ruff check
|
88 | 112 |
|
| 113 | +# check if the code needs formatting |
89 | 114 | check-format:
|
90 | 115 | poetry run ruff format --check
|
91 | 116 | poetry run ruff format --line-length 80 --check examples
|
92 | 117 |
|
| 118 | +# check that the readme renders |
93 | 119 | check-readme:
|
94 | 120 | poetry run python -m readme_renderer ./README.md -o /tmp/README.html
|
95 | 121 |
|
| 122 | +# sort the python imports |
96 | 123 | sort-imports:
|
97 | 124 | poetry run ruff check --fix --select I
|
98 | 125 |
|
| 126 | +# format the code and sort imports |
99 | 127 | format: sort-imports
|
100 | 128 | just --fmt --unstable
|
101 | 129 | poetry run ruff format
|
102 | 130 | poetry run ruff format --line-length 80 examples
|
103 | 131 |
|
| 132 | +# sort the imports and fix linting issues |
104 | 133 | lint: sort-imports
|
105 | 134 | poetry run ruff check --fix
|
106 | 135 |
|
| 136 | +# fix formatting, linting issues and import sorting |
107 | 137 | fix: lint format
|
108 | 138 |
|
| 139 | +# run all static checks |
109 | 140 | check: check-lint check-format check-types check-package check-docs check-docs-links check-readme
|
110 | 141 |
|
| 142 | +# run the tests that require rich not to be installed |
111 | 143 | test-no-rich:
|
112 | 144 | poetry run pip uninstall -y rich
|
113 | 145 | poetry run pytest --cov-append -m no_rich
|
114 | 146 |
|
| 147 | +# run the tests that require rich to be installed |
115 | 148 | test-rich:
|
116 | 149 | poetry run pytest --cov-append -m rich
|
117 | 150 |
|
| 151 | +# run all tests and log them |
118 | 152 | log-tests:
|
119 | 153 | poetry run python -m pytest --collect-only --disable-warnings -q --no-cov | poetry run python -c "from pathlib import Path; import sys; Path('./tests/tests.log').unlink(missing_ok=True); open('./tests/tests.log', 'a').close(); open('./tests/all_tests.log', 'w').writelines(sys.stdin)"
|
120 | 154 |
|
| 155 | +# run all tests |
121 | 156 | test-all: test-rich test-no-rich
|
122 | 157 | poetry run pip install colorama
|
123 | 158 | poetry run pytest --cov-append -m "not rich and not no_rich"
|
124 | 159 | poetry run pip uninstall -y colorama
|
125 | 160 | poetry run pytest --cov-append -k test_ctor_params
|
126 | 161 |
|
| 162 | +# run the tests and report if any were not run - sanity check |
127 | 163 | list-missed-tests: install log-tests test-all
|
128 | 164 | poetry run python ./tests/missed_tests.py
|
129 | 165 |
|
| 166 | +# test bash shell completions |
130 | 167 | [script("bash")]
|
131 | 168 | test-bash:
|
132 | 169 | poetry run pytest --cov-append tests/shellcompletion/test_shell_resolution.py::TestShellResolution::test_bash tests/test_parser_completers.py tests/shellcompletion/test_bash.py
|
133 | 170 |
|
| 171 | +# test zsh shell completions |
134 | 172 | [script("zsh")]
|
135 | 173 | test-zsh:
|
136 | 174 | poetry run pytest --cov-append tests/shellcompletion/test_shell_resolution.py::TestShellResolution::test_zsh tests/test_parser_completers.py tests/shellcompletion/test_zsh.py
|
137 | 175 |
|
| 176 | +# test powershell shell completions |
138 | 177 | [script("powershell")]
|
139 | 178 | test-powershell:
|
140 | 179 | poetry run pytest --cov-append tests/shellcompletion/test_shell_resolution.py::TestShellResolution::test_powershell tests/test_parser_completers.py tests/test_parser_completers.py tests/shellcompletion/test_powershell.py::PowerShellTests tests/shellcompletion/test_powershell.py::PowerShellExeTests
|
141 | 180 |
|
| 181 | +# test pwsh shell completions |
142 | 182 | [script("pwsh")]
|
143 | 183 | test-pwsh:
|
144 | 184 | poetry run pytest --cov-append tests/shellcompletion/test_shell_resolution.py::TestShellResolution::test_pwsh tests/test_parser_completers.py tests/shellcompletion/test_powershell.py::PWSHTests tests/shellcompletion/test_powershell.py::PWSHExeTests
|
145 | 185 |
|
| 186 | +# test fish shell completions |
146 | 187 | [script("fish")]
|
147 | 188 | test-fish:
|
148 | 189 | poetry run pytest --cov-append tests/shellcompletion/test_shell_resolution.py::TestShellResolution::test_fish tests/test_parser_completers.py tests/shellcompletion/test_fish.py
|
149 | 190 |
|
| 191 | +# run tests |
150 | 192 | test *TESTS:
|
151 | 193 | poetry run pytest --cov-append {{ TESTS }}
|
152 | 194 |
|
| 195 | +# run the pre-commit checks |
153 | 196 | precommit:
|
154 | 197 | poetry run pre-commit
|
155 | 198 |
|
| 199 | +# generate the test coverage report |
156 | 200 | coverage:
|
157 | 201 | poetry run coverage combine --keep *.coverage
|
158 | 202 | poetry run coverage report
|
159 | 203 | poetry run coverage xml
|
160 | 204 |
|
| 205 | +# run the command in the virtual environment |
161 | 206 | run +ARGS:
|
162 | 207 | poetry run {{ ARGS }}
|
163 | 208 |
|
| 209 | +# generate translations using google translate |
164 | 210 | translate: install-translate
|
165 | 211 | poetry run ./manage.py translate --settings tests.settings.translate
|
0 commit comments