# https://docs.travis-ci.com/user/languages/php
language: php

os:
  - linux

# https://docs.travis-ci.com/user/trusty-ci-environment/
dist: bionic

services:
  - mysql
  - postgresql

jobs:
  fast_finish: true
  include:
    #- env: DB=mysql; MW=REL1_36; PHPUNIT=8.5.*
    #  php: 8.0
    - env: DB=mysql; MW=REL1_35; PHPUNIT=8.5.*;  # SITELANG=ja
      php: 7.4
    - env: DB=postgres; MW=REL1_35; PHPUNIT=8.5.*; FUSEKI=2.4.0
      php: 7.4
    #- env: DB=sqlite; MW=REL1_35; PHPUNIT=8.5.*; SESAME=2.8.7
    #  php: 7.4
    - env: DB=sqlite; MW=REL1_35; PHPUNIT=8.5.*; BLAZEGRAPH=1.5.2
      php: 7.4
    #- env: DB=sqlite; MW=REL1_35; PHPUNIT=8.5.*; VIRTUOSO=6.1
    #  php: 7.4
    - env: DB=sqlite; MW=REL1_35; PHPUNIT=8.5.*; TYPE=benchmark
      php: 7.4
  allow_failures:
    # May take a moment and is non-critical therefore allow it to run without delaying the status
    - env: DB=sqlite; MW=REL1_35; PHPUNIT=8.5.*; TYPE=benchmark
    # Currently broken for unknown reason
    # - env: DB=sqlite; MW=REL1_35; PHPUNIT=8.5.*; BLAZEGRAPH=1.5.2
    # - env: DB=sqlite; MW=REL1_35; PHPUNIT=8.5.*; VIRTUOSO=6.1
    # - env: env: DB=mysql; MW=REL1_36; PHPUNIT=8.5.*

# Dec 16, 2015 (GCE switch): Travis support wrote (Tomcat + Java):
# bug in the JDK: http://bugs.java.com/bugdatabase/view_bug.do?bug_id=7089443.
# The hostname for the precise-gce platform is longer than 64 characters on the
# VM your job is running on
#- sudo hostname "$(hostname | cut -c1-63)"
#- sed -e "s/^\\(127\\.0\\.0\\.1.*\\)/\\1 $(hostname | cut -c1-63)/" /etc/hosts | sudo tee /etc/hosts
#- cat /etc/hosts # optionally check the content *after*

# Aug 12, 2016: (incident:2p40l49r3yxd) Travis support asks to add `sudo sysctl ...`
# After investigation, removed the lines from Dec 16, 2015 as it emptied the hosts file
before_install:
  - phpenv config-rm xdebug.ini # https://github.com/travis-ci/travis-ci/issues/1697
  - sudo sysctl -w net.ipv6.conf.all.disable_ipv6=1
  - sudo sysctl -w net.ipv6.conf.default.disable_ipv6=1
  - ip addr # for confirmation. can be skipped
  - cat /etc/hosts # optionally check the content *before*
  # MW is not yet compatible with Composer 2.x, see https://phabricator.wikimedia.org/T266417
  - composer self-update --1
  - wget https://raw.githubusercontent.com/SemanticMediaWiki/CIScripts/main/travis/install-mediawiki.sh
  - wget https://raw.githubusercontent.com/SemanticMediaWiki/CIScripts/main/travis/install-phpunit.sh

install:
  - bash ./install-mediawiki.sh
  - bash ./install-phpunit.sh
  - bash ./tests/travis/install-services.sh
  - bash ./tests/travis/install-semantic-mediawiki.sh

before_script:
  - bash ./tests/travis/update-configuration-settings.sh

script:
  - bash ./tests/travis/run-tests.sh

after_script:
  - if [ ls /tmp/stacktrace* 1> /dev/null 2>&1 ] ; then cat /tmp/stacktrace*.log ; fi
  - if [ -f php.log ] ; then cat php.log ; fi
  - if [ -f /tmp/mediawiki-debug.log ] ; then cat /tmp/mediawiki-debug.log ; fi

after_success:
  - bash ./tests/travis/upload-coverage-report.sh

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