language: python
dist: trusty
sudo: required

services:
  - docker

before_install:
  - sudo apt-add-repository 'deb http://archive.ubuntu.com/ubuntu trusty-backports universe'
  - sudo apt-get update -qq
  - sudo apt-get install -y -o Dpkg::Options::="--force-confold" --force-yes docker-engine

install:
  # Install the latest Ansible Container and Ansible
  - pip install git+https://github.com/ansible/ansible-container.git
  - pip install ansible

script:
  # Make sure docker is functioning
  - docker version
  - docker-compose version
  - docker info

  # Create an Ansible Container project
  - mkdir -p tests
  - cd tests
  - ansible-container init

  # Install the role into the project
  - echo "Installing and testing git+https://github.com/${TRAVIS_REPO_SLUG},${TRAVIS_COMMIT}"
  - ansible-container install git+https://github.com/${TRAVIS_REPO_SLUG},${TRAVIS_COMMIT}

  # Build the service image
  - ansible-container build

  # Start the service
  - ansible-container run -d
  - docker ps

  # Run tests
  - ansible-playbook test.yml

notifications:
  email: false
  webhooks: https://galaxy.ansible.com/api/v1/notifications/

