diff --git a/.travis.yml b/.travis.yml index ae47f007749..b2ccc9a0fb7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,14 +1,10 @@ language: go go: - - 1.4 + - 1.4 sudo: false -services: - - redis-server - - elasticsearch - addons: apt: packages: @@ -17,14 +13,24 @@ addons: - geoip-database before_install: - - ln -s $TRAVIS_BUILD_DIR $HOME/gopath/src/packetbeat + # Redo the travis setup but with the elastic/packetbeat path. This is needed so the package path is correct + - mkdir -p $HOME/gopath/src/github.com/elastic/packetbeat + - rsync -az ${TRAVIS_BUILD_DIR}/ $HOME/gopath/src/github.com/elastic/packetbeat/ + - export TRAVIS_BUILD_DIR=$HOME/gopath/src/github.com/elastic/packetbeat + - cd $HOME/gopath/src/github.com/elastic/packetbeat install: - - make + - make -script: make testlong +script: + - make testlong notifications: email: - tudor@elastic.co - monica@elastic.co + +after_success: + # Copy profile.cov to coverage.txt because codecov.io requires this file + - cp profile.cov coverage.txt + - bash <(curl -s https://codecov.io/bash) \ No newline at end of file diff --git a/Makefile b/Makefile index 67436d108e9..99ba0e183a2 100644 --- a/Makefile +++ b/Makefile @@ -93,15 +93,18 @@ autotest: .PHONY: testlong testlong: go vet ./... - $(GODEP) go test ./... + make cover make -C tests test .PHONY: cover cover: + # gotestcover is needed to fetch coverage for multiple packages + go get github.com/pierrre/gotestcover + GOPATH=$(shell $(GODEP) path):$(GOPATH) gotestcover -coverprofile=profile.cov -covermode=count github.com/elastic/packetbeat/... mkdir -p cover - GOPATH=$(shell $(GODEP) path):$(GOPATH) ./scripts/coverage.sh $(GODEP) go tool cover -html=profile.cov -o cover/coverage.html + .PHONY: benchmark benchmark: $(GODEP) go test -short -bench=. ./... diff --git a/scripts/coverage.sh b/scripts/coverage.sh deleted file mode 100755 index a8872e1b9f4..00000000000 --- a/scripts/coverage.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/sh - -# -# Works around the fact that go tool doesn't support the recursive -# flag when using the coverage flag. -# Taken from here: https://gist.github.com/hailiang/0f22736320abe6be71ce -# Called from the Makefile. - -echo "mode: count" > profile.cov - -# Standard go tooling behavior is to ignore dirs with leading underscors -for dir in $(find . -maxdepth 10 -not -path './.git*' -not -path '*/_*' -type d); -do -if ls $dir/*.go &> /dev/null; then - go test -covermode=count -coverprofile=$dir/profile.tmp $dir - if [ -f $dir/profile.tmp ] - then - cat $dir/profile.tmp | tail -n +2 >> profile.cov - rm $dir/profile.tmp - fi -fi -done