-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjustfile
More file actions
133 lines (123 loc) · 4.28 KB
/
justfile
File metadata and controls
133 lines (123 loc) · 4.28 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
# graphql-sqlcommenter 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 [legacy|previous|latest] -> run specific env
# just test [legacy|previous|latest] [3.9-3.13] -> 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..."
PYTHONPATH=. uv run --group test pytest
else
case "$ENV" in
legacy) PYTHON="3.9" ;;
previous) PYTHON="3.11" ;;
latest) PYTHON="3.13" ;;
*) 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.9
@just _test-env previous 3.11
@just _test-env latest 3.13
# Run a specific test environment (internal)
_test-env ENV PYTHON:
@echo ""
@echo "========================================="
@echo "Testing: Python {{ PYTHON }} - {{ ENV }}"
@echo "========================================="
@case "{{ ENV }}" in \
legacy) \
PYTHONPATH=. uv run --python {{ PYTHON }} \
--with "Django==3.2.*" \
--group test \
coverage run -m pytest \
;; \
previous) \
PYTHONPATH=. uv run --python {{ PYTHON }} \
--with "Django==4.2.*" \
--group test \
coverage run -m pytest \
;; \
latest) \
PYTHONPATH=. uv run --python {{ PYTHON }} \
--with "Django==5.1.*" \
--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 "Source coverage (must be 90%+):"
@uv run --group test coverage report --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 graphql_sqlcommenter
uv run ruff format --check graphql_sqlcommenter
@echo "✓ Formatting OK"
@echo ""
@echo "→ Running linters..."
uv run ruff check graphql_sqlcommenter
uv run bandit -r graphql_sqlcommenter -x tests
@echo "✓ Linting OK"
@echo ""
@echo "→ Type checking..."
uv run mypy graphql_sqlcommenter
@echo "✓ Type checking OK"
@echo ""
@echo "→ Validating documentation..."
uv run --group docs zensical 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:8800
docs:
uv run --group docs zensical serve --dev-addr 127.0.0.1:8800
# Format code
format:
uv run ruff format graphql_sqlcommenter