Merge pull request #197 from letsencrypt/speedup_build_and_tests

First pass at build speedups.
This commit is contained in:
Jacob Hoffman-Andrews 2015-05-14 12:05:05 -07:00
commit 672f0b1fbe
4 changed files with 64 additions and 31 deletions

1
.gitignore vendored
View File

@ -6,6 +6,7 @@
# Folders # Folders
_obj _obj
_test _test
bin
# Architecture specific extensions/prefixes # Architecture specific extensions/prefixes
*.[568vq] *.[568vq]

View File

@ -14,11 +14,5 @@ before_install:
- go get github.com/modocache/gover - go get github.com/modocache/gover
script: script:
- go build cmd/activity-monitor/main.go - make -j4 # Travis has 2 cores per build instance
- go build cmd/boulder/main.go
- go build cmd/boulder-ca/main.go
- go build cmd/boulder-ra/main.go
- go build cmd/boulder-sa/main.go
- go build cmd/boulder-va/main.go
- go build cmd/boulder-wfe/main.go
- bash test.sh - bash test.sh

View File

@ -1,2 +1,29 @@
# This is an empty Makefile to trick Travis into not running 'go get' for our # This Makefile also tricks Travis into not running 'go get' for our
# build. See http://docs.travis-ci.com/user/languages/go/ # build. See http://docs.travis-ci.com/user/languages/go/
OBJDIR = ./bin
OBJECTS = activity-monitor \
boulder \
boulder-ca \
boulder-ra \
boulder-sa \
boulder-va \
boulder-wfe
.PHONY: all build
all: build
build: $(OBJECTS)
pre:
mkdir -p $(OBJDIR)
go install ./Godeps/_workspace/src/github.com/mattn/go-sqlite3
# Compile each of the binaries
$(OBJECTS): pre
go build -o ./bin/$@ cmd/$@/main.go
clean:
rm -f $(OBJDIR)/*
rmdir $(OBJDIR)

57
test.sh
View File

@ -1,20 +1,31 @@
#!/bin/bash #!/bin/bash
# Run all tests and coverage checks. Called from Travis automatically, also # Run all tests and coverage checks. Called from Travis automatically, also
# suitable to run manually. See list of prerequisite packages in .travis.yml # suitable to run manually. See list of prerequisite packages in .travis.yml
if type realpath 2>&1 >/dev/null; then if type realpath >/dev/null 2>&1 ; then
cd $(realpath $(dirname $0)) cd $(realpath $(dirname $0))
fi fi
FAILURE=0 FAILURE=0
TESTDIRS="analysis \
ca \
core \
log \
policy \
ra \
rpc \
sa \
test \
va \
wfe"
# cmd
# Godeps
run() { run() {
echo "$*"
$* || FAILURE=1 $* || FAILURE=1
} }
doTest() {
local dir=$1
run go test -covermode=count -coverprofile=${dir}.coverprofile ./${dir}/
}
# Path for installed go package binaries. If yours is different, override with # Path for installed go package binaries. If yours is different, override with
# GOBIN=/my/path/to/bin ./test.sh # GOBIN=/my/path/to/bin ./test.sh
@ -28,28 +39,28 @@ run go vet -x ./...
# Ensure SQLite is installed so we don't recompile it each time # Ensure SQLite is installed so we don't recompile it each time
go install ./Godeps/_workspace/src/github.com/mattn/go-sqlite3 go install ./Godeps/_workspace/src/github.com/mattn/go-sqlite3
# All the subdirectories
doTest analysis
doTest ca
#doTest cmd
doTest core
doTest log
doTest policy
doTest ra
doTest rpc
doTest sa
doTest test
doTest va
#doTest vendor
doTest wfe
[ -e $GOBIN/gover ] && run $GOBIN/gover
if [ "${TRAVIS}" == "true" ] ; then if [ "${TRAVIS}" == "true" ] ; then
# Run each test by itself for Travis, so we can get coverage
for dir in ${TESTDIRS}; do
run go test -covermode=count -coverprofile=${dir}.coverprofile ./${dir}/
done
# Gather all the coverprofiles
[ -e $GOBIN/gover ] && run $GOBIN/gover
# We don't use the run function here because sometimes goveralls fails to # We don't use the run function here because sometimes goveralls fails to
# contact the server and exits with non-zero status, but we don't want to # contact the server and exits with non-zero status, but we don't want to
# treat that as a failure. # treat that as a failure.
$GOBIN/goveralls -coverprofile=gover.coverprofile -service=travis-ci [ -e $GOBIN/goveralls ] && $GOBIN/goveralls -coverprofile=gover.coverprofile -service=travis-ci
else
# Run all the tests together if local, for speed
dirlist=""
for dir in ${TESTDIRS}; do
dirlist="${dirlist} ./${dir}/"
done
run go test ${dirlist}
fi fi
exit ${FAILURE} exit ${FAILURE}