Make WordPress Core


Ignore:
Timestamp:
11/06/2020 05:17:17 PM (4 years ago)
Author:
desrosj
Message:

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

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

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

Location:
branches/5.2
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/5.2

  • branches/5.2/.travis.yml

    r47928 r49527  
    1 sudo: false
    2 dist: trusty
    3 language: php
     1language: generic
     2
     3services:
     4  - docker
     5
     6addons:
     7  apt:
     8    packages:
     9      - docker-ce
     10
    411cache:
    512  apt: true
     
    714    - $HOME/.npm
    815    - vendor
    9     - $HOME/.composer/cache
     16
    1017env:
    1118  global:
    12     - WP_TRAVISCI=travis:phpunit
     19    - LOCAL_DIR: build
     20    - COMPOSER_INSTALL: false
     21    - NPM_INSTALL: true
     22    - WP_INSTALL: true
     23    - PHP_FPM_UID: "`id -u`"
     24    - PHP_FPM_GID: "`id -g`"
     25
    1326matrix:
    1427  include:
    15   - php: 7.2
    16     env: WP_TRAVISCI=travis:format
    17   - php: 7.1
    18     env: WP_TRAVISCI=travis:js
    19   - php: 7.3
    20     env: WP_TRAVIS_OBJECT_CACHE=true
    21     services: memcached
    22   - php: 7.0
    23     env: WP_TEST_REPORTER=true
    24   - php: 5.6
     28    - env: WP_TRAVISCI=travis:format LOCAL_PHP=7.2-fpm LOCAL_PHPUNIT=7.2-fpm COMPOSER_INSTALL=true WP_INSTALL=false
     29      name: "PHP Linting"
     30    - env: WP_TRAVISCI=travis:js LOCAL_PHP=7.1-fpm WP_INSTALL=false
     31      name: "JS Tests"
     32    - env: LOCAL_PHP_MEMCACHED=true LOCAL_PHPUNIT=7.3-fpm WP_TRAVISCI=test:php
     33      name: "PHPUnit Tests: PHP 7.3 with Memcached"
     34    - env: LOCAL_PHP=7.0-fpm LOCAL_PHPUNIT=7.0-fpm WP_TEST_REPORTER=true WP_TRAVISCI=test:php
     35      name: "PHPUnit Tests: PHP 7.0"
     36    - env: LOCAL_PHP=5.6-fpm LOCAL_PHPUNIT=5.6-fpm WP_TRAVISCI=test:php
     37      name: "PHPUnit Tests: PHP 5.6"
    2538  fast_finish: true
     39
    2640before_install:
    27 - |
    28   if [[ "$WP_TRAVISCI" == "travis:phpunit" ]]; then
    29       mysql -u root -e "CREATE DATABASE wordpress_tests;"
    30       cp wp-tests-config-sample.php wp-tests-config.php
    31       sed -i "s/youremptytestdbnamehere/wordpress_tests/" wp-tests-config.php
    32       sed -i "s/yourusernamehere/root/" wp-tests-config.php
    33       sed -i "s/yourpasswordhere//" wp-tests-config.php
     41  - |
     42    if [[ "$WP_TRAVISCI" == "test:php" ]]; then
    3443      travis_retry svn checkout https://plugins.svn.wordpress.org/wordpress-importer/tags/0.6.3/ tests/phpunit/data/plugins/wordpress-importer
    35   fi
    36 - |
    37   if [[ "$WP_TRAVIS_OBJECT_CACHE" == "true" ]]; then
    38     cp tests/phpunit/includes/object-cache.php src/wp-content/object-cache.php
    39     echo "extension = memcached.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
    40   fi
     44    fi
     45  - |
     46    sudo rm /usr/local/bin/docker-compose
     47    curl -L https://github.com/docker/compose/releases/download/1.24.0/docker-compose-`uname -s`-`uname -m` > docker-compose
     48    chmod +x docker-compose
     49    sudo mv docker-compose /usr/local/bin
     50
    4151before_script:
    42 - |
    43   # Remove Xdebug for a huge performance increase:
    44   if [ -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini ]; then
    45     phpenv config-rm xdebug.ini
    46   else
    47     echo "xdebug.ini does not exist"
    48   fi
    49 - |
    50   # Export Composer's global bin dir to PATH, but not on PHP 5.2:
    51   composer config --list --global
    52   export PATH=`composer config --list --global | grep '\[home\]' | { read a; echo "${a#* }/vendor/bin:$PATH"; }`
    53 - |
    54   # Install the specified version of PHPUnit depending on the PHP version:
    55   if [[ "$WP_TRAVISCI" == "travis:phpunit" ]]; then
    56     case "$TRAVIS_PHP_VERSION" in
    57       7.3|7.2|7.1)
    58         echo "Using PHPUnit 7.x"
    59         travis_retry composer global require "phpunit/phpunit:^7"
    60         ;;
    61       7.0)
    62         echo "Using PHPUnit 6.x"
    63         travis_retry composer global require "phpunit/phpunit:^6"
    64         ;;
    65       5.6)
    66         echo "Using PHPUnit 4.x"
    67         travis_retry composer global require "phpunit/phpunit:^4"
    68         ;;
    69       *)
    70         echo "No PHPUnit version handling for PHP version $TRAVIS_PHP_VERSION"
    71         exit 1
    72         ;;
    73     esac
    74   fi
    75 - |
    76   # We only need to run composer install on the code formatting job.
    77   if [[ "$WP_TRAVISCI" == "travis:format" ]]; then
    78     composer --version
    79     travis_retry composer install
    80   fi
    81 - npm --version
    82 - node --version
    83 - nvm install 10.13.0
    84 - npm install -g grunt-cli
    85 - npm install
    86 - npm prune
    87 - mysql --version
    88 - phpenv versions
    89 - php --version
    90 - php -m
    91 - npm --version
    92 - node --version
    93 - |
    94   # Display PHPUnit information (for PHP tests only).
    95   if [[ "$WP_TRAVISCI" == "travis:phpunit" ]]; then
    96     which phpunit
    97     phpunit --version
    98   fi
    99 - curl --version
    100 - grunt --version
    101 - git --version
    102 - svn --version
    103 - locale -a
    104 script: grunt $WP_TRAVISCI
     52  - |
     53    if [[ "$COMPOSER_INSTALL" == "true" ]]; then
     54      docker-compose run --rm php composer --version
     55      docker-compose run --rm php composer install
     56    fi
     57  - npm --version
     58  - node --version
     59  - nvm install 10.13.0
     60  - |
     61    if [[ "$NPM_INSTALL" == "true" ]]; then
     62      npm install
     63    fi
     64  - |
     65    if [[ "$WP_TRAVISCI" == "test:php" ]]; then
     66      npm run env:start
     67      npm run build
     68      docker-compose run --rm mysql mysql --version
     69      docker-compose run --rm php php --version
     70      docker-compose run --rm php php -m
     71      docker-compose run --rm phpunit phpunit --version
     72    fi
     73  - |
     74    if [[ "$LOCAL_PHP_MEMCACHED" == "true" ]]; then
     75      cp tests/phpunit/includes/object-cache.php build/wp-content/object-cache.php
     76      # The memcached server needs to start after `npm run env:start`, which sets up the Docker network.
     77      docker run --name memcached --net $(basename "$PWD")_wpdevnet -d memcached
     78    fi
     79  - |
     80    if [[ "$WP_INSTALL" == "true" ]]; then
     81      # Run the install process after memcached has started.
     82      npm run env:install
     83    fi
     84  - npm --version
     85  - node --version
     86  - curl --version
     87  - git --version
     88  - svn --version
     89  - php --version
     90  - php -i
     91  - locale -a
     92
     93script:
     94  - |
     95    if [[ "$WP_TRAVISCI" == "test:php" ]]; then
     96      npm run test:php -- --verbose -c phpunit.xml.dist &&
     97      npm run test:php -- --verbose -c phpunit.xml.dist --group ajax &&
     98      npm run test:php -- --verbose -c tests/phpunit/multisite.xml &&
     99      npm run test:php -- --verbose -c tests/phpunit/multisite.xml --group ms-files &&
     100      npm run test:php -- --verbose -c phpunit.xml.dist --group external-http &&
     101      npm run test:php -- --verbose -c phpunit.xml.dist --group restapi-jsclient &&
     102      # __fakegroup__ is excluded to force PHPUnit to ignore the <exclude> settings in phpunit.xml.dist.
     103      LOCAL_PHP_XDEBUG=true npm run test:php -- -v --group xdebug --exclude-group __fakegroup__
     104    elif [[ "$WP_TRAVISCI" == "travis:format" ]]; then
     105      docker-compose run --rm php composer format
     106    else
     107      npm run grunt $WP_TRAVISCI
     108    fi
     109
    105110after_script:
    106 - |
    107   if [[ "$WP_TEST_REPORTER" == "true" ]]; then
    108     git clone https://github.com/WordPress/phpunit-test-runner.git test-runner
    109     export WPT_PREPARE_DIR=$(pwd)
    110     export WPT_TEST_DIR=$(pwd)
    111     php test-runner/report.php
    112   fi
     111  - |
     112    if [[ "$WP_TEST_REPORTER" == "true" ]]; then
     113      git clone https://github.com/WordPress/phpunit-test-runner.git test-runner
     114      docker-compose run --rm -e WPT_PREPARE_DIR=/var/www -e WPT_TEST_DIR=/var/www php php test-runner/report.php
     115    fi
     116
    113117notifications:
    114118  slack:
Note: See TracChangeset for help on using the changeset viewer.