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

before_script:
  # Install dependencies

  # Update the docker
  - apt-get -yqq update
  - apt-get -yqqf install zip unzip subversion default-mysql-client default-libmysqlclient-dev --fix-missing

  # PHP extensions
  - docker-php-ext-install -j$(nproc) mysqli pdo_mysql

  # Setup WordPress tests
  - bash bin/install-wp-tests.sh wordpress_tests root mysql mysql latest true

  # Install Composer
  - php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
  - php composer-setup.php --install-dir=/usr/local/bin --filename=composer
  - php -r "unlink('composer-setup.php');"
  - export PATH="$PATH:$HOME/.composer/vendor/bin"

  # Install PHPUnit
  - PHPUNIT_VERSION=9.6.19
  - curl -o /usr/local/bin/phpunit "https://phar.phpunit.de/phpunit-${PHPUNIT_VERSION}.phar" && chmod +x /usr/local/bin/phpunit
  - composer global require yoast/phpunit-polyfills
  - export WP_TESTS_PHPUNIT_POLYFILLS_PATH="$HOME/.composer/vendor/yoast/phpunit-polyfills"
  - phpunit --version

  # Install PHPCS and WPCS
  - composer global config allow-plugins.dealerdirect/phpcodesniffer-composer-installer true
  - composer global require "wp-coding-standards/wpcs"
  - composer global require "phpcompatibility/phpcompatibility-wp"
  - phpcs --version

PHPunit:PHP7.4:MySQL:
  image: php:7.4-bullseye
  services:
    - mysql:5.7
  script:
  - phpcs
  - phpunit

PHPunit:PHP8.0:MySQL:
  image: php:8.0-bullseye
  services:
    - mysql:5.7
  script:
  - phpcs
  - phpunit

PHPunit:PHP8.2:MySQL:
  image: php:8.2-bullseye
  services:
    - mysql:5.7
  script:
  - phpcs
  - phpunit
