forked from graingert/python-clamd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.sh
executable file
·72 lines (57 loc) · 1.68 KB
/
test.sh
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
#!/usr/bin/env bash
set -euo pipefail
versions=(
"3.8"
"3.9"
"3.10"
"3.11"
"3.12"
)
prereleases=(
"3.13"
)
print_status() {
echo -en "\n➡️ $1\n\n"
}
if ! command -v uv > /dev/null; then
echo "Error: 'uv' is not installed or not in the PATH."
echo "To install it, run:"
echo " $ curl -LsSf https://astral.sh/uv/install.sh | sh"
exit 1
fi
curdir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
markers=""
if [[ " $@ " =~ " --fast " ]]; then
markers="not slow"
fi
latest="${versions[${#versions[@]}-1]}"
if [[ " $@ " =~ " --latest " ]]; then
versions=("3.12")
prereleases=()
elif [[ " $@ " =~ " --pre " ]]; then
versions=()
prereleases=("3.13")
fi
combined=("${versions[@]}" "${prereleases[@]}")
for version in "${combined[@]}"; do
print_status "Running \`pytest\` using Python $version..."
env \
UV_PROJECT_ENVIRONMENT="$curdir/.venv/test-runner/$version/" \
VIRTUAL_ENV="$curdir/.venv/test-runner/$version/" \
uv run --frozen --python "$version" -- \
pytest -m "$markers" \
--junitxml=junit.xml \
--override-ini=junit_family=legacy \
--cov \
--cov-append \
--cov-report xml:coverage.xml \
--cov-report html
done
export UV_PROJECT_ENVIRONMENT="$curdir/.venv/test-runner/$latest/" \
export VIRTUAL_ENV="$curdir/.venv/test-runner/$latest/" \
print_status "Running \`ruff check\` using Python $latest..."
uv run --frozen --python "$latest" -- ruff check
print_status "Running \`ruff format --check\` using Python $latest..."
uv run --frozen --python "$latest" -- ruff format --check
print_status "Running \`mypy\` using Python $latest..."
uv run --frozen --python "$latest" -- mypy