language: php
sudo: false
dist: xenial

services:
  - docker

php:
  - 7.0
  - 7.1
  - 7.2
  - 7.3.6
  - 7.4snapshot

matrix:
  fast_finish: true
  allow_failures:
    - php: 7.4snapshot
  include:
    - php: 5.4
      dist: trusty
    - php: 5.5
      dist: trusty
    - php: 5.6
      dist: trusty

env:
  global:
    - DISPLAY=:99.0

cache:
  directories:
    - $HOME/.composer/cache/files

install:
  - composer install --no-interaction

before_script:
  - mkdir ./logs
  - docker run -p 4444:4444 --network=host -v /dev/shm:/dev/shm --shm-size 2g selenium/standalone-firefox:2.53.1 &> ./logs/selenium.log &
  - ./vendor/bin/mink-test-server &> ./logs/mink-test-server.log &
  - until $(echo | nc localhost 4444); do sleep 1; echo Waiting for Selenium server on port 4444...; done; echo "Selenium server started"
  - until $(echo | nc localhost 8002); do sleep 1; echo waiting for PHP server on port 8002...; done; echo "PHP server started"

script:
  - ./vendor/bin/simple-phpunit -v --coverage-clover=coverage.clover

after_script:
  - wget https://scrutinizer-ci.com/ocular.phar
  - php ocular.phar code-coverage:upload --format=php-clover coverage.clover

after_failure:
  - cat ./logs/selenium.log
  - cat ./logs/mink-test-server.log
