# Config file for automatic testing at travis-ci.org

sudo: true

dist: trusty

services:
  - docker

env:
  global:
    - DOCKER_REPO_URL=quay.io
    - DOCKER_REPO_OWNER=centerforopenscience
    - DOCKER_REPO_NAME=lookit-api
    - DOCKER_BRANCH=${TRAVIS_BRANCH/\//-}
    - DOCKER_IMAGE_URL=$DOCKER_REPO_URL/$DOCKER_REPO_OWNER/$DOCKER_REPO_NAME

cache:
  directories:
    - $HOME/docker

jobs:
  include:
    - stage: Build & Test
      script:
        - docker pull $DOCKER_IMAGE_URL:$TRAVIS_COMMIT || docker pull $DOCKER_IMAGE_URL:$DOCKER_BRANCH || true
        - docker build
            --cache-from $DOCKER_IMAGE_URL:$TRAVIS_COMMIT --cache-from $DOCKER_IMAGE_URL:$DOCKER_BRANCH
            --build-arg GIT_COMMIT=$TRAVIS_COMMIT --build-arg GIT_TAG=$TRAVIS_TAG
            --pull -t $DOCKER_IMAGE_URL:$TRAVIS_COMMIT .
        - docker run -d --name pg postgres:9.6
        - docker exec -i pg /bin/bash -c 'until pg_isready; do sleep 1; done'
        - docker run --rm -it --link pg --env DB_HOST=pg $DOCKER_IMAGE_URL:$TRAVIS_COMMIT python manage.py test

# Config file for automatic testing at travis-ci.org

sudo: true

dist: trusty

services:
  - docker

env:
  global:
    - DOCKER_REPO_URL=quay.io
    - DOCKER_REPO_OWNER=lookit
    - DOCKER_REPO_NAME=lookit-api
    - DOCKER_BRANCH=${TRAVIS_BRANCH/\//-}
    - DOCKER_IMAGE_URL=$DOCKER_REPO_URL/$DOCKER_REPO_OWNER/$DOCKER_REPO_NAME

cache:
  directories:
    - $HOME/docker

jobs:
  include:
    - stage: Build & Test
      script:
        - docker pull $DOCKER_IMAGE_URL:$TRAVIS_COMMIT || docker pull $DOCKER_IMAGE_URL:$DOCKER_BRANCH || true
        - docker build
            --cache-from $DOCKER_IMAGE_URL:$TRAVIS_COMMIT --cache-from $DOCKER_IMAGE_URL:$DOCKER_BRANCH
            --build-arg GIT_COMMIT=$TRAVIS_COMMIT --build-arg GIT_TAG=$TRAVIS_TAG
            --pull -t $DOCKER_IMAGE_URL:$TRAVIS_COMMIT .
        - docker run -d --name pg postgres:9.6
        - docker exec -i pg /bin/bash -c 'until pg_isready; do sleep 1; done'
        - docker run --rm -it --link pg --env DB_HOST=pg $DOCKER_IMAGE_URL:$TRAVIS_COMMIT python manage.py test

Switch repo owner to lookit for Travis build
Switch repo owner to lookit for Travis build
