Build/Test Tools: Backport the local Docker environment to the 4.9 branch.

This commit introduces the Docker-based local WordPress development environment to the 4.9 branch and converts the Travis test jobs to utilize this environment for easier and more consistent testing.

Until existing blockers with the PHP 5.2 Docker container can be solved, the PHP 5.2 test job will remain using the Travis `precise` image.

Merges [45745,45762,45783-45784,45800,45819,45885,46320,46999,47225,47912,48121,49335,49358,49360,49362] to the 4.9 branch.
See #48301, #47767.

git-svn-id: https://develop.svn.wordpress.org/branches/4.9@49530 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Jonathan Desrosiers 2020-11-06 17:32:00 +00:00
parent 4608a20874
commit faac54e8d0
14 changed files with 687 additions and 81 deletions

59
.env Normal file
View File

@ -0,0 +1,59 @@
##
# Default configuration options for the local dev environment.
#
# All of these options can be overridden by setting them as environment variables before starting
# the environment. You will need to restart your environment when changing any of these.
#
# Below, the following substitutions can be made:
# - '{version}': any major.minor PHP version from 5.2 onwards.
# - '{phpunit_version}': any major PHPUnit version starting with 4.
##
# The site will be available at http://localhost:LOCAL_PORT
LOCAL_PORT=8889
# Where to run WordPress from. Valid options are 'src' and 'build'.
LOCAL_DIR=src
# The PHP version to use. Valid options are 'latest', and '{version}-fpm'.
LOCAL_PHP=7.2-fpm
##
# The PHPUnit version to use when running tests.
#
# Support for new PHPUnit versions is not backported to past versions, so some old WordPress branches require an older
# version to run tests.
#
# Valid versions are:
# - 'latest' for the highest version of PHPUnit supported on the highest version of PHP supported.
# - '{version}-fpm' for the highest version of PHPUnit supported on the specified version of PHP.
# - '{phpunit_version}-php-{version}-fpm' for a specific version of PHPUnit on the specified version of PHP. This format
# is only available for PHP versions 5.6 and higher.
#
# For the full list of available options, see https://hub.docker.com/r/wordpressdevelop/phpunit/tags.
#
# For full documentation on PHPUnit compatibility and WordPress versions, see
# https://make.wordpress.org/core/handbook/references/phpunit-compatibility-and-wordpress-versions/.
#
# This defaults to the value assigned to the value of LOCAL_PHP.
##
LOCAL_PHPUNIT=6-php-${LOCAL_PHP}
# Whether or not to enable XDebug.
LOCAL_PHP_XDEBUG=false
# Whether or not to enable Memcached.
LOCAL_PHP_MEMCACHED=false
# The MySQL version to use. See https://hub.docker.com/_/mysql/ for valid versions.
LOCAL_MYSQL=5.7
# The debug settings to add to `wp-config.php`.
LOCAL_WP_DEBUG=true
LOCAL_WP_DEBUG_LOG=true
LOCAL_WP_DEBUG_DISPLAY=true
LOCAL_SCRIPT_DEBUG=true
LOCAL_WP_ENVIRONMENT_TYPE=local
# The URL to use when running e2e tests.
WP_BASE_URL=http://localhost:${LOCAL_PORT}

View File

