-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_in_docker.sh
executable file
·78 lines (52 loc) · 1.43 KB
/
test_in_docker.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
#!/bin/bash
Usage() {
cat <<EOF
Usage: ${0} PYTHON_VERSION
Run the test suite inside a Docker container. Note that on a Linux
system, Docker requires one of the following:
* Running the post-install instructions to enable rootless Docker usage
* Using the sudo command before any Docker commands
PYTHON_VERSION
This is any version listed in pyproject.toml
Who's this for?
Anyone in one or more of these categories:
* Likes reproducibility and containers
* Lacks direct access to a supported Python version
* Wants to run tests in Docker
EOF
}
error() {
cat <<< "ERROR: $*" 1>&2
}
if [[ "$1" == '--help' ]]; then
Usage
exit 0
elif [[ "$1" =~ ^3\.(8|9|10|11|12) ]]; then
PYTHON_VERSION="$1"
else
error "Expected a PYTHON_VERSION or --help"
exit 1
fi
# Command for building the image
docker build\
-f tests.Dockerfile\
--build-arg="PYTHON_VERSION=${PYTHON_VERSION}"\
-t "fontknife:${PYTHON_VERSION}"\
.
BUILD_RESULT=$?
if [ $BUILD_RESULT -ne 0 ]; then
error "Build failed!"
exit $BUILD_RESULT
fi
cat <<EOF
===== Build success! ======
Tests will now run in interactive terminal mode.
Press Ctrl-C now to interrupt them. Afterwards, you can
run bash inside the container by running the following:
docker run -i -t fontknife bash
To run an interactive Python interpreter inside the container
directly, run the following:
docker run -i -t fontknife python
===== Running Tests =======
EOF
docker run -i -t fontknife