clone:
    hg:
        image: plugins/hg

pipeline:
    tox:
        image: ${IMAGE}
        environment:
            - CFLAGS=-O0
            - DB_CACHE=/cache
            - TOX_TESTENV_PASSENV=CFLAGS DB_CACHE
            - POSTGRESQL_URI=postgresql://postgres@postgresql:5432/
        commands:
            - pip install tox
            - tox -e "${TOXENV}-${DATABASE}"
        volumes:
            - cache:/root/.cache

services:
    postgresql:
        image: postgres
        when:
            matrix:
                DATABASE: postgresql

matrix:
    include:
        - IMAGE: python:3.4
          TOXENV: py34
          DATABASE: sqlite
        - IMAGE: python:3.4
          TOXENV: py34
          DATABASE: postgresql
        - IMAGE: python:3.5
          TOXENV: py35
          DATABASE: sqlite
        - IMAGE: python:3.5
          TOXENV: py35
          DATABASE: postgresql
        - IMAGE: python:3.6
          TOXENV: py36
          DATABASE: sqlite
        - IMAGE: python:3.6
          TOXENV: py36
          DATABASE: postgresql
        - IMAGE: python:3.7
          TOXENV: py37
          DATABASE: sqlite
        - IMAGE: python:3.7
          TOXENV: py37
          DATABASE: postgresql
