-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmatrix_tests.sh
executable file
·98 lines (72 loc) · 1.74 KB
/
matrix_tests.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
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
#!/bin/bash
set -eu -o pipefail
VERSIONS=("3.10.16" "3.11.11" "3.12.8" "3.13.1")
install_version() {
version=$1;
pyenv install $version;
}
use_version() {
version=$1;
retried=$2;
install_successful=true;
DEACTIVATE_RESPONSE=$( { deactivate || true; } 2>&1 );
PYENV_LOCAL_RESPONSE=$( { pyenv local $version > outfile; rm outfile; } 2>&1 );
if [ "$PYENV_LOCAL_RESPONSE" = "pyenv: version \`$version' not installed" ]; then
install_successful=false;
if [ "$retried" = "false" ]; then
echo "$version is not installed, installing now";
install_version $version;
fi
fi
if [ "$retried" = "true" ] && [ ! $install_successful ]; then
echo "Failed to install $version";
exit 1;
fi
echo "Using version $version";
pyenv local $version;
}
setup_environment() {
rm -rf .venv;
pip install --upgrade pip -q;
pip install --upgrade uv -q;
uv sync --frozen -q;
}
run_linters() {
uv run flake8;
uv run ruff check;
uv run ruff format --diff;
}
run_tests() {
uv run pytest;
}
get_coverage() {
uv run coverage run;
uv run coverage report;
}
main() {
for VERSION in "${VERSIONS[@]}"; do
echo "========================="
use_version $VERSION false;
echo "Setting up environment for $VERSION";
setup_environment;
echo "Running linters for $VERSION";
run_linters;
echo "Running pytest for $VERSION";
run_tests;
done
echo "========================="
echo "Getting coverage statistics for $VERSION";
get_coverage;
}
cover_current_only() {
VERSION=$(python -V | awk '{print $2}')
echo "Running linters for $VERSION";
run_linters;
echo "Getting coverage statistics for $VERSION";
get_coverage;
}
if [ "$*" = "-a" ]; then
main;
else
cover_current_only;
fi