This repository has been archived by the owner on May 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.travis.yml
135 lines (119 loc) · 3.94 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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# Travis CI (MIT License) configuration file for WP Starter Theme
# @link https://travis-ci.org/
# Declare project language.
# @link http://about.travis-ci.org/docs/user/languages/php/
language: php
# Specify when Travis should build.
branches:
only:
- master
cache:
directories:
- $HOME/.composer/cache
- ./vendor
# Git clone depth.
git:
depth: 1
matrix:
fast_finish: true
include:
- php: '5.6'
env: WP_VERSION=latest PHP_LINT=1
- php: '7.2'
env: WP_VERSION=latest PHP_LINT=1
- php: '7.2'
env: WP_VERSION=trunk
- php: '7.2'
env: WP_VERSION=latest WP_PHPCS=1 WP_TRAVIS_OBJECT_CACHE=1
- php: 'nightly'
env: WP_VERSION=latest PHP_LINT=1
allow_failures:
- php: 'nightly'
# Prepare your build for testing.
# Failures in this section will result in build status 'errored'.
before_script:
# Turn off Xdebug. See https://core.trac.wordpress.org/changeset/40138.
- phpenv config-rm xdebug.ini || echo "Xdebug not available"
- export PATH="$HOME/.composer/vendor/bin:$PATH"
# Couple the PHPUnit version to the PHP version.
- |
case "$TRAVIS_PHP_VERSION" in
7.2|7.0|nightly)
echo "Using PHPUnit 6.1"
composer global require "phpunit/phpunit=6.1.*"
;;
5.6)
echo "Using PHPUnit 4.8"
composer global require "phpunit/phpunit=4.8.*"
;;
*)
echo "No PHPUnit version handling for PHP version $TRAVIS_PHP_VERSION"
exit 1
;;
esac
- og_dir="$(pwd)"
- plugin_slug="$(basename $(pwd))"
- |
if [[ ! -z "$WP_VERSION" ]] ; then
# Set up the WordPress installation.
export WP_CORE_DIR=/tmp/wordpress/
bash bin/install-wp-tests.sh wordpress_test root '' localhost $WP_VERSION
echo "define( 'JETPACK_DEV_DEBUG', true );" >> $WP_CORE_DIR/wp-tests-config.php
# Maybe install memcached.
if [[ "$WP_TRAVIS_OBJECT_CACHE" == "1" ]]; then
curl https://raw.githubusercontent.com/tollmanz/wordpress-pecl-memcached-object-cache/584392b56dc4adbe52bd2c7b86f875e23a3e5f75/object-cache.php > $WP_CORE_DIR/wp-content/object-cache.php
echo "extension = memcached.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
fi
# Set up the plugin. This assumes that this repo name matches the plugin name.
mkdir -p "${WP_CORE_DIR}wp-content/plugins/$plugin_slug"
cp -R . "${WP_CORE_DIR}wp-content/plugins/$plugin_slug/"
# Hop into plugin's directory.
cd ${WP_CORE_DIR}wp-content/plugins/$plugin_slug/
# For debugging.
which phpunit
phpunit --version
fi
# Set up phpcs.
- |
if [[ "$WP_PHPCS" == "1" ]] ; then
composer global require automattic/vipwpcs
phpcs --config-set installed_paths $HOME/.composer/vendor/wp-coding-standards/wpcs,$HOME/.composer/vendor/automattic/vipwpcs
fi
- pwd
# 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:
# Search for PHP syntax errors.
#
# Only need to run this once per PHP version.
- |
if [[ "$PHP_LINT" == "1" ]] ; then
find . -type "f" -iname "*.php" -not -path "./vendor/*" | xargs -L "1" php -l
fi
# WordPress Coding Standards.
#
# These are the same across PHP and WordPress, so we need to run them only once.
#
# @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards
# @link http://pear.php.net/package/PHP_CodeSniffer/
- |
if [[ "$WP_PHPCS" == "1" ]] ; then
phpcs -n
fi
# Run the theme's unit tests, both in single and multisite.
- |
if [[ ! -z "$WP_VERSION" ]] ; then
phpunit
WP_MULTISITE=1 phpunit
fi
# Receive notifications for build results.
# @link http://docs.travis-ci.com/user/notifications/#Email-notifications
notifications:
email: false
# Xenial image has PHP versions 5.6,7.1,7.2 pre-installed
dist: xenial
# Xenial does not start mysql by default
services:
- mysql
- memcached