Skip to content

Instantly share code, notes, and snippets.

@emersion
Last active August 28, 2016 11:25
Show Gist options
  • Save emersion/49d4dda535497002639626bd9e16480c to your computer and use it in GitHub Desktop.
Save emersion/49d4dda535497002639626bd9e16480c to your computer and use it in GitHub Desktop.
Codecov for all Go packages in a repo
#!/usr/bin/env bash
set -e
echo "" > coverage.txt
retval=0
for d in $(find . -maxdepth 10 \( -path ./vendor -o -path './.*' -o -name '_*' \) -prune -o -type d -print); do
if ls $d/*.go &> /dev/null; then
go test -v -coverprofile=profile.out -covermode=atomic $d
pkgretval=$?
if [ $pkgretval -ne 0 ]; then
retval=$pkgretval
fi
if [ -f profile.out ]; then
cat profile.out >> coverage.txt
rm profile.out
fi
fi
done
exit $retval
@emersion
Copy link
Author

emersion commented Jun 8, 2016

How to use: add this to the script section of your .travis.yml

bash <(curl -sL https://gist.github.com/emersion/49d4dda535497002639626bd9e16480c/raw/codecov-go.sh)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment