.travis.yml 2.05 KB
# Travis CI configuration file.
# @link https://travis-ci.org/

# For use with the UnderStrap WordPress theme
# @link https://github.com/understrap/understrap


# Declare virtual environment and operating system.
# @link https://docs.travis-ci.com/user/reference/overview/#virtualization-environments
os: linux
dist: xenial

# Declare project language and PHP versions to test against.
# @link https://docs.travis-ci.com/user/languages/php/
language: php
php:
  - '5.6'
  - '7.0'
  - '7.1'
  - '7.2'
  - '7.3'
  - '7.4'
  - nightly

matrix:
  fast_finish: true
  include:
    - php: 7.4
      env: PHPCS=1
  allow_failures:
    - php: nightly
  
# Use this to prepare the build for testing.
before_script:
    # Speed up build time by disabling Xdebug.
    - phpenv config-rm xdebug.ini || echo 'No xdebug config.'
    # Install composer dependencies
    - if [ "$TRAVIS_PHP_VERSION" != "nightly" ]; then 
        composer install;
      else
        composer install --ignore-platform-reqs;
      fi
    # Install JSCS: JavaScript Code Style checker
    # @link http://jscs.info/
    - if [[ "$PHPCS" == 1 ]]; then npm install -g jscs; fi
    # Install JSHint, a JavaScript Code Quality Tool
    # @link https://jshint.com/docs/
    - if [[ "$PHPCS" == 1 ]]; then npm install -g jshint; fi
    - if [[ "$PHPCS" == 1 ]]; then wget https://develop.svn.wordpress.org/trunk/.jshintrc; 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:
  # Validate the composer.json file.
  # @link https://getcomposer.org/doc/03-cli.md#validate
  - if [[ "$PHPCS" == 1 ]]; then composer validate --no-check-all --strict; fi

  # Lint the PHP files against parse errors.
  - composer lint:php

  # Check the code against the standards as documented in the phpcs.xml file.
  - if [[ "$PHPCS" == 1 ]]; then composer check:cs; fi
  # Run the theme through JSHint
  - if [[ "$PHPCS" == 1 ]]; then jshint .; fi
  # Run the theme through JavaScript Code Style checker
  - if [[ "$PHPCS" == 1 ]]; then jscs .; fi