|
1 | | -# Travis CI configuration file for Hogan. |
2 | | -# @link https://travis-ci.org/ |
3 | | - |
4 | | -# Ditch sudo and use containers. |
5 | | -# @link https://docs.travis-ci.com/user/migrating-from-legacy/#Why-migrate-to-container-based-infrastructure%3F |
6 | | -# @link https://docs.travis-ci.com/user/workers/container-based-infrastructure/#Routing-your-build-to-container-based-infrastructure |
7 | 1 | sudo: false |
8 | 2 | dist: trusty |
9 | 3 |
|
10 | | -# Declare versions of PHP to use. Use one decimal max. |
11 | | -# @link https://docs.travis-ci.com/user/build-configuration/ |
| 4 | +cache: |
| 5 | + directories: |
| 6 | + - $HOME/.composer/cache |
| 7 | + |
12 | 8 | matrix: |
13 | | - fast_finish: true |
| 9 | + include: |
| 10 | + - language: php |
| 11 | + php: 7.2 |
| 12 | + env: WP_TRAVISCI=phpcs |
14 | 13 |
|
15 | | - include: |
16 | | - # PHP 7.0.x |
17 | | - - language: php |
18 | | - php: '7.0' |
19 | | - env: |
20 | | - - SNIFF="1" |
21 | | - - LINT="0" |
| 14 | + - language: php |
| 15 | + php: 7.1 |
| 16 | + env: WP_TRAVISCI=phpcs |
22 | 17 |
|
23 | | - # PHP 7.2.x |
24 | | - - language: php |
25 | | - php: '7.2' |
26 | | - env: |
27 | | - - SNIFF="1" |
28 | | - - LINT="0" |
| 18 | + - language: php |
| 19 | + php: 7.0 |
| 20 | + env: WP_TRAVISCI=phpcs |
29 | 21 |
|
30 | | - # Node.js / Linting |
31 | | - - language: node_js |
32 | | - node_js: 8 |
33 | | - env: |
34 | | - - SNIFF="0" |
35 | | - - LINT="1" |
| 22 | + - language: node_js |
| 23 | + node_js: 8 |
| 24 | + env: WP_TRAVISCI=node |
36 | 25 |
|
37 | | -# Use this to prepare your build for testing. |
38 | | -# Failures in this section will result in build status 'errored'. |
39 | 26 | before_script: |
40 | | - - export PHPCS_DIR=/tmp/phpcs |
41 | | - - export SNIFFS_WPCS_DIR=/tmp/sniffs_wpcs |
42 | | - - export SNIFFS_PHPCOMPATIBILITY_DIR=/tmp/sniffs_phpcompataibility |
43 | | - # Install CodeSniffer for WordPress Coding Standards checks. |
44 | | - - if [[ "$SNIFF" == "1" ]]; then git clone -b master --depth 1 https://github.com/squizlabs/PHP_CodeSniffer.git $PHPCS_DIR; fi |
45 | | - # Install WordPress Coding Standards. |
46 | | - - if [[ "$SNIFF" == "1" ]]; then git clone -b master --depth 1 https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards.git $SNIFFS_WPCS_DIR; fi |
47 | | - # Install PHP Compatibility. |
48 | | - - if [[ "$SNIFF" == "1" ]]; then git clone -b master --depth 1 https://github.com/wimg/PHPCompatibility.git $SNIFFS_PHPCOMPATIBILITY_DIR; fi |
49 | | - # Set install path for PHPCS sniffs. |
50 | | - - if [[ "$SNIFF" == "1" ]]; then $PHPCS_DIR/bin/phpcs --config-set installed_paths $SNIFFS_WPCS_DIR,$SNIFFS_PHPCOMPATIBILITY_DIR; fi |
51 | | - # After CodeSniffer install you should refresh your path. |
52 | | - - if [[ "$SNIFF" == "1" ]]; then phpenv rehash; fi |
53 | | - # Install node packages. |
54 | | - - if [[ "$LINT" == "1" ]]; then yarn install; fi |
| 27 | + - if [[ "$WP_TRAVISCI" == "phpcs" ]]; then export PATH="$HOME/.composer/vendor/bin:$PATH"; fi |
| 28 | + - | |
| 29 | + if [[ "$WP_TRAVISCI" == "phpcs" ]] ; then |
| 30 | + if [ -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini ]; then |
| 31 | + phpenv config-rm xdebug.ini |
| 32 | + else |
| 33 | + echo "xdebug.ini does not exist" |
| 34 | + fi |
| 35 | + fi |
| 36 | + - | |
| 37 | + if [[ "$WP_TRAVISCI" == "phpcs" ]] ; then |
| 38 | + composer install |
| 39 | + fi |
| 40 | + - if [[ "$WP_TRAVISCI" == "node" ]]; then yarn install; fi |
55 | 41 |
|
56 | | -# Run test script commands. |
57 | | -# Default is specific to project language. |
58 | | -# All commands must exit with code 0 on success. Anything else is considered failure. |
59 | 42 | script: |
60 | | - # Search for PHP syntax errors. |
61 | | - - if [[ "$SNIFF" == "1" ]]; then find -L . -name '*.php' -print0 | xargs -0 -n 1 -P 4 php -l; fi |
62 | | - # WordPress Coding Standards. |
63 | | - # @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards |
64 | | - # @link https://pear.php.net/package/PHP_CodeSniffer/ |
65 | | - # Uses a custom ruleset based on WordPress. |
66 | | - - if [[ "$SNIFF" == "1" ]]; then $PHPCS_DIR/bin/phpcs --runtime-set testVersion $TRAVIS_PHP_VERSION; fi |
67 | | - - if [[ "$LINT" == "1" ]]; then yarn lint; fi |
| 43 | + - | |
| 44 | + if [[ "$WP_TRAVISCI" == "phpcs" ]] ; then |
| 45 | + find . -name '*.php' ! -path "./vendor/*" ! -path "./wp-content/*" -print0 | xargs -0 -n 1 -P 4 php -l |
| 46 | + echo Running phpcs for PHP version $TRAVIS_PHP_VERSION … |
| 47 | + ./vendor/bin/phpcs --runtime-set testVersion $TRAVIS_PHP_VERSION |
| 48 | + fi |
| 49 | + - if [[ "$WP_TRAVISCI" == "node" ]]; then yarn lint; fi |
68 | 50 |
|
69 | | -# Receive notifications for build results. |
70 | | -# @link https://docs.travis-ci.com/user/notifications/#Email-notifications |
71 | 51 | notifications: |
72 | | - email: false |
| 52 | + email: false |
0 commit comments