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