-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdocker-run-tests
executable file
·40 lines (34 loc) · 1.54 KB
/
docker-run-tests
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
#!/bin/bash
# This script is used to run tox in the same docker container and in the same manner that our CI
# will run tox. If tox is passing locally, but CI is failing, use this script to troubleshoot.
set -e
if [ -z "${CIRCLECI}" ]; then
# When testing locally, don't actually run docker mapped to the real source directory. Since
# Docker runs as root, the file permissions get jacked up and you have to use sudo to fix it.
# Instead, git clone the source to a temporary directory and link the docker volume to that.
# This also simulates what CircleCI does and will reveal testing errors caused by files
# that exist locally but have not been checked into git.
local_src_dpath="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
src_dname=$(basename "$local_src_dpath")
random_st="$(env LC_CTYPE=C tr -dc 'a-zA-Z0-9' < /dev/urandom \
| fold -w 8 \
| head -n 1)"
tmp_src_dpath="/tmp/docker-$src_dname-$random_st"
SRC_DPATH=$tmp_src_dpath
ARTIFACTS_DPATH="$tmp_src_dpath/.ci/artifacts"
TEST_REPORTS_DPATH="$tmp_src_dpath/.ci/test-reports"
set -x
git clone "$local_src_dpath"/ "$tmp_src_dpath"
else
SRC_DPATH="/home/ubuntu/$CIRCLE_PROJECT_REPONAME"
ARTIFACTS_DPATH=$CIRCLE_ARTIFACTS
TEST_REPORTS_DPATH=$CIRCLE_TEST_REPORTS
fi
set -x
docker run \
-v "$SRC_DPATH":/opt/src \
-v "$ARTIFACTS_DPATH":/opt/src/.ci/artifacts \
-v "$TEST_REPORTS_DPATH":/opt/src/.ci/test-reports \
level12/python-test-multi
ls "$ARTIFACTS_DPATH"
ls "$TEST_REPORTS_DPATH"