Skip to content

Commit 8787dc2

Browse files
committed
Add a just clean recipe
1 parent 6ca5776 commit 8787dc2

File tree

1 file changed

+36
-31
lines changed

1 file changed

+36
-31
lines changed

justfile

Lines changed: 36 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ _default:
55
@just --list
66

77
export COVERAGE_RCFILE := justfile_directory() + "/.coveragerc"
8-
98
uv_update_script := justfile_directory() + "/tools/uv_update.py"
109
docker_folder_exists := path_exists(invocation_directory() + '/docker')
1110
src_folder_exists := path_exists(invocation_directory() + '/src')
@@ -25,7 +24,7 @@ has_yamllint := if pyproject_toml_contents =~ '"yamllint[<=]=[A-Za-z0-9_.\-]+"'
2524
has_vale := if pyproject_toml_contents =~ '"vale[<=]=[A-Za-z0-9_.\-]+"' { "true" } else { "false" }
2625
src_folder := if src_folder_exists == "true" { "src" } else { "" }
2726
tests_folder := if tests_folder_exists == "true" { "tests" } else { "" }
28-
code := if trim(src_folder + " " + tests_folder) == "" { "*.py" } else { src_folder + " " + tests_folder}
27+
code := if trim(src_folder + " " + tests_folder) == "" { "*.py" } else { src_folder + " " + tests_folder }
2928

3029
# === Update dependencies ===
3130

@@ -45,18 +44,7 @@ alias update-deps := update-dependencies
4544

4645
# Update direct and indirect dependencies.
4746
[parallel]
48-
update-dependencies: \
49-
(update-py-dependencies "components/shared_code") \
50-
(update-py-dependencies "components/api_server") \
51-
(update-py-dependencies "components/collector") \
52-
(update-py-dependencies "components/notifier") \
53-
(update-js-dependencies "components/frontend") \
54-
(update-js-dependencies "components/renderer") \
55-
(update-py-dependencies "docs") \
56-
(update-js-dependencies "docs") \
57-
(update-py-dependencies "release") \
58-
(update-py-dependencies "tests/application_tests") \
59-
(update-py-dependencies "tests/feature_tests")
47+
update-dependencies: (update-py-dependencies "components/shared_code") (update-py-dependencies "components/api_server") (update-py-dependencies "components/collector") (update-py-dependencies "components/notifier") (update-js-dependencies "components/frontend") (update-js-dependencies "components/renderer") (update-py-dependencies "docs") (update-js-dependencies "docs") (update-py-dependencies "release") (update-py-dependencies "tests/application_tests") (update-py-dependencies "tests/feature_tests")
6048

6149
# === Install dependencies ===
6250

@@ -89,10 +77,7 @@ build-docs: install-py-dependencies
8977
# Build the artifacts or components from the code, in the current working directory. Builds Docker components if the working directory is the project root. Pass one or more of 'api_server', 'collector', 'notifier', 'frontend', 'proxy', 'database', 'renderer', 'testdata', or 'testldap' to build specific components or none to build them all.
9078
[no-cd]
9179
build *components:
92-
{{ if has_sphinx == "true" { "just build-docs" }
93-
else { if js_build_script != "{}" { "just build-js" }
94-
else { if docker_folder_exists == "true" { f"docker compose build {{ components }}" }
95-
else { "echo 'Nothing to build in this folder'" } }} }}
80+
{{ if has_sphinx == "true" { "just build-docs" } else if js_build_script != "{}" { "just build-js" } else if docker_folder_exists == "true" { f"docker compose build {{components}}" } else { "echo 'Nothing to build in this folder'" } }}
9681
9782
# === Start components ===
9883
@@ -111,10 +96,7 @@ start-js-component: install-js-dependencies
11196
# Start component(s). Starts a component locally if the current working directory is a component folder (components/api_server, components/collector, components/notifier, or components/frontend). Starts components in Docker if the working directory is the project root. Pass one or more of 'api_server', 'collector', 'notifier', 'frontend', 'proxy', 'database', 'renderer', 'testdata', or 'testldap' to start specific components or none to start them all.
11297
[no-cd]
11398
start *components:
114-
{{ if pyproject_toml_exists == "true" { "just start-py-component" }
115-
else { if js_start_script != "{}" { "just start-js-component" }
116-
else { if docker_folder_exists == "true" { f"docker compose up {{ components }}" }
117-
else { "echo 'Nothing to start in this folder'" } }} }}
99+
{{ if pyproject_toml_exists == "true" { "just start-py-component" } else if js_start_script != "{}" { "just start-js-component" } else if docker_folder_exists == "true" { f"docker compose up {{components}}" } else { "echo 'Nothing to start in this folder'" } }}
118100

