Make WordPress Core


Ignore:
Timestamp:
11/06/2020 05:24:43 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.1 branch.
See #48301, #47767.

Location:
branches/5.1
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/5.1

  • branches/5.1/.travis.yml

    r49278 r49528  
    1 sudo: false
    2 dist: trusty
    31language: php
     2
     3services:
     4  - docker
     5
    46cache:
    57  apt: true
     
    79    - $HOME/.npm
    810    - vendor
    9     - $HOME/.composer/cache
     11
    1012env:
    1113  global:
    12     - WP_TRAVISCI=travis:phpunit
     14    - LOCAL_DIR: build
     15    - COMPOSER_INSTALL: false
     16    - NPM_INSTALL: true
     17    - WP_INSTALL: true
     18    - PHP_FPM_UID: "`id -u`"
     19    - PHP_FPM_GID: "`id -g`"
     20
    1321matrix:
    1422  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   - php: 7.0
    21     env: WP_TEST_REPORTER=true
    22   - php: 5.6
    23     env: WP_TRAVIS_OBJECT_CACHE=true
    24     services: memcached
    25   - php: 5.2
    26     dist: precise
     23    - env: WP_TRAVISCI=travis:format LOCAL_PHP=7.2-fpm LOCAL_PHPUNIT=7.2-fpm COMPOSER_INSTALL=true WP_INSTALL=false
     24      name: "PHP Linting"
     25    - env: WP_TRAVISCI=travis:js LOCAL_PHP=7.1-fpm WP_INSTALL=false
     26      name: "JS Tests"
     27    - env: LOCAL_PHP_MEMCACHED=true LOCAL_PHPUNIT=7.3-fpm WP_TRAVISCI=test:php
     28      name: "PHPUnit Tests: PHP 7.3 with Memcached"
     29    - env: LOCAL_PHP=7.0-fpm LOCAL_PHPUNIT=6-php-7.0-fpm WP_TEST_REPORTER=true WP_TRAVISCI=test:php
     30      name: "PHPUnit Tests: PHP 7.0"
     31    - env: LOCAL_PHP=5.6-fpm LOCAL_PHPUNIT=4-php-5.6-fpm WP_TRAVISCI=test:php
     32      name: "PHPUnit Tests: PHP 5.6"
     33    - env: WP_TRAVISCI=travis:phpunit WP_INSTALL=false
     34      php: 5.2
     35      dist: precise
     36  fast_finish: true
     37
    2738before_install:
    28 - |
    29   if [[ "$WP_TRAVISCI" == "travis:phpunit" ]]; then
     39  - |
     40    if [[ "$WP_TRAVISCI" == "test:php" ]]; then
     41      travis_retry svn checkout https://plugins.svn.wordpress.org/wordpress-importer/tags/0.6.3/ tests/phpunit/data/plugins/wordpress-importer
     42    fi
     43  - |
     44    if [[ "$WP_TRAVISCI" != "travis:phpunit" ]]; then
     45      curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
     46      sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
     47      sudo apt-get update
     48      sudo apt-get -y -o Dpkg::Options::="--force-confnew" install docker-ce
     49    fi
     50  - |
     51    sudo rm /usr/local/bin/docker-compose
     52    curl -L https://github.com/docker/compose/releases/download/1.24.0/docker-compose-`uname -s`-`uname -m` > docker-compose
     53    chmod +x docker-compose
     54    sudo mv docker-compose /usr/local/bin
     55  - |
     56    if [[ "$WP_TRAVISCI" == "travis:phpunit" ]]; then
    3057      mysql -u root -e "CREATE DATABASE wordpress_tests;"
    3158      cp wp-tests-config-sample.php wp-tests-config.php
     
    3461      sed -i "s/yourpasswordhere//" wp-tests-config.php
    3562      travis_retry svn checkout https://plugins.svn.wordpress.org/wordpress-importer/tags/0.6.3/ tests/phpunit/data/plugins/wordpress-importer
    36   fi
    37 - |
    38   if [[ "$WP_TRAVIS_OBJECT_CACHE" == "true" ]]; then
    39     cp tests/phpunit/includes/object-cache.php src/wp-content/object-cache.php
    40     echo "extension = memcached.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
    41   fi
     63    fi
     64
    4265before_script:
    43 - |
    44   # Remove Xdebug for a huge performance increase:
    45   if [ -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini ]; then
    46     phpenv config-rm xdebug.ini
    47   else
    48     echo "xdebug.ini does not exist"
    49   fi
    50 - |
    51   # Export Composer's global bin dir to PATH, but not on PHP 5.2:
    52   if [[ ${TRAVIS_PHP_VERSION:0:3} != "5.2" ]]; then
    53     composer config --list --global
    54     export PATH=`composer config --list --global | grep '\[home\]' | { read a; echo "${a#* }/vendor/bin:$PATH"; }`
    55   fi
    56 - |
    57   # Install the specified version of PHPUnit depending on the PHP version:
    58   if [[ "$WP_TRAVISCI" == "travis:phpunit" ]]; then
    59     case "$TRAVIS_PHP_VERSION" in
    60       7.3|7.2|7.1)
    61         echo "Using PHPUnit 7.x"
    62         travis_retry composer global require "phpunit/phpunit:^7"
    63         ;;
    64       7.0)
    65         echo "Using PHPUnit 6.x"
    66         travis_retry composer global require "phpunit/phpunit:^6"
    67         ;;
    68       5.6|5.5|5.4|5.3)
    69         echo "Using PHPUnit 4.x"
    70         travis_retry composer global require "phpunit/phpunit:^4"
    71         ;;
    72       5.2)
    73         # Do nothing, use default PHPUnit 3.6.x
    74         echo "Using default PHPUnit, hopefully 3.6"
    75         ;;
    76       *)
    77         echo "No PHPUnit version handling for PHP version $TRAVIS_PHP_VERSION"
    78         exit 1
    79         ;;
    80     esac
    81   fi
    82 - |
    83   # We only need to run composer install on the code formatting job.
    84   if [[ "$WP_TRAVISCI" == "travis:format" ]]; then
    85     composer --version
    86     travis_retry composer install
    87   fi
    88 - npm --version
    89 - node --version
    90 - nvm install
    91 - npm install -g grunt-cli
    92 - npm install
    93 - npm prune
    94 - mysql --version
    95 - phpenv versions
    96 - php --version
    97 - php -m
    98 - npm --version
    99 - node --version
    100 - |
    101   # Display PHPUnit information (for PHP tests only).
    102   if [[ "$WP_TRAVISCI" == "travis:phpunit" ]]; then
    103     which phpunit
    104     phpunit --version
    105   fi
    106 - curl --version
    107 - grunt --version
    108 - git --version
    109 - svn --version
    110 - locale -a
    111 script: grunt $WP_TRAVISCI
     66  - |
     67    if [[ "$COMPOSER_INSTALL" == "true" ]]; then
     68      docker-compose run --rm php composer --version
     69      docker-compose run --rm php composer install
     70    fi
     71  - npm --version
     72  - node --version
     73  - nvm install
     74  - |
     75    if [[ "$WP_TRAVISCI" == "travis:phpunit" ]]; then
     76      phpenv config-rm xdebug.ini
     77      npm install -g grunt-cli
     78      mysql --version
     79      phpenv versions
     80      php --version
     81      php -m
     82    fi
     83  - |
     84    if [[ "$NPM_INSTALL" == "true" ]]; then
     85      npm install
     86    fi
     87  - |
     88    if [[ "$WP_TRAVISCI" == "test:php" ]]; then
     89      npm run env:start
     90      npm run build
     91      docker-compose run --rm mysql mysql --version
     92      docker-compose run --rm php php --version
     93      docker-compose run --rm php php -m
     94      docker-compose run --rm phpunit phpunit --version
     95    fi
     96  - |
     97    if [[ "$LOCAL_PHP_MEMCACHED" == "true" ]]; then
     98      cp tests/phpunit/includes/object-cache.php build/wp-content/object-cache.php
     99      # The memcached server needs to start after `npm run env:start`, which sets up the Docker network.
     100      docker run --name memcached --net $(basename "$PWD")_wpdevnet -d memcached
     101    fi
     102  - |
     103    if [[ "$WP_INSTALL" == "true" ]]; then
     104      # Run the install process after memcached has started.
     105      npm run env:install
     106    fi
     107  - npm --version
     108  - node --version
     109  - curl --version
     110  - git --version
     111  - svn --version
     112  - php --version
     113  - php -i
     114  - locale -a
     115
     116script:
     117  - |
     118    if [[ "$WP_TRAVISCI" == "test:php" ]]; then
     119      npm run test:php -- --verbose -c phpunit.xml.dist &&
     120      npm run test:php -- --verbose -c phpunit.xml.dist --group ajax &&
     121      npm run test:php -- --verbose -c tests/phpunit/multisite.xml &&
     122      npm run test:php -- --verbose -c tests/phpunit/multisite.xml --group ms-files &&
     123      npm run test:php -- --verbose -c phpunit.xml.dist --group external-http &&
     124      npm run test:php -- --verbose -c phpunit.xml.dist --group restapi-jsclient &&
     125      # __fakegroup__ is excluded to force PHPUnit to ignore the <exclude> settings in phpunit.xml.dist.
     126      LOCAL_PHP_XDEBUG=true npm run test:php -- -v --group xdebug --exclude-group __fakegroup__
     127    elif [[ "$WP_TRAVISCI" == "travis:format" ]]; then
     128      docker-compose run --rm php composer format
     129    else
     130      npm run grunt $WP_TRAVISCI
     131    fi
     132
    112133after_script:
    113 - |
    114   if [[ "$WP_TEST_REPORTER" == "true" ]]; then
    115     git clone https://github.com/WordPress/phpunit-test-runner.git test-runner
    116     export WPT_PREPARE_DIR=$(pwd)
    117     export WPT_TEST_DIR=$(pwd)
    118     php test-runner/report.php
    119   fi
     134  - |
     135    if [[ "$WP_TEST_REPORTER" == "true" ]]; then
     136      git clone https://github.com/WordPress/phpunit-test-runner.git test-runner
     137      docker-compose run --rm -e WPT_PREPARE_DIR=/var/www -e WPT_TEST_DIR=/var/www php php test-runner/report.php
     138    fi
     139
    120140notifications:
    121141  slack:
Note: See TracChangeset for help on using the changeset viewer.