Skip to content

Commit a0cbcfd

Browse files
committed
Add a justfile, roughly equivalent to the makefile
1 parent 2f5fb33 commit a0cbcfd

1 file changed

Lines changed: 125 additions & 0 deletions

File tree

justfile

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
LANGUAGES := "de"
2+
GLUE_PLUGINS := `ls pulp-glue/src/pulp_glue/`
3+
CLI_PLUGINS := `ls src/pulpcore/cli/`
4+
5+
# Show discovered plugins
6+
info:
7+
@echo "Pulp glue"
8+
@echo "plugins: {{ GLUE_PLUGINS }}"
9+
@echo "Pulp CLI"
10+
@echo "plugins: {{ CLI_PLUGINS }}"
11+
12+
# Build all packages
13+
[group('build')]
14+
build:
15+
uv build --all
16+
17+
# Format code and sort imports
18+
[group('lint')]
19+
format:
20+
#!/usr/bin/env -S uv run --isolated --group lint bash
21+
set -euxo pipefail
22+
ruff format
23+
ruff check --select I --fix
24+
25+
# Auto-fix lint violations
26+
[group('lint')]
27+
autofix:
28+
#!/usr/bin/env -S uv run --isolated --group lint bash
29+
set -euxo pipefail
30+
uv lock
31+
ruff check --fix
32+
33+
# Run all linters
34+
[group('lint')]
35+
lint:
36+
#!/usr/bin/env -S uv run --isolated --group lint bash
37+
set -euxo pipefail
38+
uv lock --check
39+
find tests .ci -name '*.sh' -print0 | xargs -0 shellcheck -x
40+
ruff format --check --diff
41+
ruff check
42+
.ci/scripts/check_click_for_mypy.py
43+
mypy
44+
cd pulp-glue && mypy
45+
echo "🙊 Code 🙈 LGTM 🙉 !"
46+
47+
[private]
48+
[no-exit-message]
49+
setup-test-config:
50+
#!/usr/bin/env bash
51+
if [ ! -f tests/cli.toml ]; then
52+
cp tests/cli.toml.example tests/cli.toml
53+
echo "In order to configure the tests to talk to your test server, you might need to edit tests/cli.toml ."
54+
fi
55+
56+
# Run all tests
57+
[group('test')]
58+
test: setup-test-config
59+
uv run pytest -v tests pulp-glue/tests cookiecutter/pulp_filter_extension.py
60+
61+
# Run live tests against a running server
62+
[group('test')]
63+
livetest: setup-test-config
64+
uv run pytest -v tests pulp-glue/tests -m live
65+
66+
# Run live tests in parallel
67+
[group('test')]
68+
paralleltest: setup-test-config
69+
uv run pytest -v tests pulp-glue/tests -m live -n 8
70+
71+
# Run unit tests only (no server required)
72+
[group('test')]
73+
unittest:
74+
uv run pytest -v tests pulp-glue/tests cookiecutter/pulp_filter_extension.py -m "not live"
75+
76+
# Run glue unit tests only
77+
[group('test')]
78+
unittest-glue:
79+
uv run pytest -v pulp-glue/tests -m "not live"
80+
81+
# Build documentation
82+
[group('docs')]
83+
docs:
84+
pulp-docs build
85+
86+
# Serve documentation with live reload
87+
[group('docs')]
88+
servedocs:
89+
pulp-docs serve -w CHANGES.md -w pulp-glue/pulp_glue -w pulp_cli/generic.py
90+
91+
# Extract translatable strings into .pot files
92+
[group('i18n')]
93+
extract-messages:
94+
#!/usr/bin/env bash
95+
set -euxo pipefail
96+
for base in pulp-glue/pulp_glue pulpcore/cli; do
97+
for dir in "$base"/*/; do
98+
plugin=$(basename "$dir")
99+
xgettext -d "$plugin" -o "$dir/locale/messages.pot" "$dir"/*.py
100+
sed -i 's/charset=CHARSET/charset=UTF-8/g' "$dir/locale/messages.pot"
101+
done
102+
done
103+
104+
# Compile .po files into .mo files
105+
[group('i18n')]
106+
compile-messages:
107+
#!/usr/bin/env bash
108+
set -euxo pipefail
109+
for base in pulp-glue/pulp_glue pulpcore/cli; do
110+
for dir in "$base"/*/; do
111+
plugin=$(basename "$dir")
112+
for lang in {{ LANGUAGES }}; do
113+
potfile="$dir/locale/messages.pot"
114+
pofile="$dir/locale/$lang/LC_MESSAGES/messages.po"
115+
mofile="$dir/locale/$lang/LC_MESSAGES/messages.mo"
116+
mkdir -p "$(dirname "$pofile")"
117+
if [ -f "$pofile" ]; then
118+
msgmerge --update "$pofile" "$potfile"
119+
else
120+
cp "$potfile" "$pofile"
121+
fi
122+
msgfmt -o "$mofile" "$pofile"
123+
done
124+
done
125+
done

0 commit comments

Comments
 (0)