Skip to content

Commit

Permalink
Merge branch 'feature/coveralls'
Browse files Browse the repository at this point in the history
Closes #61
  • Loading branch information
dansimau committed Jan 25, 2016
2 parents a948bbc + 438cd75 commit b6ffc82
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 2 deletions.
18 changes: 17 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,25 @@
language: go
go:
- 1.5

before_install:
- go get -u github.com/axw/gocov/gocov
- go get -u github.com/mattn/goveralls
- go get golang.org/x/tools/cmd/cover

before_script:
- ./scripts/travis/get-thrift.sh
- ./scripts/travis/get-thrift-gen.sh
- go get github.com/vektra/mockery/.../

env:
- RUN="make test_ci"
- RUN="test/update-coveralls"

matrix:
allow_failures:
- env: RUN="test/update-coveralls"
fast_finish: true

script:
- make test_ci
- test/travis
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ringpop-go [![Build Status](https://travis-ci.org/uber/ringpop-go.svg?branch=master)](https://travis-ci.org/uber/ringpop-go)
ringpop-go [![Build Status](https://travis-ci.org/uber/ringpop-go.svg?branch=master)](https://travis-ci.org/uber/ringpop-go) [![Coverage Status](https://coveralls.io/repos/uber/ringpop-go/badge.svg?branch=master&service=github)](https://coveralls.io/github/uber/ringpop-go?branch=master)
==========

Ringpop is a library that brings cooperation and coordination to distributed
Expand Down
25 changes: 25 additions & 0 deletions test/travis
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash
#
# Run Travis CI scripts from an environment variable.
#
# This script evaluates and executes the command string from the RUN
# environment variable.
#
# It allows you to execute different commands in a test matrix on Travis CI,
# based on env vars in your .travis.yml.
#
declare RUN_DEFAULT=""

# Perform default action if none specified
if [ -z "$RUN" ]; then
RUN=$RUN_DEFAULT
fi

# Exit with error if there's nothing to do
if [ -z "$RUN" ]; then
echo "ERROR: No actions specified and no default actions. Exiting." >&2
exit 1
fi

# Execute the command string; echo the commands as they run
eval "set -x; $RUN"
39 changes: 39 additions & 0 deletions test/update-coveralls
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/bash
#
# Send coverage data to coveralls.io
#
# `go test -coverprofile=` only supports generating a coverage profile for one
# package at a time. This script combines coverage data from multiple packages
# and then sends the coverage data to coveralls.io
#
echo "mode: set" > acc.out
FAIL=0

packages="$(find . -type d -maxdepth 3 \
! -path './.git*' \
! -path '*/_*' \
! -path './Godeps*' \
! -path './test*' \
)"

# Standard go tooling behavior is to ignore dirs with leading underscores
for dir in $packages;
do
if ls $dir/*.go &> /dev/null; then
go test -coverprofile=profile.out $dir || FAIL=$?
if [ -f profile.out ]
then
cat profile.out | grep -v "mode: set" | grep -v "mocks.go" >> acc.out
rm profile.out
fi
fi
done

# Failures have incomplete results, so don't send
if [ "$FAIL" -eq 0 ]; then
goveralls -service=travis-ci -v -coverprofile=acc.out
fi

rm -f acc.out

exit $FAIL

0 comments on commit b6ffc82

Please sign in to comment.