WordPress.org

Make WordPress Core

Changeset 45762


Ignore:
Timestamp:
08/07/2019 11:54:22 AM (4 months ago)
Author:
pento
Message:

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.

Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/.env

    r45745 r45762  
    1919LOCAL_PHP_XDEBUG=false
    2020
     21# Whether or not to enable Memcached.
     22LOCAL_PHP_MEMCACHED=false
     23
    2124# The MySQL version to use. See https://hub.docker.com/_/mysql/ for valid versions.
    2225LOCAL_MYSQL=5.7
  • trunk/.travis.yml

    r45745 r45762  
    1818env:
    1919  global:
    20     - LOCAL_DIR=build
     20    - LOCAL_DIR: build
    2121
    2222matrix:
    2323  include:
    2424  - env: WP_TRAVISCI=test:e2e
     25    name: E2E Tests
    2526  - env: WP_TRAVISCI=travis:phpcs
     27    name: PHP Linting
    2628  - env: WP_TRAVISCI=travis:js
     29    name: JS Tests
    2730  - env: LOCAL_PHP=7.3-fpm WP_TRAVISCI=test:php
    28   - php: 7.3
    29     dist: trusty
    30     env: WP_TRAVIS_OBJECT_CACHE=true WP_TRAVISCI=travis:phpunit
    31     services: memcached
     31    name: "PHPUnit Tests: PHP 7.3"
     32  - env: LOCAL_PHP=7.3-fpm LOCAL_PHP_MEMCACHED=true WP_TRAVISCI=test:php
     33    name: "PHPUnit Tests: PHP 7.3 with Memcached"
    3234  - env: LOCAL_PHP=7.2-fpm WP_TRAVISCI=test:php
     35    name: "PHPUnit Tests: PHP 7.2"
    3336  - env: LOCAL_PHP=7.1-fpm WP_TRAVISCI=test:php
     37    name: "PHPUnit Tests: PHP 7.1"
    3438  - env: LOCAL_PHP=7.0-fpm WP_TEST_REPORTER=true WP_TRAVISCI=test:php
     39    name: "PHPUnit Tests: PHP 7.0"
    3540  - env: LOCAL_PHP=5.6-fpm WP_TRAVISCI=test:php
    36   - php: 7.4snapshot
    37     dist: trusty
    38     env: WP_TRAVISCI=travis:phpunit
    39   - php: nightly
    40     dist: trusty
    41     env: WP_TRAVISCI=travis:phpunit
     41    name: "PHPUnit Tests: PHP 5.6"
     42  - env: LOCAL_PHP=7.4-fpm WP_TRAVISCI=test:php
     43    name: "PHPUnit Tests: PHP 7.4"
     44  - env: LOCAL_PHP=8.0-fpm WP_TRAVISCI=test:php
     45    name: "PHPUnit Tests: PHP 8.0"
    4246  allow_failures:
    43   - php: 7.4snapshot
    44   - php: nightly
     47  - env: LOCAL_PHP=7.4-fpm WP_TRAVISCI=test:php
     48  - env: LOCAL_PHP=8.0-fpm WP_TRAVISCI=test:php
    4549  fast_finish: true
    4650
    4751before_install:
    48 - |
    49   if [[ "$WP_TRAVISCI" == "travis:phpunit" ]]; then
    50       mysql -u root -e "CREATE DATABASE wordpress_tests;"
    51       cp wp-tests-config-sample.php wp-tests-config.php
    52       sed -i "s/youremptytestdbnamehere/wordpress_tests/" wp-tests-config.php
    53       sed -i "s/yourusernamehere/root/" wp-tests-config.php
    54       sed -i "s/yourpasswordhere//" wp-tests-config.php
    55       travis_retry svn checkout https://plugins.svn.wordpress.org/wordpress-importer/tags/0.6.3/ tests/phpunit/data/plugins/wordpress-importer
    56   fi
    5752- |
    5853  if [[ "$WP_TRAVISCI" == "test:php" ]]; then
     
    6257      sed -i "s/yourpasswordhere/password/" wp-tests-config.php
    6358      sed -i "s/localhost/mysql/" wp-tests-config.php
     59      echo "define( 'FS_METHOD', 'direct' );" >> wp-tests-config.php
    6460      travis_retry svn checkout https://plugins.svn.wordpress.org/wordpress-importer/tags/0.6.3/ tests/phpunit/data/plugins/wordpress-importer
    6561  fi
     
    6965  chmod +x docker-compose
    7066  sudo mv docker-compose /usr/local/bin
    71 - |
    72   if [[ "$WP_TRAVIS_OBJECT_CACHE" == "true" ]]; then
    73     cp tests/phpunit/includes/object-cache.php src/wp-content/object-cache.php
    74     echo "extension = memcached.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
    75   fi
    7667
    7768before_script:
     
    10899    npm run env:start
    109100    npm run build
     101    docker-compose -f tools/local-env/docker-compose.yml run --rm mysql mysql --version
     102    docker-compose -f tools/local-env/docker-compose.yml run --rm php php --version
     103    docker-compose -f tools/local-env/docker-compose.yml run --rm php php -m
     104    docker-compose -f tools/local-env/docker-compose.yml -f tools/local-env/docker-compose.scripts.yml run --rm phpunit phpunit --version
     105  fi
     106- |
     107  if [[ "$LOCAL_PHP_MEMCACHED" == "true" ]]; then
     108    cp tests/phpunit/includes/object-cache.php build/wp-content/object-cache.php
     109    docker run --name memcached --net local-env_wpdevnet -d memcached
    110110  fi
    111111- |
     
    113113    npm run env:install
    114114  fi
    115 - mysql --version
    116 - phpenv versions
    117 - php --version
    118 - php -m
    119115- npm --version
    120116- node --version
    121 - which phpunit
    122 - phpunit --version
    123117- curl --version
    124118- git --version
     
    131125      npm run test:e2e
    132126    elif [[ "$WP_TRAVISCI" == "test:php" ]]; then
    133       npm run test:php -- -- -- --verbose -c phpunit.xml.dist
    134       npm run test:php -- -- -- --verbose -c phpunit.xml.dist --group ajax
    135       npm run test:php -- -- -- --verbose -c tests/phpunit/multisite.xml
    136       npm run test:php -- -- -- --verbose -c tests/phpunit/multisite.xml --group ms-files
    137       npm run test:php -- -- -- --verbose -c phpunit.xml.dist --group external-http
     127      npm run test:php -- -- -- --verbose -c phpunit.xml.dist &&
     128      npm run test:php -- -- -- --verbose -c phpunit.xml.dist --group ajax &&
     129      npm run test:php -- -- -- --verbose -c tests/phpunit/multisite.xml &&
     130      npm run test:php -- -- -- --verbose -c tests/phpunit/multisite.xml --group ms-files &&
     131      npm run test:php -- -- -- --verbose -c phpunit.xml.dist --group external-http &&
    138132      npm run test:php -- -- -- --verbose -c phpunit.xml.dist --group restapi-jsclient
    139133    else
  • trunk/package.json

    r45745 r45762  
    148148        "env:__cli-next": "docker-compose -f ./tools/local-env/docker-compose.yml -f ./tools/local-env/docker-compose.scripts.yml run --rm cli",
    149149        "env:logs": "docker-compose -f ./tools/local-env/docker-compose.yml -f ./tools/local-env/docker-compose.scripts.yml logs",
     150        "env:pull": "dotenv npm run env:__pull-next",
     151        "env:__pull-next": "docker-compose -f ./tools/local-env/docker-compose.yml -f ./tools/local-env/docker-compose.scripts.yml pull",
    150152        "test:e2e": "dotenv npm run test:__e2e-next",
    151153        "test:__e2e-next": "cross-var cross-env WP_BASE_URL=http://localhost:$LOCAL_PORT wp-scripts test-e2e --config tests/e2e/jest.config.js",
  • trunk/tests/phpunit/includes/object-cache.php

    r45607 r45762  
    836836            $this->servers = $memcached_servers;
    837837        } else {
    838             $this->servers = array( array( '127.0.0.1', 11211 ) );
     838            $this->servers = array( array( 'memcached', 11211 ) );
    839839        }
    840840
  • trunk/tests/phpunit/tests/ajax/CustomizeMenus.php

    r45607 r45762  
    5555        if ( 'administrator' !== $role ) {
    5656            // If we're not an admin, we should get a wp_die(-1).
    57             $this->setExpectedException( 'WPAjaxDieStopException' );
     57            $this->setExpectedException( 'WPAjaxDieStopException', '-1' );
    5858        }
    5959
     
    444444        if ( 'administrator' !== $role ) {
    445445            // If we're not an admin, we should get a wp_die(-1).
    446             $this->setExpectedException( 'WPAjaxDieStopException' );
     446            $this->setExpectedException( 'WPAjaxDieStopException', '-1' );
    447447        }
    448448
  • trunk/tools/local-env/docker-compose.scripts.yml

    r45745 r45762  
    1414    environment:
    1515      LOCAL_PHP_XDEBUG: ${LOCAL_PHP_XDEBUG-false}
     16      LOCAL_PHP_MEMCACHED: ${LOCAL_PHP_MEMCACHED-false}
    1617
    1718    volumes:
     
    3233    environment:
    3334      LOCAL_PHP_XDEBUG: ${LOCAL_PHP_XDEBUG-false}
     35      LOCAL_PHP_MEMCACHED: ${LOCAL_PHP_MEMCACHED-false}
    3436
    3537    volumes:
  • trunk/tools/local-env/docker-compose.yml

    r45745 r45762  
    3939    environment:
    4040      LOCAL_PHP_XDEBUG: ${LOCAL_PHP_XDEBUG-false}
     41      LOCAL_PHP_MEMCACHED: ${LOCAL_PHP_MEMCACHED-false}
    4142
    4243    volumes:
Note: See TracChangeset for help on using the changeset viewer.