Skip to content

Commit

Permalink
Significantly speed up travis and make runs
Browse files Browse the repository at this point in the history
- Inline ci/travis.sh into .travis.yml
- Use two go test steps instead of once for speed up
- Drop the whitelist and use all the packages as listed from $(go list ./...).
  This removes the need to do bookeeping in both .travis.yml and Makefile during
  refactoring.
- Trimmed the Makefile significantly. Removed "go test -i" as while this is
  extremely helpful when cross compiling, it doesn't help when compiling for the
  host.
- Added deps as a phony target, made this step faster. I'm not sure of the
  usefulness of this step though and would recommend to remove it.
- 'make examples' is currently broken so I didn't add it to .travis.yml.

I experimented a bit on travis with go test on another similar project, timings
for the go test step only:
- Using both -race and -coverprofile with the loop over $(go list ./...) took
  190s
- Using -coverprofile alone with the loop over $(go list ./...) took 10~11s
- Using -race ./... took 5s

It means that using one after the other takes 16~17s while running with both
flags takes 190s. A 91% speedup. Add my previous commit that cut off the test
runtime by half, the total speed will be appreciable.
  • Loading branch information
maruel committed Mar 25, 2017
1 parent 1a3c52c commit 55eb298
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 47 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ before_script:
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
script:
- ./ci/travis.sh
- bash -c 'set -e; echo "" > coverage.txt; for d in $(go list ./...); do go test -covermode=count -coverprofile=p.out $d; if [ -f p.out ]; then cat p.out >> coverage.txt; rm p.out; fi; done'
- go test -race ./...
after_success:
- bash <(curl -s https://codecov.io/bash)
branches:
Expand Down
52 changes: 25 additions & 27 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
PACKAGES := gobot gobot/api gobot/drivers/gpio gobot/drivers/aio gobot/drivers/i2c gobot/platforms/firmata/client gobot/platforms/intel-iot/edison gobot/platforms/intel-iot/joule gobot/platforms/parrot/ardrone gobot/platforms/parrot/bebop gobot/platforms/parrot/minidrone gobot/platforms/sphero/ollie gobot/platforms/sphero/bb8 gobot/sysfs $(shell ls ./platforms | sed -e 's/^/gobot\/platforms\//')
.PHONY: test cover robeaux examples
.PHONY: test cover robeaux examples deps

test:
go test -i ./...
for package in $(PACKAGES) ; do \
go test gobot.io/x/$$package ; \
done ; \
go test ./...

cover:
echo "" > profile.cov
go test -i ./...
for package in $(PACKAGES) ; do \
go test -covermode=count -coverprofile=tmp.cov gobot.io/x/$$package ; \
cat tmp.cov >> profile.cov ; \
rm tmp.cov ; \
done ; \
for package in $$(go list ./...) ; do \
go test -covermode=count -coverprofile=tmp.cov $$package ; \
if [ -f tmp.cov ]; then \
cat tmp.cov >> profile.cov ; \
rm tmp.cov ; \
fi ; \
done

robeaux:
ifeq (,$(shell which go-bindata))
Expand Down Expand Up @@ -42,18 +39,19 @@ examples:
done ; \

deps:
go get -d -v github.com/bmizerany/pat
go get -d -v github.com/hybridgroup/go-ardrone/client
go get -d -v github.com/mgutz/logxi/v1
go get -d -v golang.org/x/sys/unix
go get -d -v github.com/currantlabs/ble
go get -d -v github.com/tarm/serial
go get -d -v github.com/veandco/go-sdl2/sdl
go get -d -v golang.org/x/net/websocket
go get -d -v github.com/eclipse/paho.mqtt.golang
go get -d -v github.com/nats-io/nats
go get -d -v github.com/lazywei/go-opencv
go get -d -v github.com/donovanhide/eventsource
go get -d -v github.com/hashicorp/go-multierror
go get -d -v github.com/sigurn/crc8
go get -d -v github.com/codegangsta/cli
go get -d -v \
github.com/bmizerany/pat \
github.com/codegangsta/cli \
github.com/currantlabs/ble \
github.com/donovanhide/eventsource \
github.com/eclipse/paho.mqtt.golang \
github.com/hashicorp/go-multierror \
github.com/hybridgroup/go-ardrone/client \
github.com/lazywei/go-opencv \
github.com/mgutz/logxi/v1 \
github.com/nats-io/nats \
github.com/sigurn/crc8 \
github.com/tarm/serial \
github.com/veandco/go-sdl2/sdl \
golang.org/x/net/websocket \
golang.org/x/sys/unix
19 changes: 0 additions & 19 deletions ci/travis.sh

This file was deleted.

0 comments on commit 55eb298

Please sign in to comment.