felixarntz/wp-site-identity

View on GitHub
.travis.yml

Summary

Maintainability
Test Coverage
sudo: false
dist: trusty
language: php
cache:
  directories:
    - node_modules
    - vendor
    - $HOME/.composer/cache
matrix:
  include:
    - php: 7.1
      env: WP_VERSION=master WP_MULTISITE=1 PHPLINT=1 COVERAGE=1
    - php: 5.2
      env: WP_VERSION=4.9 WP_MULTISITE=1 PHPLINT=1
      dist: precise
    - php: 7.1
      env: WP_VERSION=4.9
    - php: 7.1
      env: WP_VERSION=4.8
    - php: 7.1
      env: WP_VERSION=4.7
    - php: 7.0
      env: WP_VERSION=4.9
    - php: 5.6
      env: WP_VERSION=4.9
    - php: 5.5
      env: WP_VERSION=4.9
    - php: 5.4
      env: WP_VERSION=4.9
    - php: 5.3
      env: WP_VERSION=4.9
      dist: precise
    - php: nightly
      env: WP_VERSION=4.9
  allow_failures:
    - php: nightly
before_script:
- |
  if [[ "$COVERAGE" != "1" ]]; then
    stable='^[0-9\.]+$'
    if [[ "$TRAVIS_PHP_VERSION" =~ $stable ]]; then
      if [ -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini ]; then
        phpenv config-rm xdebug.ini
      fi
    fi
  fi
- |
  case "$TRAVIS_PHP_VERSION" in
    5.6|5.5|5.4|5.3)
      composer global require "phpunit/phpunit:^4"
      ;;
    5.2)
      ;;
    *)
      composer selfupdate 1.0.0 --no-interaction
      composer install --dev --no-interaction
      ;;
  esac
- PLUGIN_SLUG=$(basename $(pwd))
- export WP_DEVELOP_DIR=/tmp/wordpress/
- git clone --depth=50 --branch="$WP_VERSION" git://develop.git.wordpress.org/ /tmp/wordpress
- cd ..
- cp -r "$PLUGIN_SLUG" "/tmp/wordpress/src/wp-content/plugins/$PLUGIN_SLUG"
- cd /tmp/wordpress/
- |
  if [[ "$WP_TRAVIS_OBJECT_CACHE" == "true" ]]; then
    curl https://raw.githubusercontent.com/tollmanz/wordpress-pecl-memcached-object-cache/584392b56dc4adbe52bd2c7b86f875e23a3e5f75/object-cache.php > src/wp-content/object-cache.php
  fi
- cp wp-tests-config-sample.php wp-tests-config.php
- sed -i "s/youremptytestdbnamehere/wordpress_tests/" wp-tests-config.php
- sed -i "s/yourusernamehere/travis/" wp-tests-config.php
- sed -i "s/yourpasswordhere//" wp-tests-config.php
- mysql -e "CREATE DATABASE wordpress_tests;" -uroot
- cd "/tmp/wordpress/src/wp-content/plugins/$PLUGIN_SLUG"
- phpenv rehash
script:
- |
  if [[ "$PHPLINT" == "1" ]]; then
    find -L .  -path ./vendor -prune -o -name '*.php' -print0 | xargs -0 -n 1 -P 4 php -l
  fi
- |
  if [[ -z "$CODECLIMATE_REPO_TOKEN" ]]; then
    COVERAGE="0"
  fi
- |
  case "$TRAVIS_PHP_VERSION" in
    5.6|5.5|5.4|5.3|5.2)
      phpunit -c phpunit.xml
      ;;
    *)
      if [[ "$COVERAGE" == "1" ]]; then
        mkdir -p build/logs
        vendor/bin/phpunit -c phpunit.xml --coverage-clover build/logs/clover.xml
        vendor/bin/test-reporter;
      else
        vendor/bin/phpunit -c phpunit.xml
      fi
      ;;
  esac
notifications:
  email: false