@ -1,96 +1,130 @@
sudo: false
dist: trusty
language: php
services:
- docker
cache:
apt: true
directories:
- $HOME/.npm
- vendor
- $HOME/.composer/cache
env:
global:
- WP_TRAVISCI=travis:phpunit
- LOCAL_DIR: build
- NPM_INSTALL: true
- WP_INSTALL: true
- PHP_FPM_UID: "`id -u`"
- PHP_FPM_GID: "`id -g`"
matrix:
include:
- php: 7.1
env: WP_TRAVISCI=travis:js
- php: 7.2
- php: 5.6
env: WP_TRAVIS_OBJECT_CACHE=true
services: memcached
- php: 5.2
dist: precise
- env: WP_TRAVISCI=travis:js LOCAL_PHP=7.1-fpm WP_INSTALL=false
name: "JS Tests"
- env: LOCAL_PHPUNIT=6-php-7.2-fpm WP_TRAVISCI=test:php
name: "PHPUnit Tests: PHP 7.2"
- env: LOCAL_PHP_MEMCACHED=true LOCAL_PHP=5.6-fpm LOCAL_PHPUNIT=4-php-5.6-fpm WP_TRAVISCI=test:php
name: "PHPUnit Tests: PHP 5.6 with Memcached"
- env: WP_TRAVISCI=travis:phpunit WP_INSTALL=false
php: 5.2
dist: precise
name: "PHPUnit Tests: PHP 5.2"
fast_finish: true
before_install:
- |
if [[ "$WP_TRAVISCI" == "travis:phpunit" ]]; then
- |
if [[ "$WP_TRAVISCI" == "test:php" ]]; then
travis_retry svn checkout https://plugins.svn.wordpress.org/wordpress-importer/tags/0.6.3/ tests/phpunit/data/plugins/wordpress-importer
fi
- |
if [[ "$WP_TRAVISCI" != "travis:phpunit" ]]; then
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt-get update
sudo apt-get -y -o Dpkg::Options::="--force-confnew" install docker-ce
fi
- |
sudo rm /usr/local/bin/docker-compose
curl -L https://github.com/docker/compose/releases/download/1.24.0/docker-compose-`uname -s`-`uname -m` > docker-compose
chmod +x docker-compose
sudo mv docker-compose /usr/local/bin
- |
if [[ "$WP_TRAVISCI" == "travis:phpunit" ]]; then
mysql -u root -e "CREATE DATABASE wordpress_tests;"
cp wp-tests-config-sample.php wp-tests-config.php
sed -i "s/youremptytestdbnamehere/wordpress_tests/" wp-tests-config.php
sed -i "s/yourusernamehere/root/" wp-tests-config.php
sed -i "s/yourpasswordhere//" wp-tests-config.php
svn checkout https://plugins.svn.wordpress.org/wordpress-importer/tags/0.6.3/ tests/phpunit/data/plugins/wordpress-importer
fi
- |
if [[ "$WP_TRAVIS_OBJECT_CACHE" == "true" ]]; then
cp tests/phpunit/includes/object-cache.php src/wp-content/object-cache.php
echo "extension = memcached.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
fi
travis_retry svn checkout https://plugins.svn.wordpress.org/wordpress-importer/tags/0.6.3/ tests/phpunit/data/plugins/wordpress-importer
fi
before_script:
- |
# Remove Xdebug for a huge performance increase:
if [ -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini ]; then
phpenv config-rm xdebug.ini
else
echo "xdebug.ini does not exist"
fi
- |
# Export Composer's global bin dir to PATH, but not on PHP 5.2:
if [[ ${TRAVIS_PHP_VERSION:0:3} != "5.2" ]]; then
composer config --list --global
export PATH=`composer config --list --global | grep '\[home\]' | { read a; echo "${a#* }/vendor/bin:$PATH"; }`
fi
- |
# Install the specified version of PHPUnit depending on the PHP version:
if [[ "$WP_TRAVISCI" == "travis:phpunit" ]]; then
case "$TRAVIS_PHP_VERSION" in
7.2|7.1|7.0|nightly)
echo "Using PHPUnit 6.x"
composer global require "phpunit/phpunit:^6"
;;
5.6|5.5|5.4|5.3)
echo "Using PHPUnit 4.x"
composer global require "phpunit/phpunit:^4"
;;
5.2)
# Do nothing, use default PHPUnit 3.6.x
echo "Using default PHPUnit, hopefully 3.6"
;;
*)
echo "No PHPUnit version handling for PHP version $TRAVIS_PHP_VERSION"
exit 1
;;
esac
fi
- npm --version
- node --version
- nvm install 6.9.1
- npm install -g grunt-cli
- npm install
- npm prune
- mysql --version
- phpenv versions
- php --version
- php -m
- npm --version
- node --version
- which phpunit
- phpunit --version
- curl --version
- grunt --version
- git --version
- svn --version
- locale -a
script: grunt $WP_TRAVISCI
- npm --version
- node --version
- nvm install
- |
if [[ "$WP_TRAVISCI" == "travis:phpunit" ]]; then
phpenv config-rm xdebug.ini
mysql --version
phpenv versions
php --version
php -m
fi
- |
if [[ "$NPM_INSTALL" == "true" ]]; then
npm install
fi
- |
if [[ "$WP_TRAVISCI" == "test:php" ]]; then
npm run env:start
npm run build
docker-compose run --rm mysql mysql --version
docker-compose run --rm php php --version
docker-compose run --rm php php -m
docker-compose run --rm phpunit phpunit --version
fi
- |
if [[ "$LOCAL_PHP_MEMCACHED" == "true" ]]; then
cp tests/phpunit/includes/object-cache.php build/wp-content/object-cache.php
# The memcached server needs to start after `npm run env:start`, which sets up the Docker network.
docker run --name memcached --net $(basename "$PWD")_wpdevnet -d memcached
fi
- |
if [[ "$WP_INSTALL" == "true" ]]; then
# Run the install process after memcached has started.
npm run env:install
fi
- npm --version
- node --version
- curl --version
- git --version
- svn --version
- php --version
- php -i
- locale -a
script:
- |
if [[ "$WP_TRAVISCI" == "test:php" ]]; then
npm run test:php -- --verbose -c phpunit.xml.dist &&
npm run test:php -- --verbose -c phpunit.xml.dist --group ajax &&
npm run test:php -- --verbose -c tests/phpunit/multisite.xml &&
npm run test:php -- --verbose -c tests/phpunit/multisite.xml --group ms-files &&
npm run test:php -- --verbose -c phpunit.xml.dist --group external-http &&
npm run test:php -- --verbose -c phpunit.xml.dist --group restapi-jsclient &&
# __fakegroup__ is excluded to force PHPUnit to ignore the <exclude> settings in phpunit.xml.dist.
LOCAL_PHP_XDEBUG=true npm run test:php -- -v --group xdebug --exclude-group __fakegroup__
else
npm run grunt $WP_TRAVISCI
fi
after_script:
- |
if [[ "$WP_TEST_REPORTER" == "true" ]]; then
git clone https://github.com/WordPress/phpunit-test-runner.git test-runner
docker-compose run --rm -e WPT_PREPARE_DIR=/var/www -e WPT_TEST_DIR=/var/www php php test-runner/report.php
fi
notifications:
slack:
rooms:

