1#!bash
2
3ACME_DIR="$(pwd)"
4
5# Fetch boulder and dependencies.
6echo travis_fold:start:get-boulder
7
8NEEDED_LIBS=
9if [ -e "$HOME/tcache/gopath.tar" ]; then
10  cd "$GOPATH"
11  tar xvf "$HOME/tcache/gopath.tar" || exit 1
12  cd "$ACME_DIR"
13else
14  NEEDED_LIBS="github.com/jsha/listenbuddy github.com/tcnksm/ghr github.com/hlandau/gox bitbucket.org/liamstask/goose/cmd/goose"
15fi
16
17export CGO_LDFLAGS_ALLOW=-Wl,--no-as-needed
18
19time travis_retry go get -v \
20  github.com/letsencrypt/boulder/... \
21  $NEEDED_LIBS
22echo travis_fold:end:get-boulder
23
24# Setup DB.
25cd $GOPATH/src/github.com/letsencrypt/boulder
26echo travis_fold:start:setup-boulder
27time ./test/create_db.sh || exit 2
28
29# Setup AMQP.
30#time go run cmd/rabbitmq-setup/main.go -server amqp://localhost || exit 4
31
32# Patch config, startup detection.
33patch -t -p1 < "$ACME_DIR/.travis/boulder.patch" || exit 3
34echo travis_fold:end:setup-boulder
35
36# Start boulder.
37export OBJDIR="$GOPATH/src/github.com/letsencrypt/boulder/bin"
38{ ./start.py &> boulder.log || cat boulder.log ; } &
39START_PID=$$
40
41# Wait for boulder to come up.
42echo Waiting for boulder to come up...
43while ((1)); do
44  kill -0 "$START_PID" || break
45  [ -e /tmp/boulder-has-started ] && break
46
47  sleep 1
48done
49echo Boulder up.
50echo ----------------------------------------------------------------
51
52# Run tests.
53cd "$ACME_DIR"
54
55echo travis_fold:start:go-tests
56time go test -v -tags=integration ./...
57RESULT=$?
58echo travis_fold:end:go-tests
59
60echo travis_fold:start:boulder-log
61echo Dumping boulder log
62cat $GOPATH/src/github.com/letsencrypt/boulder/boulder.log
63echo travis_fold:end:boulder-log
64
65echo Done with exit code $RESULT
66if [ "$RESULT" != "0" ]; then
67  exit $RESULT
68fi
69
70# Crosscompilation failures are rare now and crosscompiling takes a long time
71# so only do it for tags.
72if [ -n "$TRAVIS_TAG" ]; then
73  time source ./.travis/crosscompile
74fi
75
76# No point stopping boulder, travis will do it.
77# Don't exit here, we need after_success to run and this script is sourced.
78