language: python

# Cache dependencies between builds
cache: pip

python:
  - "3.6"

services:
  - postgresql

addons:
  # Django 2.1+ requires PostgreSQL 9.4+
  postgresql: "9.4"

install:
  - pip install -r requirements.txt
  # Supervisor < 4 does not support python 3 but Supervisor 4 is not
  # released to PyPI yet. => Install from Github
  - pip install git+https://github.com/Supervisor/supervisor.git

before_script:
  # Create local PostgreSQL database
  # NOTE: the database name (here 'oser_backend_db') must match the name
  # in one of these DATABASE_URL setting:
  # - the one set up in TravisCI environment variables
  # - the one set up in settings/default.py
  - psql -c 'create database oser_backend_db;' -U postgres

  # Apply database migrations
  - python manage.py migrate

script:
  - python manage.py test
