-
Notifications
You must be signed in to change notification settings - Fork 301
Expand file tree
/
Copy pathjustfile
More file actions
197 lines (184 loc) · 7.36 KB
/
Copy pathjustfile
File metadata and controls
197 lines (184 loc) · 7.36 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
# django-countries justfile - Modern development commands using uv
# Default recipe - show available commands
default:
@just --list
# Run tests - smart command that handles multiple scenarios
# Usage:
# just test -> run all test matrices + coverage
# just test quick -> quick test with current Python (no coverage)
# just test [latest|previous|legacy|latest-pyuca|latest-noi18n] -> run specific env
# just test [latest|previous|legacy|latest-pyuca|latest-noi18n] [3.10-3.14] -> run specific env + python
test *ARGS='':
#!/usr/bin/env bash
set -euo pipefail
# Pass ARGS from just to bash script
ARGS=({{ ARGS }})
if [ ${#ARGS[@]} -eq 0 ]; then
# No args: run all test matrices + coverage
echo "Running all test environments..."
just _test-matrix
echo ""
echo "Generating coverage report..."
just _coverage-report
elif [ ${#ARGS[@]} -eq 1 ]; then
# One arg: could be "quick" or environment name
ENV="${ARGS[0]}"
if [ "$ENV" = "quick" ]; then
echo "Running quick test with current Python..."
uv run --group test pytest
else
case "$ENV" in
legacy) PYTHON="3.10" ;;
previous) PYTHON="3.13" ;;
latest|latest-pyuca|latest-noi18n) PYTHON="3.14" ;;
*) echo "Unknown environment: $ENV"; exit 1 ;;
esac
just _test-env "$ENV" "$PYTHON"
fi
elif [ ${#ARGS[@]} -eq 2 ]; then
# Two args: environment and python version
just _test-env "${ARGS[0]}" "${ARGS[1]}"
else
echo "Usage: just test [ENV [PYTHON]]"
exit 1
fi
# Run all test environments (internal)
_test-matrix:
@echo "Cleaning old coverage files..."
@rm -rf .coverage* htmlcov
@just _test-env legacy 3.10
@just _test-env previous 3.13
@just _test-env latest 3.14
@just _test-env latest-pyuca 3.14
@just _test-env latest-noi18n 3.14
# Run a specific test environment (internal)
_test-env ENV PYTHON:
@echo ""
@echo "========================================="
@echo "Testing: Python {{ PYTHON }} - {{ ENV }}"
@echo "========================================="
@case "{{ ENV }}" in \
legacy) \
uv run --python {{ PYTHON }} \
--with "Django==4.2.*" \
--with "djangorestframework==3.14.*" \
--with "pyuca" \
--group test \
coverage run -m pytest \
;; \
previous) \
uv run --python {{ PYTHON }} \
--with "Django==5.2.*" \
--with "djangorestframework==3.16.*" \
--group test \
coverage run -m pytest \
;; \
latest) \
uv run --python {{ PYTHON }} \
--with "Django==6.0.*" \
--with "djangorestframework==3.17.*" \
--with "graphene-django==3.0.*" \
--group test \
coverage run -m pytest \
;; \
latest-pyuca) \
uv run --python {{ PYTHON }} \
--with "Django==6.0.*" \
--with "djangorestframework==3.17.*" \
--with "graphene-django==3.0.*" \
--with "pyuca" \
--group test \
coverage run -m pytest \
;; \
latest-noi18n) \
DJANGO_SETTINGS_MODULE=django_countries.tests.settings_noi18n \
uv run --python {{ PYTHON }} \
--with "Django==6.0.*" \
--with "djangorestframework==3.17.*" \
--with "graphene-django==3.0.*" \
--group test \
coverage run -m pytest \
;; \
*) \
echo "Unknown environment: {{ ENV }}"; exit 1 \
;; \
esac
# Generate coverage report (internal)
_coverage-report:
@uv run --group test coverage combine .coverage* 2>/dev/null || true
@echo ""
@echo "Test coverage (must be 100%):"
@uv run --group test coverage report --include="django_countries/tests/*" --fail-under=100 -m
@echo ""
@echo "Source coverage (must be 90%+):"
@uv run --group test coverage report --omit="django_countries/tests/*" --fail-under=90 -m
@uv run --group test coverage html
@echo ""
@echo "Coverage report saved to htmlcov/index.html"
# Run all checks (format, lint, type, docs, test)
check:
@echo "Running all checks..."
@echo ""
@echo "→ Checking code formatting..."
uv run ruff check --select I django_countries
uv run ruff format --check django_countries
@echo "✓ Formatting OK"
@echo ""
@echo "→ Running linters..."
uv run ruff check django_countries
uv run bandit -r django_countries -x tests
@echo "✓ Linting OK"
@echo ""
@echo "→ Type checking..."
uv run mypy django_countries
@echo "✓ Type checking OK"
@echo ""
@echo "→ Validating documentation..."
uv run --group docs mkdocs build --strict
@echo "✓ Documentation OK"
@echo ""
@echo "→ Running tests..."
just test
@echo ""
@echo "======================================"
@echo "✓ All checks passed!"
@echo "======================================"
# Serve documentation locally at http://127.0.0.1:8080
docs:
uv run --group docs mkdocs serve --livereload --dev-addr 127.0.0.1:8080
# Build and deploy documentation to GitHub Pages
deploy_docs:
@echo "Building documentation..."
uv run --group docs mkdocs build --strict
@echo "✓ Documentation builds successfully"
@echo ""
@echo "Deploying to GitHub Pages..."
uv run --group docs mkdocs gh-deploy --force
@echo "✓ Documentation deployed"
# Update English translation source file with new translatable strings
tx-makemessages:
@echo "Updating English translation source file..."
@cd django_countries && DJANGO_SETTINGS_MODULE=django_countries.tests.settings \
uv run --group dev django-admin makemessages --locale=en --no-obsolete
@echo "✓ English source file updated (django_countries/locale/en/LC_MESSAGES/django.po)"
@echo ""
@echo "Next steps:"
@echo " 1. Review changes: git diff django_countries/locale/en/"
@echo " 2. Commit changes: git add django_countries/locale/en/ && git commit -m 'Update English translation source file'"
@echo " 3. Push source to Transifex: tx push -s"
@echo " 4. Wait for translators to update translations on Transifex"
@echo " 5. Pull updated translations: just tx-pull"
# Pull translations from Transifex and compile message catalogs
tx-pull:
@echo "Pulling translations from Transifex..."
tx pull -a --minimum-perc=60 --use-git-timestamps
@echo "Compiling message catalogs (excluding English source)..."
@cd django_countries && uv run --group dev django-admin compilemessages --exclude=en
@echo "✓ Translations updated and compiled"
# Deploy a new release to PyPI
# Usage:
# just deploy [patch|minor|major] - Specify bump type
# just deploy - Interactive prompt for bump type
# just deploy [BUMP] --allow-dirty - Allow uncommitted changes (not recommended)
deploy *ARGS:
uv run --group dev python scripts/deploy.py {{ ARGS }}