-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathrun_tests
executable file
·128 lines (113 loc) · 2.92 KB
/
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
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#!/bin/bash
set -e
ME="${BASH_SOURCE[0]}"
mydir=$(cd $(dirname $ME) && pwd)
cd $mydir
container="robkinyon/dbix-class-sims-test"
# Broken: 5.12
all_versions="5.10 5.14 5.16 5.18 5.20 5.22 5.24 5.26"
export MSYS_NO_PATHCONV=1
files_dirs_to_map=(
lib t
)
volumes=()
for item in ${files_dirs_to_map[@]}; do
volumes+=(-v $(pwd)/$item:/app/$item)
done
if [[ "$1" == "pull" ]]; then
shift
versions=${@:-"${all_versions}"}
for version in ${versions}; do
docker pull perl:${version}
done
elif [[ "$1" == "build" ]]; then
shift
mkdir -p build_log
versions=${@:-"${all_versions}"}
if which dos2unix &>/dev/null; then
dos2unix devops/within_carton
fi
for version in ${versions}; do
echo "Running build for perl-${version}"
set +e
(
cat Dockerfile.test | sed "s/{{version}}/${version}/" \
> Dockerfile.${version}
docker build -t ${container}:${version} -f Dockerfile.${version} .
rm Dockerfile.${version}
)&>build_log/${version}.log
set -e
done
elif [[ "$1" == "shell" ]]; then
shift
versions=${@:-"${all_versions}"}
for version in ${versions}; do
echo "Launch shell in perl-${version}"
MSYS_NO_PATHCONV=1 \
docker run \
-it --rm \
-e SIMS_DEBUG \
"${volumes[@]}" \
${container}:${version} bash
done
elif [[ "$1" == "test" ]]; then
shift
versions=${@:-"${all_versions}"}
for version in ${versions}; do
echo "Running tests against perl-${version} (should take under 1min)"
MSYS_NO_PATHCONV=1 \
docker run \
-it --rm \
-e SIMS_DEBUG \
"${volumes[@]}" \
${container}:${version} ${TESTS_TO_RUN:-"t"}
done
elif [[ "$1" == "cover" ]]; then
shift
versions=${@:-"${all_versions}"}
for version in ${versions}; do
echo "Running test coverage against perl-${version} (takes up to 10min)"
rm -rf cover_db cover_db_${version}
mkdir cover_db
MSYS_NO_PATHCONV=1 \
docker run \
-it --rm \
"${volumes[@]}" \
-v "$(pwd)/cover_db:/app/cover_db" \
${container}:${version} \
cover
mv cover_db cover_db_${version}
done
elif [[ "$1" == "release" ]]; then
shift
if [[ ! -f ~/.pause ]]; then
>&2 echo "No ~/.pause file found."
exit 1
fi
# Because of an interaction between Docker-toolbox and Git-bash, we have to
# copy the .pause here out of $HOME.
cp ~/.pause .
tag=5.26
if [[ -z $(docker images -q ${container}:${tag}) ]]; then
$ME build ${tag}
fi
files_dirs_to_map=(
lib t
Changes LICENSE
Makefile.PL inc
MANIFEST MANIFEST.SKIP
)
volumes=(-v $(pwd)/.pause:/root/.pause)
for item in ${files_dirs_to_map[@]}; do
volumes+=(-v $(pwd)/$item:/app/$item)
done
docker run \
--rm \
"${volumes[@]}" \
--entrypoint bash \
${container}:${tag} \
-c "carton exec perl -I. Makefile.PL && make dist && cpan-upload *.tar.gz"
else
>&2 echo "${ME}: <pull | build | test | release> [version, ...]"
exit 1
fi