Skip to content
Permalink
Browse files

Build Tools: Switch all Travis PHPUnit jobs over to Docker-based PHP.

Additionally, there are a handful of related minor changes in this commit:
- `.travis.yml` has been tidied up a little.
- [45745] was incorrectly marking Travis jobs as passed when some PHPUnit runs failed.
- Add the `LOCAL_PHP_MEMCACHED` environment variable, for enabling Memcached.
- Add the `env:pull` NPM script, for refreshing Docker images.

See #47767.


git-svn-id: https://develop.svn.wordpress.org/trunk@45762 602fd350-edb4-49c9-b593-d223f7449a82
  • Loading branch information...
pento committed Aug 7, 2019
1 parent 008085d commit 4271f1aeca533be3dacdcd68d2f71b1e29929706
3 .env
@@ -18,6 +18,9 @@ LOCAL_PHP=latest
# 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

@@ -17,62 +17,53 @@ cache:

env:
global:
- LOCAL_DIR=build
- LOCAL_DIR: build

matrix:
include:
- env: WP_TRAVISCI=test:e2e
name: E2E Tests
- env: WP_TRAVISCI=travis:phpcs
name: PHP Linting
- env: WP_TRAVISCI=travis:js
name: JS Tests
- env: LOCAL_PHP=7.3-fpm WP_TRAVISCI=test:php
- php: 7.3
dist: trusty
env: WP_TRAVIS_OBJECT_CACHE=true WP_TRAVISCI=travis:phpunit
services: memcached
name: "PHPUnit Tests: PHP 7.3"
- env: LOCAL_PHP=7.3-fpm LOCAL_PHP_MEMCACHED=true WP_TRAVISCI=test:php
name: "PHPUnit Tests: PHP 7.3 with Memcached"
- env: LOCAL_PHP=7.2-fpm WP_TRAVISCI=test:php
name: "PHPUnit Tests: PHP 7.2"
- env: LOCAL_PHP=7.1-fpm WP_TRAVISCI=test:php
name: "PHPUnit Tests: PHP 7.1"
- env: LOCAL_PHP=7.0-fpm WP_TEST_REPORTER=true WP_TRAVISCI=test:php
name: "PHPUnit Tests: PHP 7.0"
- env: LOCAL_PHP=5.6-fpm WP_TRAVISCI=test:php
- php: 7.4snapshot
dist: trusty
env: WP_TRAVISCI=travis:phpunit
- php: nightly
dist: trusty
env: WP_TRAVISCI=travis:phpunit
name: "PHPUnit Tests: PHP 5.6"
- env: LOCAL_PHP=7.4-fpm WP_TRAVISCI=test:php
name: "PHPUnit Tests: PHP 7.4"
- env: LOCAL_PHP=8.0-fpm WP_TRAVISCI=test:php
name: "PHPUnit Tests: PHP 8.0"
allow_failures:
- php: 7.4snapshot
- php: nightly
- env: LOCAL_PHP=7.4-fpm WP_TRAVISCI=test:php
- env: LOCAL_PHP=8.0-fpm WP_TRAVISCI=test:php
fast_finish: true

before_install:
- |
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
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" == "test:php" ]]; then
cp wp-tests-config-sample.php wp-tests-config.php
sed -i "s/youremptytestdbnamehere/wordpress_develop_tests/" wp-tests-config.php
sed -i "s/yourusernamehere/root/" wp-tests-config.php
sed -i "s/yourpasswordhere/password/" wp-tests-config.php
sed -i "s/localhost/mysql/" wp-tests-config.php
echo "define( 'FS_METHOD', 'direct' );" >> wp-tests-config.php
travis_retry svn checkout https://plugins.svn.wordpress.org/wordpress-importer/tags/0.6.3/ tests/phpunit/data/plugins/wordpress-importer
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_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
before_script:
- |
@@ -107,19 +98,22 @@ before_script:
if [[ "$WP_TRAVISCI" == "test:e2e" ]] || [[ "$WP_TRAVISCI" == "test:php" ]]; then
npm run env:start
npm run build
docker-compose -f tools/local-env/docker-compose.yml run --rm mysql mysql --version
docker-compose -f tools/local-env/docker-compose.yml run --rm php php --version
docker-compose -f tools/local-env/docker-compose.yml run --rm php php -m
docker-compose -f tools/local-env/docker-compose.yml -f tools/local-env/docker-compose.scripts.yml 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
docker run --name memcached --net local-env_wpdevnet -d memcached
fi
- |
if [[ "$WP_TRAVISCI" == "test:e2e" ]]; then
npm run env:install
fi
- mysql --version
- phpenv versions
- php --version
- php -m
- npm --version
- node --version
- which phpunit
- phpunit --version
- curl --version
- git --version
- svn --version
@@ -130,11 +124,11 @@ script:
if [[ "$WP_TRAVISCI" == "test:e2e" ]]; then
npm run test:e2e
elif [[ "$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 &&
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
else
npm run grunt $WP_TRAVISCI
@@ -147,6 +147,8 @@
"env:cli": "dotenv npm run env:__cli-next",
"env:__cli-next": "docker-compose -f ./tools/local-env/docker-compose.yml -f ./tools/local-env/docker-compose.scripts.yml run --rm cli",
"env:logs": "docker-compose -f ./tools/local-env/docker-compose.yml -f ./tools/local-env/docker-compose.scripts.yml logs",
"env:pull": "dotenv npm run env:__pull-next",
"env:__pull-next": "docker-compose -f ./tools/local-env/docker-compose.yml -f ./tools/local-env/docker-compose.scripts.yml pull",
"test:e2e": "dotenv npm run test:__e2e-next",
"test:__e2e-next": "cross-var cross-env WP_BASE_URL=http://localhost:$LOCAL_PORT wp-scripts test-e2e --config tests/e2e/jest.config.js",
"test:php": "dotenv npm run test:__php-next",
@@ -835,7 +835,7 @@ public function __construct( $persistent_id = null ) {
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 );
@@ -54,7 +54,7 @@ function test_ajax_load_available_items_cap_check( $role, $expected_results ) {
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 ) ) );
@@ -443,7 +443,7 @@ function test_ajax_search_available_items_caps_check( $role, $expected_results )
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 ) ) );
@@ -13,6 +13,7 @@ services:

environment:
LOCAL_PHP_XDEBUG: ${LOCAL_PHP_XDEBUG-false}
LOCAL_PHP_MEMCACHED: ${LOCAL_PHP_MEMCACHED-false}

volumes:
- ../../:/var/www
@@ -31,6 +32,7 @@ services:

environment:
LOCAL_PHP_XDEBUG: ${LOCAL_PHP_XDEBUG-false}
LOCAL_PHP_MEMCACHED: ${LOCAL_PHP_MEMCACHED-false}

volumes:
- ./phpunit-config.ini:/usr/local/etc/php/conf.d/phpunit-config.ini
@@ -38,6 +38,7 @@ services:

environment:
LOCAL_PHP_XDEBUG: ${LOCAL_PHP_XDEBUG-false}
LOCAL_PHP_MEMCACHED: ${LOCAL_PHP_MEMCACHED-false}

volumes:
- ./php-config.ini:/usr/local/etc/php/conf.d/php-config.ini

0 comments on commit 4271f1a

Please sign in to comment.
You can’t perform that action at this time.