dist: xenial

services:
  - postgresql

env:
  global:
    - ENVIRONMENT=testing
    - LIBRETIME_LOG_DIR=/tmp/log/libretime
    
before_install:
  - sudo add-apt-repository -y ppa:libretime/libretime
  - sudo apt-get -q update

addons:
  apt:
    packages:
      - gstreamer1.0-plugins-base
      - gstreamer1.0-plugins-good
      - gstreamer1.0-plugins-bad
      - gstreamer1.0-plugins-ugly
      - libgirepository1.0-dev
      - liquidsoap
      - liquidsoap-plugin-faad
      - liquidsoap-plugin-lame
      - liquidsoap-plugin-mad
      - liquidsoap-plugin-vorbis
      - python3-gst-1.0
      - silan
      - gcc
      - gir1.2-gtk-3.0
      - python3-gi
      - python3-gi-cairo
      - python-cairo
      - pkg-config
      - libcairo2-dev

jobs:
  include:
#    - language: php
#      php: 7.3
#      stage: test
#    - language: php
#      php: 7.2
#      stage: test
    - language: php
      php: 7.0
      stage: test
    - language: php
      php: 5.6
      stage: test
#    - language: python
#      python: 3.8
#      stage: test
#    - language: python
#      python: 3.6
#      stage: test
    - language: python
      python: 3.5
      stage: test
    - stage: deploy
      addons:
        apt:
          packages:
            dos2unix
      script:
        ./travis/release.sh
      deploy:
        - provider: releases
          token: $GITHUB_TOKEN
          file: build/libretime-*.tar.gz
          edge: true
          on:
            tags: true
  allow_failures:
    # https://github.com/LibreTime/libretime/issues/779
#    - language: php
#      php: 7.3
#    - language: php
#      php: 7.2
    # Ubuntu Bionic cloud image uses Python 3.6.9
#    - language: python
#      python: 3.8
    # https://github.com/LibreTime/libretime/issues/1041
#    - language: python
#      python: 3.5
    - language: php
      php: 5.6

install: ./travis/install.sh
before_script:
- psql -c 'CREATE DATABASE libretime;' -U postgres
- psql -c "CREATE USER libretime WITH PASSWORD 'libretime';" -U postgres
- psql -c 'GRANT CONNECT ON DATABASE libretime TO libretime;' -U postgres
- psql -c 'ALTER USER libretime CREATEDB;' -U postgres
- mkdir -p /tmp/log/libretime
script: ./travis/test.sh