dist: xenial

services:
  - postgresql

env:
  global:
    - ENVIRONMENT=testing
    - LIBRETIME_LOG_DIR=/tmp/log/libretime

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

jobs:
  include:
    - language: php
      php: 7.3
      stage: test
    - language: php
      php: 7.2
      stage: test
    - language: php
      php: 7.1
      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.7
      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
    - language: php
      php: 7.1
    # https://github.com/LibreTime/libretime/issues/1041
    - language: python
      python: 3.5

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