-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
105 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"id": "setup-wptl", | ||
"name": "WordPress with Test Library", | ||
"description": "Sets up WordPress and WordPress Test Library", | ||
"version": "0.0.1", | ||
"options": { | ||
"versions": { | ||
"type": "string", | ||
"default": "", | ||
"description": "Versions to install" | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#!/bin/sh | ||
|
||
set -e | ||
|
||
download_wp() { | ||
VERSION="$1" | ||
if [ "${VERSION}" = "nightly" ] || [ "${VERSION}" = "trunk" ]; then | ||
TESTS_TAG="trunk" | ||
elif [ "${VERSION}" = "latest" ]; then | ||
VERSIONS=$(wget https://api.wordpress.org/core/version-check/1.7/ -q -O - ) | ||
LATEST=$(echo "${VERSIONS}" | jq -r '.offers | map(select( .response == "upgrade")) | .[0].version') | ||
if [ -z "${LATEST}" ]; then | ||
echo "Unable to detect the latest WP version" | ||
exit 1 | ||
fi | ||
|
||
download_wp "${LATEST}" | ||
ln -sf "/usr/share/wptl/wordpress-${LATEST}" /usr/share/wptl/wordpress-latest | ||
ln -sf "/usr/share/wptl/wordpress-tests-lib-${LATEST}" /usr/share/wptl/wordpress-tests-lib-latest | ||
return | ||
elif [ "${VERSION%.x}" != "${VERSION}" ]; then | ||
VER="${VERSION}" | ||
LATEST=$(wget https://api.wordpress.org/core/version-check/1.7/ -q -O - | jq --arg version "${VERSION%.x}" -r '.offers | map(select(.version | startswith($version))) | sort_by(.version) | reverse | .[0].version') | ||
download_wp "${LATEST}" | ||
ln -sf "/usr/share/wptl/wordpress-${LATEST}" "/usr/share/wptl/wordpress-${VER}" | ||
ln -sf "/usr/share/wptl/wordpress-tests-lib-${LATEST}" "/usr/share/wptl/wordpress-tests-lib-${VER}" | ||
return | ||
else | ||
TESTS_TAG="tags/${VERSION}" | ||
fi | ||
|
||
if [ ! -d "/usr/share/wptl/wordpress-${VERSION}" ]; then | ||
if [ "${VERSION}" = "nightly" ]; then | ||
cd /wordpress | ||
wget -q https://wordpress.org/nightly-builds/wordpress-latest.zip | ||
unzip -q wordpress-latest.zip | ||
mv /usr/share/wptl/wordpress /usr/share/wptl/wordpress-nightly | ||
rm -f wordpress-latest.zip | ||
cd - | ||
else | ||
mkdir -p "/usr/share/wptl/wordpress-${VERSION}" | ||
wget -q "https://wordpress.org/wordpress-${VERSION}.tar.gz" -O - | tar --strip-components=1 -zxm -f - -C "/usr/share/wptl/wordpress-${VERSION}" | ||
fi | ||
wget -q https://raw.github.com/markoheijnen/wp-mysqli/master/db.php -O "/usr/share/wptl/wordpress-${VERSION}/wp-content/db.php" | ||
else | ||
echo "Skipping WordPress download" | ||
fi | ||
|
||
if [ ! -d "/usr/share/wptl/wordpress-tests-lib-${VERSION}" ]; then | ||
mkdir -p "/usr/share/wptl/wordpress-tests-lib-${VERSION}" | ||
svn co --quiet --ignore-externals "https://develop.svn.wordpress.org/${TESTS_TAG}/tests/phpunit/includes/" "/usr/share/wptl/wordpress-tests-lib-${VERSION}/includes" | ||
svn co --quiet --ignore-externals "https://develop.svn.wordpress.org/${TESTS_TAG}/tests/phpunit/data/" "/usr/share/wptl/wordpress-tests-lib-${VERSION}/data" | ||
rm -f "/usr/share/wptl/wordpress-tests-lib-${VERSION}/wp-tests-config-sample.php" | ||
wget -q "https://develop.svn.wordpress.org/${TESTS_TAG}/wp-tests-config-sample.php" -O "/usr/share/wptl/wordpress-tests-lib-${VERSION}/wp-tests-config-sample.php" | ||
else | ||
echo "Skipping WordPress test library download" | ||
fi | ||
} | ||
|
||
download_wp "${1:-latest}" |
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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/bin/sh | ||
|
||
set -e | ||
|
||
PATH=/usr/local/bin:/usr/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin | ||
|
||
if [ "$(id -u || true)" -ne 0 ]; then | ||
echo 'Script must be run as root. Use sudo, su, or add "USER root" to your Dockerfile before running this script.' | ||
exit 1 | ||
fi | ||
|
||
echo '(*) Setting up WordPress and Test Library...' | ||
|
||
if [ -z "${_REMOTE_USER}" ] || [ "${_REMOTE_USER}" = "root" ]; then | ||
WEB_USER="${CONTAINER_USER:-www-data}" | ||
else | ||
WEB_USER="${_REMOTE_USER}" | ||
fi | ||
|
||
install -d -m 0755 -o "${WEB_USER}" -g "${WEB_USER}" /usr/share/wptl | ||
install -m 0755 -o root -g root install-wptl.sh /usr/local/bin/install-wptl | ||
|
||
if [ -z "${VERSIONS}" ]; then | ||
VERSIONS="$(wget https://api.wordpress.org/core/version-check/1.7/ -q -O - | jq -r '[.offers[].version] | unique | map(select( . >= "5.5")) | .[]') nightly" | ||
fi | ||
|
||
for version in ${VERSIONS} latest; do | ||
install-wptl "${version}" & | ||
done | ||
wait | ||
|
||
echo 'Done!' |