136
docker-compose.yml Normal file
View File

@ -0,0 +1,136 @@
version: '3.7'
services:
##
# The web server container.
##
wordpress-develop:
image: nginx:alpine
networks:
- wpdevnet
ports:
- ${LOCAL_PORT-8889}:80
environment:
LOCAL_DIR: ${LOCAL_DIR-src}
volumes:
- ./tools/local-env/default.template:/etc/nginx/conf.d/default.template
- ./:/var/www
# Load our config file, substituting environment variables into the config.
command: /bin/sh -c "envsubst '$$LOCAL_DIR' < /etc/nginx/conf.d/default.template > /etc/nginx/conf.d/default.conf && exec nginx -g 'daemon off;'"
depends_on:
- php
##
# The PHP container.
##
php:
image: wordpressdevelop/php:${LOCAL_PHP-7.2-fpm}
networks:
- wpdevnet
environment:
LOCAL_PHP_XDEBUG: ${LOCAL_PHP_XDEBUG-false}
LOCAL_PHP_MEMCACHED: ${LOCAL_PHP_MEMCACHED-false}
PHP_FPM_UID: ${PHP_FPM_UID-1000}
PHP_FPM_GID: ${PHP_FPM_GID-1000}
volumes:
- ./tools/local-env/php-config.ini:/usr/local/etc/php/conf.d/php-config.ini
- ./:/var/www
depends_on:
- mysql
##
# The MySQL container.
##
mysql:
image: mysql:${LOCAL_MYSQL-5.7}
networks:
- wpdevnet
ports:
- "3306"
environment:
MYSQL_ROOT_PASSWORD: password
volumes:
- ./tools/local-env/mysql-init.sql:/docker-entrypoint-initdb.d/mysql-init.sql
- mysql:/var/lib/mysql
# For compatibility with PHP versions that don't support the caching_sha2_password auth plugin used in MySQL 8.0.
command: --default-authentication-plugin=mysql_native_password
##
# The WP CLI container.
##
cli:
image: wordpressdevelop/cli:${LOCAL_PHP-7.2-fpm}
networks:
- wpdevnet
environment:
LOCAL_PHP_XDEBUG: ${LOCAL_PHP_XDEBUG-false}
LOCAL_PHP_MEMCACHED: ${LOCAL_PHP_MEMCACHED-false}
PHP_FPM_UID: ${PHP_FPM_UID-1000}
PHP_FPM_GID: ${PHP_FPM_GID-1000}
volumes:
- ./:/var/www
# The init directive ensures the command runs with a PID > 1, so Ctrl+C works correctly.
init: true
##
# The PHPUnit container.
##
phpunit:
image: wordpressdevelop/phpunit:${LOCAL_PHPUNIT-6-php-7.2-fpm}
networks:
- wpdevnet
environment:
LOCAL_PHP_XDEBUG: ${LOCAL_PHP_XDEBUG-false}
LOCAL_PHP_MEMCACHED: ${LOCAL_PHP_MEMCACHED-false}
LOCAL_DIR: ${LOCAL_DIR-src}
WP_MULTISITE: ${WP_MULTISITE-false}
PHP_FPM_UID: ${PHP_FPM_UID-1000}
PHP_FPM_GID: ${PHP_FPM_GID-1000}
TRAVIS_BRANCH: ${TRAVIS_BRANCH-false}
TRAVIS_PULL_REQUEST: ${TRAVIS_PULL_REQUEST-false}
GITHUB_REF: ${GITHUB_REF-false}
GITHUB_EVENT_NAME: ${GITHUB_EVENT_NAME-false}
volumes:
- ./tools/local-env/phpunit-config.ini:/usr/local/etc/php/conf.d/phpunit-config.ini
- ./:/var/www
- phpunit-uploads:/var/www/${LOCAL_DIR-src}/wp-content/uploads
# The init directive ensures the command runs with a PID > 1, so Ctrl+C works correctly.
init: true
depends_on:
- mysql
volumes:
# So that sites aren't wiped every time containers are restarted, MySQL uses a persistent volume.
mysql: {}
# Using a volume for the uploads directory improves PHPUnit performance.
phpunit-uploads: {}
networks:
# Creating our own network allows us to connect between containers using their service name.
wpdevnet:
driver: bridge

