-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add PHPUnit and WP PHPUnit dependencies; refactor CI workflow
- Loading branch information
1 parent
cfa791c
commit e6d56b2
Showing
6 changed files
with
600 additions
and
302 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,76 +1,129 @@ | ||
#!/bin/sh | ||
|
||
set -x | ||
|
||
ARGS="" | ||
while [ $# -gt 0 ]; do | ||
case "$1" in | ||
--wp) | ||
shift | ||
WORDPRESS_VERSION="$1" | ||
;; | ||
|
||
--multisite) | ||
shift | ||
WP_MULTISITE="$1" | ||
;; | ||
|
||
*) | ||
ARGS="${ARGS} $1" | ||
;; | ||
esac | ||
|
||
shift | ||
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 | ||
|
||
: "${WORDPRESS_VERSION:=latest}" | ||
: "${WP_VERSION:=latest}" | ||
: "${WP_MULTISITE:=0}" | ||
: "${PHP_VERSION:=""}" | ||
: "${PHP_OPTIONS:=""}" | ||
: "${PHPUNIT_VERSION:=""}" | ||
: "${DOCKER_OPTIONS:=""}" | ||
|
||
export WORDPRESS_VERSION | ||
export WP_VERSION | ||
export WP_MULTISITE | ||
|
||
if [ $# -ge 2 ]; then | ||
shift 2 | ||
elif [ $# -ge 1 ]; then | ||
shift 1 | ||
fi | ||
export PHP_VERSION | ||
export PHP_OPTIONS | ||
export PHPUNIT_VERSION | ||
|
||
echo "--------------" | ||
echo "Will test with WORDPRESS_VERSION=${WORDPRESS_VERSION} and WP_MULTISITE=${WP_MULTISITE}" | ||
echo "Will test with WP_VERSION=${WP_VERSION} and WP_MULTISITE=${WP_MULTISITE}" | ||
echo "--------------" | ||
echo | ||
|
||
MARIADB_VERSION="10.3" | ||
UUID=$(date +%s000) | ||
NETWORK_NAME="tests-${UUID}" | ||
|
||
docker network create "${NETWORK_NAME}" | ||
if [ -z "${NETWORK_NAME_OVERRIDE}" ]; then | ||
NETWORK_NAME="tests-${UUID}" | ||
docker network create "${NETWORK_NAME}" | ||
else | ||
NETWORK_NAME="${NETWORK_NAME_OVERRIDE}" | ||
fi | ||
|
||
export MYSQL_HOST="db-${UUID}" | ||
export MYSQL_USER=wordpress | ||
export MYSQL_PASSWORD=wordpress | ||
export MYSQL_DATABASE=wordpress_test | ||
export MYSQL_ROOT_PASSWORD=wordpress | ||
export MYSQL_INITDB_SKIP_TZINFO=1 | ||
|
||
db=$(docker run --rm --network "${NETWORK_NAME}" --name "${MYSQL_HOST}" -e MYSQL_ROOT_PASSWORD -e MARIADB_INITDB_SKIP_TZINFO -e MYSQL_USER -e MYSQL_PASSWORD -e MYSQL_DATABASE -d "mariadb:${MARIADB_VERSION}") | ||
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() { | ||
docker rm -f "${db}" | ||
docker network rm "${NETWORK_NAME}" | ||
if [ -n "${db}" ]; then | ||
docker rm -f "${db}" | ||
fi | ||
|
||
if [ -z "${NETWORK_NAME_OVERRIDE}" ]; then | ||
docker network rm "${NETWORK_NAME}" | ||
fi | ||
} | ||
|
||
trap cleanup EXIT | ||
|
||
# shellcheck disable=SC2086 # ARGS must not be quoted | ||
if [ -z "${CI}" ]; then | ||
interactive="-it" | ||
else | ||
interactive="" | ||
fi | ||
|
||
# shellcheck disable=SC2086,SC2248,SC2312 # ARGS and DOCKER_OPTIONS must not be quoted | ||
docker run \ | ||
--rm \ | ||
--network "${NETWORK_NAME}" \ | ||
-e WORDPRESS_VERSION \ | ||
-e WP_MULTISITE \ | ||
-e MYSQL_USER \ | ||
-e MYSQL_PASSWORD \ | ||
-e MYSQL_DATABASE \ | ||
-e MYSQL_HOST \ | ||
-v "$(pwd):/app" \ | ||
wildwildangel/wp-test-runner "/usr/local/bin/runner" ${ARGS} | ||
${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 \ | ||
${DOCKER_OPTIONS} \ | ||
-v "$(pwd):/home/circleci/project" \ | ||
ghcr.io/automattic/vip-container-images/wp-test-runner:latest \ | ||
${ARGS} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.