variables:
  # Configure mysql service (https://hub.docker.com/_/mysql/)
  MYSQL_DATABASE: wordpress_tests
  MYSQL_ROOT_PASSWORD: mysql

cache:
  paths:
    - $HOME/.composer

before_script:
  # Install dependencies

  # update the docker
  - apt-get clean
  - apt-get -yqq update

  # install the required packages for the running CI tests
  - |
    apt-get -yqqf install lsb-release zip unzip subversion mysql-client libicu-dev libpng-dev libbz2-dev --fix-missing

    if [[ $(lsb_release -a) =~ "stretch" ]]; then
      apt-get -yqqf install default-libmysqlclient-dev --fix-missing
    else
      apt-get -yqqf install libmysqlclient-dev --fix-missing
    fi

  # PHP extensions
  - docker-php-ext-install mbstring mysqli intl gd zip bz2

  # Install Composer
  - curl -sS https://getcomposer.org/installer | php
  - mv composer.phar /usr/local/bin/composer
  - export PATH="$HOME/.composer/vendor/bin:$PATH"

  # Set up WordPress tests
  - bash bin/install-wp-tests.sh $MYSQL_DATABASE root $MYSQL_ROOT_PASSWORD mysql latest true

  # PHPUnit
  - |
    if [[ $(php -v) =~ "PHP 7." ]]; then
      composer global require "phpunit/phpunit=6.1.*"
    else
      composer global require "phpunit/phpunit=4.8.*"
    fi

  # Install PHPCS and WPCS
  - composer global require automattic/vipwpcs
  - phpcs --config-set installed_paths $HOME/.composer/vendor/wp-coding-standards/wpcs,$HOME/.composer/vendor/automattic/vipwpcs

PHPunit:PHP5.3:MySQL:
  image: tetraweb/php:5.3
  services:
    - mysql:5.6
  script:
    - phpcs -n
    - phpunit
  when: manual
  allow_failure: true

PHPunit:PHP5.6:MySQL:
  image: php:5.6-stretch
  services:
    - mysql:5.6
  script:
    - phpcs -n
    - phpunit

PHPunit:PHP7.0:MySQL:
  image: php:7.0-stretch
  services:
    - mysql:5.6
  script:
    - phpcs -n
    - phpunit

PHPunit:PHP7.1:MySQL:
  image: php:7.1-stretch
  services:
    - mysql:5.6
  script:
    - phpcs -n
    - phpunit

PHPunit:PHP7.2:MySQL:
  image: php:7.2-stretch
  services:
    - mysql:5.6
  script:
    - phpcs -n
    - phpunit
