Skip to content

Commit ccb2d63

Browse files
authored
Remove duplication in justfile (#12944)
1 parent 856b98c commit ccb2d63

File tree

1 file changed

+29
-21
lines changed

1 file changed

+29
-21
lines changed

justfile

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,15 @@ code := if trim(src_folder + " " + tests_folder) == "" { ".?*.py" } else { src_f
3131
random_string := uuid()
3232
uv_run := "uv run --quiet"
3333
update_dep := uv_run + " --project tools/update_dependencies tools/update_dependencies/src/update_"
34+
coverage := uv_run + " coverage"
35+
fixit := uv_run + " fixit --quiet"
3436
pyproject_fmt := uv_run + " pyproject-fmt --no-generate-python-version-classifiers"
37+
ruff := uv_run + " ruff --quiet"
38+
troml := uv_run + " troml"
39+
vulture := uv_run + " vulture --exclude .venv --min-confidence 0"
40+
vulture_whitelist := ".vulture-whitelist.py"
41+
sphinx_build := uv_run + " sphinx-build"
42+
npm_run := "npm run --silent"
3543

3644
# === Update dependencies ===
3745

@@ -109,14 +117,14 @@ build-docker *components:
109117
[private]
110118
build-js: install-js-dependencies
111119
?[ {{ has_js_build_script }} = true ]
112-
npm run --ignore-scripts --silent build
120+
{{ npm_run }} --ignore-scripts build
113121

114122
# Build the documentation from the code.
115123
[no-cd]
116124
[private]
117125
build-docs: install-py-dependencies
118126
?[ {{ has_sphinx }} = true ]
119-
{{ uv_run }} sphinx-build src build
127+
{{ sphinx_build }} src build
120128

121129
# Build artifacts or components from the code. Run `just build-help` for more information.
122130
[no-cd]
@@ -155,7 +163,7 @@ start-py-component: install-py-dependencies
155163
[private]
156164
start-js-component: install-js-dependencies
157165
?[ {{ has_js_start_script }} = true ]
158-
npm run --silent start
166+
{{ npm_run }} start
159167

160168
# Start one or more component(s). Run `just start-help` for more information.
161169
[no-cd]
@@ -182,17 +190,17 @@ start-help:
182190
[private]
183191
py-unit-test $PYTHONDEVMODE="1" $PYTHONPATH="src:$PYTHONPATH": install-py-dependencies
184192
?[ {{ has_py_unit_tests }} = true ]
185-
{{ uv_run }} coverage run -m unittest --quiet
186-
{{ uv_run }} coverage report --fail-under=0
187-
{{ uv_run }} coverage html --quiet --fail-under=0
188-
{{ uv_run }} coverage xml --quiet # Fail if coverage is too low, but only after the text and HTML reports have been generated
193+
{{ coverage }} run -m unittest --quiet
194+
{{ coverage }} report --fail-under=0
195+
{{ coverage }} html --quiet --fail-under=0
196+
{{ coverage }} xml --quiet # Fail if coverage is too low, but only after the text and HTML reports have been generated
189197

190198
# Run the JavaScript unit tests. Pass 'cov' to also measure the test coverage.
191199
[no-cd]
192200
[private]
193201
js-unit-test *cov: install-js-dependencies
194202
?[ {{ has_js_test_script }} = true ]
195-
npm run --silent test {{ if cov == "cov" { "-- --coverage" } else { "" } }}
203+
{{ npm_run }} test {{ if cov == "cov" { "-- --coverage" } else { "" } }}
196204

197205
# Run the unit tests, in the current working directory. Pass 'cov' to also measure the JavaScript test coverage (Python test coverage is always measured).
198206
[no-cd]
@@ -214,15 +222,15 @@ mypy: install-py-dependencies
214222
[private]
215223
fixit: install-py-dependencies
216224
?[ {{ pyproject_toml_exists }} = true ]
217-
{{ uv_run }} fixit --quiet lint {{ code }}
225+
{{ fixit }} lint {{ code }}
218226

219227
# Run ruff.
220228
[no-cd]
221229
[private]
222230
ruff: install-py-dependencies
223231
?[ {{ pyproject_toml_exists }} = true ]
224-
{{ uv_run }} ruff format --quiet --check {{ code }}
225-
{{ uv_run }} ruff check --quiet {{ code }}
232+
{{ ruff }} format --check {{ code }}
233+
{{ ruff }} check {{ code }}
226234

227235
# Run pyproject-fmt.
228236
[no-cd]
@@ -236,7 +244,7 @@ pyproject-fmt: install-py-dependencies
236244
[private]
237245
troml: install-py-dependencies
238246
?[ {{ pyproject_toml_exists }} = true ]
239-
{{ uv_run }} troml check
247+
{{ troml }} check
240248

241249
# Run pip-audit.
242250
[no-cd]
@@ -266,7 +274,7 @@ bandit: install-py-dependencies
266274
[private]
267275
vulture: install-py-dependencies
268276
?[ {{ pyproject_toml_exists }} = true ]
269-
{{ uv_run }} vulture --exclude .venv --min-confidence 0 {{ code }} .vulture-whitelist.py
277+
{{ vulture }} {{ code }} {{ vulture_whitelist }}
270278

271279
# Run vale.
272280
[no-cd]
@@ -288,7 +296,7 @@ yamllint: install-py-dependencies
288296
sphinx: install-py-dependencies
289297
?[ {{ has_sphinx }} = true ]
290298
echo Running sphinx linkcheck may take a while, be patient...
291-
{{ uv_run }} sphinx-build -M linkcheck src build --quiet --jobs auto
299+
{{ sphinx_build }} -M linkcheck src build --quiet --jobs auto
292300

293301
# Run Python checks.
294302
[no-cd]
@@ -301,7 +309,7 @@ check-py: mypy fixit ruff pyproject-fmt troml pip-audit uv-audit bandit vulture
301309
[private]
302310
npm-lint: install-js-dependencies
303311
?[ {{ package_json_exists }} = true ]
304-
npm run --silent lint --if-present
312+
{{ npm_run }} lint --if-present
305313

306314
# Run npm audit.
307315
[no-cd]
@@ -336,21 +344,21 @@ check: check-js check-py
336344
[private]
337345
fix-py: install-py-dependencies
338346
?[ {{ pyproject_toml_exists }} = true ]
339-
{{ uv_run }} ruff format --quiet {{ code }}
340-
{{ uv_run }} ruff check --quiet --fix {{ code }}
341-
{{ uv_run }} fixit fix {{ code }}
347+
{{ ruff }} format {{ code }}
348+
{{ ruff }} check --fix {{ code }}
349+
{{ fixit }} fix {{ code }}
342350
# Pyproject-fmt returns exit code 1 when pyproject.toml needs formatting, ignore it when formatting:
343351
{{ pyproject_fmt }} --no-print-diff pyproject.toml || true
344-
{{ uv_run }} troml suggest --fix
352+
{{ troml }} suggest --fix
345353
# Vulture returns exit code 3 when there is dead code, ignore it when writing the whitelist:
346-
{{ uv_run }} vulture --exclude .venv --min-confidence 0 --make-whitelist {{ code }} > .vulture-whitelist.py || true
354+
{{ vulture }} --make-whitelist {{ code }} > {{ vulture_whitelist }} || true
347355

348356
# Fix JavaScript quality issues that can be fixed automatically.
349357
[no-cd]
350358
[private]
351359
fix-js: install-js-dependencies
352360
?[ {{ has_js_fix_script }} = true ]
353-
npm run --silent fix
361+
{{ npm_run }} fix
354362

355363
# Fix quality issues that can be fixed automatically, in the current working directory.
356364
[no-cd]

0 commit comments

Comments
 (0)