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