-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.travis.yml
106 lines (99 loc) · 3.18 KB
/
.travis.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# Travis CI configuration file.
# @link https://travis-ci.org/
# Declare project language and PHP versions to test against.
# @link http://about.travis-ci.org/docs/user/languages/php/
language: php
# Ditch sudo and use containers.
# @link https://docs.travis-ci.com/user/ci-environment/
sudo: false
# Tell Travis CI which distro to use
dist: trusty
env:
global:
# WordPress Coding Standard test indicator.
WP_CS_TEST=no
WP_VERSION=latest
WP_MULTISITE=0
# Create a matrix for testing against multiple PHP versions.
matrix:
include:
- php: 7.2
env: WP_CS_TEST=yes
- php: 7.2
env: WP_VERSION=4.9
- php: 7.1
- php: 7.1
env: WP_VERSION=4.9
- php: 7.0
- php: 7.0
env: WP_VERSION=4.9
# Setup NPM modules for Travis CI cache maintanence.
cache:
apt: true
directories:
- $HOME/.npm
- node_modules
- vendor
- $HOME/.composer/cache
before_install:
- |
if [ "${WP_CS_TEST}" == "yes" ]; then
npm prune
npm update
$TRAVIS_BUILD_DIR/vendor/bin/phpcs --config-set installed_paths $TRAVIS_BUILD_DIR/vendor/wp-coding-standards/wpcs
fi
# Use this to prepare your build for testing.
# e.g. copy database configurations, environment variables, etc.
# Failures in this section will result in build status 'errored'.
before_script:
- |
# Remove Xdebug for a huge performance increase:
if [ -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini ]; then
phpenv config-rm xdebug.ini
else
echo "xdebug.ini does not exist"
fi
- export PATH="$HOME/.composer/vendor/bin:$PATH"
# Install phpunuit test suite
- |
if [[ ! -z "$WP_VERSION" ]] ; then
bash bin/install-wp-tests.sh wordpress_test root '' localhost $WP_VERSION
if [[ ${TRAVIS_PHP_VERSION:0:3} == "5.2" ]]; then
echo "Using default PHPUnit, hopefully 3.6"
elif [[ ${TRAVIS_PHP_VERSION:0:3} == "5.6" ]]; then
composer global require "phpunit/phpunit=5.7.*"
elif [[ ${TRAVIS_PHP_VERSION:0:2} == "5." ]]; then
composer global require "phpunit/phpunit=4.8.*"
elif [[ ${TRAVIS_PHP_VERSION:0:2} == "7." && "${WP_VERSION}" == "4.0" ]]; then
composer global require "phpunit/phpunit=5.7.*"
else
composer global require "phpunit/phpunit:^6"
fi
fi
- which phpunit
- phpunit --version
# Only update composer with other dependencies from composer.json if we are doing CS tests.
- |
if [ "${WP_CS_TEST}" == "yes" ]; then
composer update
fi
# Run test script commands.
# Default is specific to project language.
# All commands must exit with code 0 on success. Anything else is considered failure.
script:
# Change to the src folder
- cd src
# Search for PHP syntax errors.
- find . \( -name '*.php' \) -exec php -lf {} \;
# Go back to the root before running further tests.
- cd ..
# We really only need to run coding standards and linting tests once, on the most recent PHP build
# as any failure will be reported any way. This saves a fair amount of time during test runs.
- |
if [ "${WP_CS_TEST}" == "yes" ]; then
node --version
npm --version
npm install
./node_modules/.bin/gulp phpcs
fi
- phpunit