Make WordPress Core

Changeset 49528


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:
11 added
6 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:
  • branches/5.1/package-lock.json

    r49462 r49528  
    3333            "resolved": "https://registry.npmjs.org/@financial-times/useragent_parser/-/useragent_parser-1.0.2.tgz",
    3434            "integrity": "sha512-zuJMxn5Qnk7CKl+zrVXDqXs0F+p4tshO6B4s8VenJj34EEVuV4iZIbkGiEFJUbn29z9Mcn6k8yfj9qSCNDcPPQ=="
     35        },
     36        "@hapi/address": {
     37            "version": "2.1.4",
     38            "resolved": "https://registry.npmjs.org/@hapi/address/-/address-2.1.4.tgz",
     39            "integrity": "sha512-QD1PhQk+s31P1ixsX0H0Suoupp3VMXzIVMSwobR3F3MSUO2YCV0B7xqLcUw/Bh8yuvd3LhpyqLQWTNcRmp6IdQ==",
     40            "dev": true
     41        },
     42        "@hapi/bourne": {
     43            "version": "1.3.2",
     44            "resolved": "https://registry.npmjs.org/@hapi/bourne/-/bourne-1.3.2.tgz",
     45            "integrity": "sha512-1dVNHT76Uu5N3eJNTYcvxee+jzX4Z9lfciqRRHCU27ihbUcYi+iSc2iml5Ke1LXe1SyJCLA0+14Jh4tXJgOppA==",
     46            "dev": true
     47        },
     48        "@hapi/hoek": {
     49            "version": "8.5.1",
     50            "resolved": "https://registry.npmjs.org/@hapi/hoek/-/hoek-8.5.1.tgz",
     51            "integrity": "sha512-yN7kbciD87WzLGc5539Tn0sApjyiGHAJgKvG9W8C7O+6c7qmoQMfVs0W4bX17eqz6C78QJqqFrtgdK5EWf6Qow==",
     52            "dev": true
     53        },
     54        "@hapi/joi": {
     55            "version": "15.1.1",
     56            "resolved": "https://registry.npmjs.org/@hapi/joi/-/joi-15.1.1.tgz",
     57            "integrity": "sha512-entf8ZMOK8sc+8YfeOlM8pCfg3b5+WZIKBfUaaJT8UsjAAPjartzxIYm3TIbjvA4u+u++KbcXD38k682nVHDAQ==",
     58            "dev": true,
     59            "requires": {
     60                "@hapi/address": "2.x.x",
     61                "@hapi/bourne": "1.x.x",
     62                "@hapi/hoek": "8.x.x",
     63                "@hapi/topo": "3.x.x"
     64            }
     65        },
     66        "@hapi/topo": {
     67            "version": "3.1.6",
     68            "resolved": "https://registry.npmjs.org/@hapi/topo/-/topo-3.1.6.tgz",
     69            "integrity": "sha512-tAag0jEcjwH+P2quUfipd7liWCNX2F8NvYjQp2wtInsZxnMlypdw0FtAOLxtvvkO+GSRRbmNi8m/5y42PQJYCQ==",
     70            "dev": true,
     71            "requires": {
     72                "@hapi/hoek": "^8.3.0"
     73            }
    3574        },
    3675        "@tannin/compile": {
     
    46844723            }
    46854724        },
     4725        "dotenv": {
     4726            "version": "8.2.0",
     4727            "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-8.2.0.tgz",
     4728            "integrity": "sha512-8sJ78ElpbDJBHNeBzUbUVLsqKdccaa/BXF1uPTw3GrvQTBgrQrtObr2mUrE38vzYd8cEv+m/JBfDLioYcfXoaw==",
     4729            "dev": true
     4730        },
     4731        "dotenv-expand": {
     4732            "version": "5.1.0",
     4733            "resolved": "https://registry.npmjs.org/dotenv-expand/-/dotenv-expand-5.1.0.tgz",
     4734            "integrity": "sha512-YXQl1DSa4/PQyRfgrv6aoNjhasp/p4qs9FjJ4q4cQk+8m4r6k4ZSiEyytKG8f8W9gi8WsQtIObNmKd+tMzNTmA==",
     4735            "dev": true
     4736        },
    46864737        "download": {
    46874738            "version": "4.4.3",
     
    1329613347            "integrity": "sha1-QAwJ6+kU57F+C27zJjQA/Cq8fLM="
    1329713348        },
     13349        "rx": {
     13350            "version": "4.1.0",
     13351            "resolved": "https://registry.npmjs.org/rx/-/rx-4.1.0.tgz",
     13352            "integrity": "sha1-pfE/957zt0D+MKqAP7CfmIBdR4I=",
     13353            "dev": true
     13354        },
    1329813355        "rxjs": {
    1329913356            "version": "5.5.10",
     
    1583815895            "requires": {
    1583915896                "indexof": "0.0.1"
     15897            }
     15898        },
     15899        "wait-on": {
     15900            "version": "3.3.0",
     15901            "resolved": "https://registry.npmjs.org/wait-on/-/wait-on-3.3.0.tgz",
     15902            "integrity": "sha512-97dEuUapx4+Y12aknWZn7D25kkjMk16PbWoYzpSdA8bYpVfS6hpl2a2pOWZ3c+Tyt3/i4/pglyZctG3J4V1hWQ==",
     15903            "dev": true,
     15904            "requires": {
     15905                "@hapi/joi": "^15.0.3",
     15906                "core-js": "^2.6.5",
     15907                "minimist": "^1.2.0",
     15908                "request": "^2.88.0",
     15909                "rx": "^4.1.0"
     15910            },
     15911            "dependencies": {
     15912                "core-js": {
     15913                    "version": "2.6.11",
     15914                    "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.6.11.tgz",
     15915                    "integrity": "sha512-5wjnpaT/3dV+XB4borEsnAYQchn00XSgTAWKDkEqv+K8KevjbzmofK6hfJ9TZIlpj2N0xQpazy7PiRQiWHqzWg==",
     15916                    "dev": true
     15917                }
    1584015918            }
    1584115919        },
  • branches/5.1/package.json

    r49462 r49528  
    2020        "copy-webpack-plugin": "^4.6.0",
    2121        "cssnano": "4.1.8",
     22        "dotenv": "^8.2.0",
     23        "dotenv-expand": "^5.1.0",
    2224        "grunt": "~1.0.3",
    2325        "grunt-banner": "^0.6.0",
     
    4951        "uglify-js": "^3.4.9",
    5052        "uglifyjs-webpack-plugin": "2.1.1",
     53        "wait-on": "^3.3.0",
    5154        "webpack": "4.29.2",
    5255        "webpack-dev-server": "3.1.14",
     
    111114    },
    112115    "scripts": {
    113         "grunt": "grunt"
     116        "build": "grunt build",
     117        "build:dev": "grunt build --dev",
     118        "dev": "grunt watch --dev",
     119        "test": "grunt test",
     120        "watch": "grunt watch",
     121        "grunt": "grunt",
     122        "env:start": "node ./tools/local-env/scripts/start.js",
     123        "env:stop": "node ./tools/local-env/scripts/docker.js down",
     124        "env:restart": "npm run env:stop && npm run env:start",
     125        "env:clean": "node ./tools/local-env/scripts/docker.js down -v --remove-orphans",
     126        "env:reset": "node ./tools/local-env/scripts/docker.js down --rmi all -v --remove-orphans",
     127        "env:install": "node ./tools/local-env/scripts/install.js",
     128        "env:cli": "node ./tools/local-env/scripts/docker.js run cli",
     129        "env:logs": "node ./tools/local-env/scripts/docker.js logs",
     130        "env:pull": "node ./tools/local-env/scripts/docker.js pull",
     131        "test:php": "node ./tools/local-env/scripts/docker.js run --rm phpunit phpunit"
    114132    }
    115133}
  • branches/5.1/tests/phpunit/includes/object-cache.php

    r42343 r49528  
    835835            $this->servers = $memcached_servers;
    836836        } else {
    837             $this->servers = array( array( '127.0.0.1', 11211 ) );
     837            $this->servers = array( array( 'memcached', 11211 ) );
    838838        }
    839839
  • branches/5.1/tests/phpunit/tests/ajax/CustomizeMenus.php

    r43571 r49528  
    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
Note: See TracChangeset for help on using the changeset viewer.