machine:
  services:
    - docker

dependencies:
  override:
    - docker build -t test-integration-frontend:latest .
    - >
      docker run
      -e "APIKEY=${APIKEY}"
      -e "CIRCLE_PROJECT_REPONAME=${CIRCLE_PROJECT_REPONAME}"
      -e "CIRCLE_BUILD_NUM=${CIRCLE_BUILD_NUM}"
      -e "IMAGE=${IMAGE:-coreos-beta}"
      --name=test-integration-frontend-init
      test-integration-frontend:latest /initialize.sh
    - docker commit test-integration-frontend-init test-integration-frontend:latest

test:
  override:
    - docker run --name=test-integration-frontend test-integration-frontend:latest /run_tests.sh
  post:
    - docker run --name=DUMP-test-integration-frontend test-integration-frontend:latest vagrant ssh -- sudo journalctl
    - docker run --name=DESTROY-test-integration-frontend test-integration-frontend:latest vagrant destroy -f
    # TODO: Collect container as an asset?

notify:
  webhooks:
    - url: $WEBHOOK_URL

machine:
  services:
    - docker

dependencies:
  override:
    - docker build -t test-integration-frontend:latest .
    - >
      docker run
      -e "APIKEY=${APIKEY}"
      -e "CIRCLE_PROJECT_REPONAME=${CIRCLE_PROJECT_REPONAME}"
      -e "CIRCLE_BUILD_NUM=${CIRCLE_BUILD_NUM}"
      -e "IMAGE=${IMAGE:-coreos-beta}"
      --name=test-integration-frontend-init
      test-integration-frontend:latest /initialize.sh
    - docker commit test-integration-frontend-init test-integration-frontend:latest

test:
  override:
    - docker run --name=test-integration-frontend test-integration-frontend:latest /run_tests.sh
  post:
    - docker run test-integration-frontend:latest ssh-keygen -l -f /.ssh/id_rsa | awk '{ print $2 }' > ~/sshid
    - docker run --name=DUMP-test-integration-frontend test-integration-frontend:latest vagrant ssh -- sudo journalctl
    - docker run --name=DESTROY-test-integration-frontend test-integration-frontend:latest vagrant destroy -f
    - 'curl -f -X DELETE -H "Content-Type: application/json" -H "Authorization: Bearer ${APIKEY}" https://api.digitalocean.com/v2/account/keys/$(cat ~/sshid)'
    # TODO: Collect container as an asset?

notify:
  webhooks:
    - url: $WEBHOOK_URL

Remove SSH Key from Digital Oceans key ring after the test machine was destroyed.
Remove SSH Key from Digital Oceans key ring after the test machine was destroyed.
