-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-test.sh
More file actions
executable file
·70 lines (60 loc) · 2.23 KB
/
Copy pathdocker-test.sh
File metadata and controls
executable file
·70 lines (60 loc) · 2.23 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
#!/usr/bin/env bash
# docker-test.sh — build and run the metbit test container for one or all Python versions.
#
# Usage:
# ./docker-test.sh # test all versions (3.10 → 3.13)
# ./docker-test.sh 3.11 # single version
# ./docker-test.sh 3.12 -k pca # filter tests
# ./docker-test.sh all # explicitly test all versions
# KEEP=1 ./docker-test.sh 3.12 # keep container after run
set -euo pipefail
ALL_VERSIONS=("3.10" "3.11" "3.12" "3.13")
run_version() {
local PY="$1"
shift
local IMAGE="metbit-test-py${PY//.}"
echo ""
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo " Python ${PY} → ${IMAGE}"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "--> Building..."
docker build \
--build-arg PYTHON_VERSION="${PY}" \
-f Dockerfile.test \
-t "${IMAGE}" \
. \
--quiet
local DOCKER_OPTS="--rm"
if [[ "${KEEP:-0}" == "1" ]]; then
DOCKER_OPTS=""
echo " (container kept — find it with 'docker ps -a')"
fi
echo "--> Running tests..."
if docker run ${DOCKER_OPTS} "${IMAGE}" \
pytest -m "not slow and not perf" --tb=short -q "$@"; then
echo "✓ Python ${PY} PASSED"
return 0
else
echo "✗ Python ${PY} FAILED"
return 1
fi
}
# Determine what to run
ARG="${1:-all}"
shift || true
if [[ "$ARG" == "all" ]]; then
FAILED=()
for PY in "${ALL_VERSIONS[@]}"; do
run_version "$PY" "$@" || FAILED+=("$PY")
done
echo ""
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
if [[ ${#FAILED[@]} -eq 0 ]]; then
echo " All versions PASSED: ${ALL_VERSIONS[*]}"
else
echo " FAILED versions: ${FAILED[*]}"
exit 1
fi
else
run_version "$ARG" "$@"
fi