machine:
  environment:
    GOPATH: $HOME/.go_workspace
    REPO: ${GOPATH}/src/github.com/${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME}
    DOCKER_VERSION: 1.9.1
    DOCKER_MACHINE_VERSION: 0.6.0
    ERIS_CLI_BRANCH: develop
    GO15VENDOREXPERIMENT: 1
  post:
    - git config --global user.email "billings@erisindustries.com"
    - git config --global user.name "Billings the Bot"
    - rm -rf ${GOPATH%%:*}/src/github.com/${CIRCLE_PROJECT_USERNAME}
    - mkdir -p ${GOPATH%%:*}/src/github.com/${CIRCLE_PROJECT_USERNAME}
    - cp -r ${HOME}/${CIRCLE_PROJECT_REPONAME} ${GOPATH%%:*}/src/github.com/${CIRCLE_PROJECT_USERNAME}/.

dependencies:
  override:
    - sudo curl -L -o /usr/bin/docker http://s3-external-1.amazonaws.com/circle-downloads/docker-$DOCKER_VERSION-circleci; sudo chmod 0775 /usr/bin/docker; sudo usermod -a -G docker $USER; true
    - sudo service docker start
    - sudo curl -sSL -o /usr/local/bin/docker-machine https://github.com/docker/machine/releases/download/v$DOCKER_MACHINE_VERSION/docker-machine-linux-x86_64; sudo chmod 0755 /usr/local/bin/docker-machine
    - "go get github.com/eris-ltd/eris-cli/cmd/eris; cd ${GOPATH%%:*}/src/github.com/eris-ltd/eris-cli && git checkout origin/$ERIS_CLI_BRANCH && go install ./cmd/eris"
    - "sudo apt-get update && sudo apt-get install -y libgmp3-dev"

test:
  pre:
    - go get github.com/Masterminds/glide
    - cd $REPO && glide install
    # Install eris-db cmd for tests
    - cd $REPO && go install ./cmd/eris-db
  override:
    # We only wish to test our packages not vendored ones
    - echo "Running unit tests..."
    - cd $REPO && glide novendor | xargs go test -tags integration
    - echo "Running integration tests..."
    # - cd $REPO && "tests/circle_test.sh | tee $CIRCLE_ARTIFACTS/output.log; test ${PIPESTATUS[0]} -eq 0"

deployment:
  master:
    branch: master
    commands:
      - tests/build_tool.sh
      - docker login -e $DOCKER_EMAIL -u $DOCKER_USER -p $DOCKER_PASS quay.io
      - docker push quay.io/eris/erisdb
  develop:
    branch: develop
    commands:
      - tests/build_tool.sh
      - docker login -e $DOCKER_EMAIL -u $DOCKER_USER -p $DOCKER_PASS quay.io
      - docker push quay.io/eris/erisdb