119101
# === Run tests ===
120102

@@ -139,7 +121,7 @@ js-unit-test *cov: install-js-dependencies
139121
[no-cd]
140122
test *cov:
141123
{{ if has_py_unit_tests == "true" { "just py-unit-test" } else { "" } }}
142-
{{ if js_test_script != "{}" { f"just js-unit-test {{ cov }}" } else { "" } }}
124+
{{ if js_test_script != "{}" { f"just js-unit-test {{cov}}" } else { "" } }}
143125
{{ if has_py_unit_tests + js_test_script == "false{}" { "echo 'Nothing to test'" } else { "" } }}
144126
145127
# === Run checks ===
@@ -148,16 +130,16 @@ test *cov:
148130
[no-cd]
149131
[private]
150132
check-py: install-py-dependencies
151-
uv run ruff format --check {{code}}
152-
uv run ruff check {{code}}
153-
uv run mypy {{code}}
154-
uv run fixit lint {{code}}
133+
uv run ruff format --check {{ code }}
134+
uv run ruff check {{ code }}
135+
uv run mypy {{ code }}
136+
uv run fixit lint {{ code }}
155137
uv run pyproject-fmt --check pyproject.toml
156138
uv run troml check
157139
uv export --quiet --directory . --format requirements-txt --no-emit-package shared-code > /tmp/requirements.txt
158140
uv run pip-audit --requirement /tmp/requirements.txt --disable-pip
159-
uv run bandit --configfile pyproject.toml --quiet --recursive {{code}}
160-
uv run vulture --exclude .venv --min-confidence 0 {{code}} .vulture-whitelist.py
141+
uv run bandit --configfile pyproject.toml --quiet --recursive {{ code }}
142+
uv run vulture --exclude .venv --min-confidence 0 {{ code }} .vulture-whitelist.py
161143
{{ if has_vale == "true" { "uv run vale sync; uv run vale --no-wrap --glob '*.md' src" } else { "" } }}
162144
{{ if has_yamllint == "true" { "uv run yamllint ../publiccode.yml" } else { "" } }}
163145
{{ if has_sphinx == "true" { "uv run sphinx-build -M linkcheck src build" } else { "" } }}
@@ -198,13 +180,13 @@ check:
198180
# Fix quality issues that can be fixed automatically, in the current working directory.
199181
[no-cd]
200182
fix:
201-
{{ if pyproject_toml_exists == "true" {"just fix-py"} else { "" } }}
183+
{{ if pyproject_toml_exists == "true" { "just fix-py" } else { "" } }}
202184
{{ if js_fix_script != "{}" { "just fix-js" } else { "" } }}
203185
204186
# === Release ===
205187
206188
# Release Quality-time. Run `just release --help` for more information.
207-
[working-directory: 'release']
189+
[working-directory('release')]
208190
release *args:
209191
uv run --script release.py {{ args }}
210192
@@ -214,3 +196,26 @@ release *args:
214196
[no-cd]
215197
[private]
216198
ci $CI="true": test check
199+
200+
# === Clean ===
201+
202+
# Clean caches, build folders, and generated files
203+
clean:
204+
rm -f .coverage
205+
rm -f */.coverage
206+
rm -f */*/.coverage
207+
rm -rf build
208+
rm -rf */build
209+
rm -rf */*/build
210+
rm -rf .*_cache
211+
rm -rf */.*_cache
212+
rm -rf */*/.*_cache
213+
rm -rf */node_modules
214+
rm -rf */*/node_modules
215+
rm -rf */*.egg-info
216+
rm -rf */*/*.egg-info
217+
rm -rf */*/*/*.egg-info
218+
rm -rf */.venv
219+
rm -rf */*/.venv
220+
rm -rf */*/dist
221+
rm -rf */*/htmlcov

0 commit comments

Comments
 (0)