-
Notifications
You must be signed in to change notification settings - Fork 101
/
test.sh
executable file
·133 lines (110 loc) · 2.78 KB
/
test.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
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
129
130
131
132
133
#!/bin/sh
while [ $# -gt 0 ]; do
case "$1" in
--wp)
shift
WP_VERSION="$1"
;;
--multisite)
shift
WP_MULTISITE="$1"
;;
--php)
shift
PHP_VERSION="$1"
;;
--php-options)
shift
PHP_OPTIONS="$1"
;;
--phpunit)
shift
PHPUNIT_VERSION="$1"
;;
--network)
shift
NETWORK_NAME_OVERRIDE="$1"
;;
--dbhost)
shift
MYSQL_HOST_OVERRIDE="$1"
;;
--docker-options)
shift
DOCKER_OPTIONS="$1"
;;
*)
ARGS="${ARGS} $1"
;;
esac
shift
done
: "${WP_VERSION:=latest}"
: "${WP_MULTISITE:=0}"
: "${PHP_VERSION:=""}"
: "${PHP_OPTIONS:=""}"
: "${PHPUNIT_VERSION:=""}"
: "${DOCKER_OPTIONS:=""}"
PHP_OPTIONS="-d apc.enable_cli=1 ${PHP_OPTIONS}"
export WP_VERSION
export WP_MULTISITE
export PHP_VERSION
export PHP_OPTIONS
export PHPUNIT_VERSION
echo "--------------"
echo "Will test with WP_VERSION=${WP_VERSION} and WP_MULTISITE=${WP_MULTISITE}"
echo "--------------"
echo
UUID=$(date +%s000)
if [ -z "${NETWORK_NAME_OVERRIDE}" ]; then
NETWORK_NAME="tests-${UUID}"
docker network create "${NETWORK_NAME}"
else
NETWORK_NAME="${NETWORK_NAME_OVERRIDE}"
fi
export MYSQL_USER=wordpress
export MYSQL_PASSWORD=wordpress
export MYSQL_DATABASE=wordpress_test
db=""
if [ -z "${MYSQL_HOST_OVERRIDE}" ]; then
MYSQL_HOST="db-${UUID}"
db=$(docker run --rm --network "${NETWORK_NAME}" --name "${MYSQL_HOST}" -e MYSQL_ROOT_PASSWORD="wordpress" -e MYSQL_INITDB_SKIP_TZINFO=1 -e MYSQL_USER -e MYSQL_PASSWORD -e MYSQL_DATABASE -d "mysql:8")
else
MYSQL_HOST="${MYSQL_HOST_OVERRIDE}"
fi
export MYSQL_HOST
cleanup() {
if [ -n "${db}" ]; then
docker rm -f "${db}"
fi
if [ -z "${NETWORK_NAME_OVERRIDE}" ]; then
docker network rm "${NETWORK_NAME}"
fi
}
trap cleanup EXIT
if [ -z "${CI}" ]; then
interactive="-it"
else
interactive=""
fi
# shellcheck disable=SC2086,SC2248,SC2312 # ARGS and DOCKER_OPTIONS must not be quoted
docker run \
${interactive} \
--rm \
--network "${NETWORK_NAME}" \
-e WP_VERSION \
-e WP_MULTISITE \
-e PHP_VERSION \
-e PHP_OPTIONS \
-e PHPUNIT_VERSION \
-e MYSQL_USER \
-e MYSQL_PASSWORD \
-e MYSQL_DB="${MYSQL_DATABASE}" \
-e MYSQL_HOST \
-e DISABLE_XDEBUG=1 \
-e WPVIP_PARSELY_INTEGRATION_TEST_MODE="${WPVIP_PARSELY_INTEGRATION_TEST_MODE}" \
-e WPVIP_PARSELY_INTEGRATION_PLUGIN_VERSION="${WPVIP_PARSELY_INTEGRATION_PLUGIN_VERSION}" \
${DOCKER_OPTIONS} \
-v "$(pwd):/home/circleci/project" \
ghcr.io/automattic/vip-container-images/wp-test-runner:latest \
${ARGS}