From ed323322040f5a1ab389852a65ce85ac62ccb1de Mon Sep 17 00:00:00 2001 From: "J.C. Jones" Date: Thu, 14 May 2015 11:35:13 -0700 Subject: [PATCH] First pass at build speedups. Feel free to use `make -j9` on your desktops! --- .gitignore | 1 + .travis.yml | 8 +------- Makefile | 29 ++++++++++++++++++++++++++- test.sh | 57 ++++++++++++++++++++++++++++++++--------------------- 4 files changed, 64 insertions(+), 31 deletions(-) diff --git a/.gitignore b/.gitignore index f53f35677..ee612ec5e 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ # Folders _obj _test +bin # Architecture specific extensions/prefixes *.[568vq] diff --git a/.travis.yml b/.travis.yml index 5ea930ade..060ef10fc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,11 +14,5 @@ before_install: - go get github.com/modocache/gover script: - - go build cmd/activity-monitor/main.go - - 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 + - make -j4 # Travis has 2 cores per build instance - bash test.sh diff --git a/Makefile b/Makefile index 86624b29c..d23629236 100644 --- a/Makefile +++ b/Makefile @@ -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/ + +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) \ No newline at end of file diff --git a/test.sh b/test.sh index b3aeb8796..9c3689b27 100755 --- a/test.sh +++ b/test.sh @@ -1,20 +1,31 @@ #!/bin/bash # Run all tests and coverage checks. Called from Travis automatically, also # 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)) fi FAILURE=0 +TESTDIRS="analysis \ + ca \ + core \ + log \ + policy \ + ra \ + rpc \ + sa \ + test \ + va \ + wfe" + # cmd + # Godeps + run() { + echo "$*" $* || 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 # 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 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 + # 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 # contact the server and exits with non-zero status, but we don't want to # 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 exit ${FAILURE}