218
npm-shrinkwrap.json generated
View File

@ -1,6 +1,6 @@
{
"name": "WordPress",
"version": "4.9.0",
"version": "4.9.16",
"dependencies": {
"abbrev": {
"version": "1.1.1",
@ -947,6 +947,12 @@
"resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz",
"dev": true
},
"core-js": {
"version": "2.6.11",
"from": "core-js@>=2.5.7 <3.0.0",
"resolved": "https://registry.npmjs.org/core-js/-/core-js-2.6.11.tgz",
"dev": true
},
"core-util-is": {
"version": "1.0.2",
"from": "core-util-is@>=1.0.0 <1.1.0",
@ -1338,6 +1344,18 @@
"resolved": "https://registry.npmjs.org/domutils/-/domutils-1.5.1.tgz",
"dev": true
},
"dotenv": {
"version": "8.2.0",
"from": "dotenv@>=8.2.0 <9.0.0",
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-8.2.0.tgz",
"dev": true
},
"dotenv-expand": {
"version": "5.1.0",
"from": "dotenv-expand@>=5.1.0 <6.0.0",
"resolved": "https://registry.npmjs.org/dotenv-expand/-/dotenv-expand-5.1.0.tgz",
"dev": true
},
"download": {
"version": "4.4.3",
"from": "download@>=4.1.2 <5.0.0",
@ -2198,6 +2216,20 @@
"resolved": "https://registry.npmjs.org/grunt-banner/-/grunt-banner-0.6.0.tgz",
"dev": true
},
"grunt-cli": {
"version": "0.1.13",
"from": "grunt-cli@0.1.13",
"resolved": "https://registry.npmjs.org/grunt-cli/-/grunt-cli-0.1.13.tgz",
"dev": true,
"dependencies": {
"resolve": {
"version": "0.3.1",
"from": "resolve@>=0.3.1 <0.4.0",
"resolved": "https://registry.npmjs.org/resolve/-/resolve-0.3.1.tgz",
"dev": true
}
}
},
"grunt-contrib-clean": {
"version": "1.0.0",
"from": "grunt-contrib-clean@>=1.0.0 <1.1.0",
@ -3303,6 +3335,20 @@
"resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz",
"dev": true
},
"isemail": {
"version": "3.2.0",
"from": "isemail@>=3.0.0 <4.0.0",
"resolved": "https://registry.npmjs.org/isemail/-/isemail-3.2.0.tgz",
"dev": true,
"dependencies": {
"punycode": {
"version": "2.1.1",
"from": "punycode@>=2.0.0 <3.0.0",
"resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz",
"dev": true
}
}
},
"isexe": {
"version": "2.0.0",
"from": "isexe@>=2.0.0 <3.0.0",
@ -3321,6 +3367,20 @@
"resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz",
"dev": true
},
"joi": {
"version": "13.7.0",
"from": "joi@>=13.0.0 <14.0.0",
"resolved": "https://registry.npmjs.org/joi/-/joi-13.7.0.tgz",
"dev": true,
"dependencies": {
"hoek": {
"version": "5.0.4",
"from": "hoek@>=5.0.0 <6.0.0",
"resolved": "https://registry.npmjs.org/hoek/-/hoek-5.0.4.tgz",
"dev": true
}
}
},
"jpegtran-bin": {
"version": "3.2.0",
"from": "jpegtran-bin@>=3.0.0 <4.0.0",
@ -4566,6 +4626,12 @@
"resolved": "https://registry.npmjs.org/pseudomap/-/pseudomap-1.0.2.tgz",
"dev": true
},
"psl": {
"version": "1.8.0",
"from": "psl@>=1.1.28 <2.0.0",
"resolved": "https://registry.npmjs.org/psl/-/psl-1.8.0.tgz",
"dev": true
},
"public-encrypt": {
"version": "4.0.0",
"from": "public-encrypt@>=4.0.0 <5.0.0",
@ -4923,6 +4989,12 @@
"resolved": "https://registry.npmjs.org/run-async/-/run-async-0.1.0.tgz",
"dev": true
},
"rx": {
"version": "4.1.0",
"from": "rx@>=4.1.0 <5.0.0",
"resolved": "https://registry.npmjs.org/rx/-/rx-4.1.0.tgz",
"dev": true
},
"rx-lite": {
"version": "3.1.2",
"from": "rx-lite@>=3.1.2 <4.0.0",
@ -5581,6 +5653,20 @@
"resolved": "https://registry.npmjs.org/to-arraybuffer/-/to-arraybuffer-1.0.1.tgz",
"dev": true
},
"topo": {
"version": "3.0.3",
"from": "topo@>=3.0.0 <4.0.0",
"resolved": "https://registry.npmjs.org/topo/-/topo-3.0.3.tgz",
"dev": true,
"dependencies": {
"hoek": {
"version": "6.1.3",
"from": "hoek@>=6.0.0 <7.0.0",
"resolved": "https://registry.npmjs.org/hoek/-/hoek-6.1.3.tgz",
"dev": true
}
}
},
"tough-cookie": {
"version": "2.3.3",
"from": "tough-cookie@>=2.3.3 <2.4.0",
@ -5708,6 +5794,20 @@
"resolved": "https://registry.npmjs.org/unzip-response/-/unzip-response-1.0.2.tgz",
"dev": true
},
"uri-js": {
"version": "4.4.0",
"from": "uri-js@>=4.2.2 <5.0.0",
"resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.0.tgz",
"dev": true,
"dependencies": {
"punycode": {
"version": "2.1.1",
"from": "punycode@^2.1.0",
"resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz",
"dev": true
}
}
},
"uri-path": {
"version": "1.0.0",
"from": "uri-path@>=1.0.0 <2.0.0",
@ -5849,6 +5949,122 @@
"resolved": "https://registry.npmjs.org/vm-browserify/-/vm-browserify-0.0.4.tgz",
"dev": true
},
"wait-on": {
"version": "3.2.0",
"from": "wait-on@>=3.2.0 <3.3.0",
"resolved": "https://registry.npmjs.org/wait-on/-/wait-on-3.2.0.tgz",
"dev": true,
"dependencies": {
"ajv": {
"version": "6.12.6",
"from": "ajv@>=6.12.3 <7.0.0",
"resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz",
"dev": true
},
"aws4": {
"version": "1.11.0",
"from": "aws4@>=1.8.0 <2.0.0",
"resolved": "https://registry.npmjs.org/aws4/-/aws4-1.11.0.tgz",
"dev": true
},
"combined-stream": {
"version": "1.0.8",
"from": "combined-stream@>=1.0.6 <1.1.0",
"resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz",
"dev": true
},
"extend": {
"version": "3.0.2",
"from": "extend@>=3.0.2 <3.1.0",
"resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz",
"dev": true
},
"fast-deep-equal": {
"version": "3.1.3",
"from": "fast-deep-equal@>=3.1.1 <4.0.0",
"resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz",
"dev": true
},
"form-data": {
"version": "2.3.3",
"from": "form-data@>=2.3.2 <2.4.0",
"resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.3.tgz",
"dev": true
},
"har-validator": {
"version": "5.1.5",
"from": "har-validator@>=5.1.3 <5.2.0",
"resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.1.5.tgz",
"dev": true
},
"json-schema-traverse": {
"version": "0.4.1",
"from": "json-schema-traverse@>=0.4.1 <0.5.0",
"resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz",
"dev": true
},
"mime-db": {
"version": "1.44.0",
"from": "mime-db@1.44.0",
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.44.0.tgz",
"dev": true
},
"mime-types": {
"version": "2.1.27",
"from": "mime-types@>=2.1.19 <2.2.0",
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.27.tgz",
"dev": true
},
"oauth-sign": {
"version": "0.9.0",
"from": "oauth-sign@>=0.9.0 <0.10.0",
"resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz",
"dev": true
},
"punycode": {
"version": "2.1.1",
"from": "punycode@^2.1.1",
"resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz",
"dev": true
},
"qs": {
"version": "6.5.2",
"from": "qs@>=6.5.2 <6.6.0",
"resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz",
"dev": true
},
"request": {
"version": "2.88.2",
"from": "request@>=2.88.0 <3.0.0",
"resolved": "https://registry.npmjs.org/request/-/request-2.88.2.tgz",
"dev": true
},
"safe-buffer": {
"version": "5.2.1",
"from": "safe-buffer@>=5.1.2 <6.0.0",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
"dev": true
},
"tough-cookie": {
"version": "2.5.0",
"from": "tough-cookie@>=2.5.0 <2.6.0",
"resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.5.0.tgz",
"dev": true
},
"tunnel-agent": {
"version": "0.6.0",
"from": "tunnel-agent@>=0.6.0 <0.7.0",
"resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz",
"dev": true
},
"uuid": {
"version": "3.4.0",
"from": "uuid@>=3.3.2 <4.0.0",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz",
"dev": true
}
}
},
"walkdir": {
"version": "0.0.11",
"from": "walkdir@>=0.0.11 <0.0.12",

View File

@ -13,9 +13,12 @@
"license": "GPL-2.0+",
"devDependencies": {
"autoprefixer": "^6.5.1",
"dotenv": "^8.2.0",
"dotenv-expand": "^5.1.0",
"grunt": "~0.4.5",
"grunt-banner": "^0.6.0",
"grunt-contrib-clean": "~1.0.0",
"grunt-cli": "0.1.13",
"grunt-contrib-compress": "~1.3.0",
"grunt-contrib-concat": "~1.0.0",
"grunt-contrib-copy": "~1.0.0",
@ -34,10 +37,29 @@
"grunt-replace": "~1.0.1",
"grunt-rtlcss": "~2.0.1",
"grunt-sass": "~1.2.1",
"ink-docstrap": "^1.3.0",
"grunt-webpack": "^3.0.2",
"ink-docstrap": "^1.3.0",
"matchdep": "~1.0.0",
"wait-on": "~3.2.0",
"webpack": "^3.6.0",
"webpack-dev-server": "^2.9.1"
},
"scripts": {
"build": "grunt build",
"build:dev": "grunt build --dev",
"dev": "grunt watch --dev",
"test": "grunt test",
"watch": "grunt watch",
"grunt": "grunt",
"env:start": "node ./tools/local-env/scripts/start.js",
"env:stop": "node ./tools/local-env/scripts/docker.js down",
"env:restart": "npm run env:stop && npm run env:start",
"env:clean": "node ./tools/local-env/scripts/docker.js down -v --remove-orphans",
"env:reset": "node ./tools/local-env/scripts/docker.js down --rmi all -v --remove-orphans",
"env:install": "node ./tools/local-env/scripts/install.js",
"env:cli": "node ./tools/local-env/scripts/docker.js run cli",
"env:logs": "node ./tools/local-env/scripts/docker.js logs",
"env:pull": "node ./tools/local-env/scripts/docker.js pull",
"test:php": "node ./tools/local-env/scripts/docker.js run --rm phpunit phpunit"
}
}

View File

@ -829,7 +829,7 @@ class WP_Object_Cache {
if ( isset( $memcached_servers ) )
$this->servers = $memcached_servers;
else
$this->servers = array( array( '127.0.0.1', 11211 ) );
$this->servers = array( array( 'memcached', 11211 ) );
$this->addServers( $this->servers );

View File

@ -54,7 +54,7 @@ class Tests_Ajax_CustomizeMenus extends WP_Ajax_UnitTestCase {
if ( 'administrator' != $role ) {
// If we're not an admin, we should get a wp_die(-1).
$this->setExpectedException( 'WPAjaxDieStopException' );
$this->setExpectedException( 'WPAjaxDieStopException', '-1' );
}
wp_set_current_user( self::factory()->user->create( array( 'role' => $role ) ) );
@ -429,7 +429,7 @@ class Tests_Ajax_CustomizeMenus extends WP_Ajax_UnitTestCase {
if ( 'administrator' != $role ) {
// If we're not an admin, we should get a wp_die(-1).
$this->setExpectedException( 'WPAjaxDieStopException' );
$this->setExpectedException( 'WPAjaxDieStopException', '-1' );
}
wp_set_current_user( self::factory()->user->create( array( 'role' => $role ) ) );

View File

@ -0,0 +1,32 @@
server {
index index.php index.html;
listen 80 default_server;
listen [::]:80 default_server;
server_name localhost;
client_max_body_size 1g;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
root /var/www/${LOCAL_DIR};
absolute_redirect off;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass php:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_pass_header Authorization;
}
}

View File

@ -0,0 +1,8 @@
/**
* MySQL server init.
*
* SQL queries in this file will be executed the first time the MySQL server is started.
*/
CREATE DATABASE IF NOT EXISTS wordpress_develop;
CREATE DATABASE IF NOT EXISTS wordpress_develop_tests;

View File

@ -0,0 +1,2 @@
upload_max_filesize = 1G
post_max_size = 1G

View File

@ -0,0 +1,6 @@
upload_max_filesize = 1G
post_max_size = 1G
opcache.enable = 1
opcache.enable_cli = 1
opache.file_cache = /tmp/php-opcache

View File

@ -0,0 +1,8 @@
const dotenv = require( 'dotenv' );
const dotenvExpand = require( 'dotenv-expand' );
const { execSync } = require( 'child_process' );
dotenvExpand( dotenv.config() );
// Execute any docker-compose command passed to this script.
execSync( 'docker-compose ' + process.argv.slice( 2 ).join( ' ' ), { stdio: 'inherit' } );

View File

@ -0,0 +1,47 @@
const dotenv = require( 'dotenv' );
const dotenvExpand = require( 'dotenv-expand' );
const wait_on = require( 'wait-on' );
const { execSync } = require( 'child_process' );
const { renameSync, readFileSync, writeFileSync } = require( 'fs' );
dotenvExpand( dotenv.config() );
// Create wp-config.php.
wp_cli( 'config create --dbname=wordpress_develop --dbuser=root --dbpass=password --dbhost=mysql --path=/var/www/src --force' );
// Add the debug settings to wp-config.php.
// Windows requires this to be done as an additional step, rather than using the --extra-php option in the previous step.
wp_cli( `config set WP_DEBUG ${process.env.LOCAL_WP_DEBUG} --raw --type=constant` );
wp_cli( `config set WP_DEBUG_LOG ${process.env.LOCAL_WP_DEBUG_LOG} --raw --type=constant` );
wp_cli( `config set WP_DEBUG_DISPLAY ${process.env.LOCAL_WP_DEBUG_DISPLAY} --raw --type=constant` );
wp_cli( `config set SCRIPT_DEBUG ${process.env.LOCAL_SCRIPT_DEBUG} --raw --type=constant` );
wp_cli( `config set WP_ENVIRONMENT_TYPE ${process.env.LOCAL_WP_ENVIRONMENT_TYPE} --type=constant` );
// Move wp-config.php to the base directory, so it doesn't get mixed up in the src or build directories.
renameSync( 'src/wp-config.php', 'wp-config.php' );
// Read in wp-tests-config-sample.php, edit it to work with our config, then write it to wp-tests-config.php.
const testConfig = readFileSync( 'wp-tests-config-sample.php', 'utf8' )
.replace( 'youremptytestdbnamehere', 'wordpress_develop_tests' )
.replace( 'yourusernamehere', 'root' )
.replace( 'yourpasswordhere', 'password' )
.replace( 'localhost', 'mysql' )
.concat( "\ndefine( 'FS_METHOD', 'direct' );\n" );
writeFileSync( 'wp-tests-config.php', testConfig );
// Once the site is available, install WordPress!
wait_on( { resources: [ `tcp:localhost:${process.env.LOCAL_PORT}`] } )
.then( () => {
wp_cli( 'db reset --yes' );
wp_cli( `core install --title="WordPress Develop" --admin_user=admin --admin_password=password --admin_email=test@test.com --skip-email --url=http://localhost:${process.env.LOCAL_PORT}` );
} );
/**
* Runs WP-CLI commands in the Docker environment.
*
* @param {string} cmd The WP-CLI command to run.
*/
function wp_cli( cmd ) {
execSync( `docker-compose run --rm cli ${cmd}`, { stdio: 'inherit' } );
}

View File

@ -0,0 +1,36 @@
const dotenv = require( 'dotenv' );
const dotenvExpand = require( 'dotenv-expand' );
const { execSync } = require( 'child_process' );
dotenvExpand( dotenv.config() );
// Start the local-env containers.
execSync( 'docker-compose up -d wordpress-develop', { stdio: 'inherit' } );
// If Docker Toolbox is being used, we need to manually forward LOCAL_PORT to the Docker VM.
if ( process.env.DOCKER_TOOLBOX_INSTALL_PATH ) {
// VBoxManage is added to the PATH on every platform except Windows.
const vboxmanage = process.env.VBOX_MSI_INSTALL_PATH ? `${ process.env.VBOX_MSI_INSTALL_PATH }/VBoxManage` : 'VBoxManage'
// Check if the port forwarding is already configured for this port.
const vminfoBuffer = execSync( `"${ vboxmanage }" showvminfo "${ process.env.DOCKER_MACHINE_NAME }" --machinereadable` );
const vminfo = vminfoBuffer.toString().split( /[\r\n]+/ );
vminfo.forEach( ( info ) => {
if ( ! info.startsWith( 'Forwarding' ) ) {
return;
}
// `info` is in the format: Forwarding(1)="tcp-port8889,tcp,127.0.0.1,8889,,8889"
// Parse it down so `rule` only contains the data inside quotes, split by ','.
const rule = info.replace( /(^.*?"|"$)/, '' ).split( ',' );
// Delete rules that are using the port we need.
if ( rule[ 3 ] === process.env.LOCAL_PORT || rule[ 5 ] === process.env.LOCAL_PORT ) {
execSync( `"${ vboxmanage }" controlvm "${ process.env.DOCKER_MACHINE_NAME }" natpf1 delete ${ rule[ 0 ] }`, { stdio: 'inherit' } );
}
} );
// Add our port forwarding rule.
execSync( `"${ vboxmanage }" controlvm "${ process.env.DOCKER_MACHINE_NAME }" natpf1 "tcp-port${ process.env.LOCAL_PORT },tcp,127.0.0.1,${ process.env.LOCAL_PORT },,${ process.env.LOCAL_PORT }"`, { stdio: 'inherit' } );
}