#!/bin/bash
# vim: set ft=sh

set -e

export GOPATH=${PWD}/concourse
export PATH=${PWD}/concourse/bin:$PATH

go install github.com/onsi/ginkgo/ginkgo

cp bosh-cli/bosh* /usr/local/bin/bosh
chmod +x /usr/local/bin/bosh

eval $(ssh-agent)
ssh-add <(echo "$BOSH_KEY")

export CONCOURSE_RELEASE_VERSION="$(cat concourse-release/version)"
export GARDEN_RUNC_RELEASE_VERSION="$(cat garden-runc-release/version)"
export STEMCELL_VERSION="$(cat stemcell/version)"

bosh upload-release concourse-release/*.tgz
bosh upload-release garden-runc-release/*.tgz
bosh upload-stemcell stemcell/*.tgz

cd concourse/src/github.com/concourse/topgun/
ginkgo -nodes=4 -r -race -keepGoing -skip="$SKIP" "$@"
