Commit e66e1443 authored by Adam Reese's avatar Adam Reese Committed by GitHub

Merge pull request #940 from adamreese/feat/coveralls

feat(ci): setup test coverage reports with coveralls.io
parents b080e944 ebffaadb
...@@ -22,13 +22,22 @@ IFS=$'\n\t' ...@@ -22,13 +22,22 @@ IFS=$'\n\t'
HELM_ROOT="${BASH_SOURCE[0]%/*}/.." HELM_ROOT="${BASH_SOURCE[0]%/*}/.."
cd "$HELM_ROOT" cd "$HELM_ROOT"
case "${CIRCLE_NODE_INDEX-0}" in run_unit_test() {
0) if [[ "${CIRCLE_BRANCH-}" == "master" ]]; then
echo "Running 'make test-unit'" echo "Running unit tests with coverage'"
./scripts/coverage.sh --coveralls
else
echo "Running unit tests'"
make test-unit make test-unit
;; fi
1) }
run_style_check() {
echo "Running 'make test-style'" echo "Running 'make test-style'"
make test-style make test-style
;; }
case "${CIRCLE_NODE_INDEX-0}" in
0) run_unit_test ;;
1) run_style_check ;;
esac esac
...@@ -16,22 +16,35 @@ ...@@ -16,22 +16,35 @@
set -euo pipefail set -euo pipefail
COVERDIR=${COVERDIR:-.coverage} covermode=${COVERMODE:-atomic}
COVERMODE=${COVERMODE:-atomic} coverdir=$(mktemp -d /tmp/coverage.XXXXXXXXXX)
PACKAGES=($(go list $(glide novendor))) profile="${coverdir}/cover.out"
if [[ ! -d "$COVERDIR" ]]; then hash goveralls 2>/dev/null || go get github.com/mattn/goveralls
mkdir -p "$COVERDIR"
fi
echo "mode: ${COVERMODE}" > "${COVERDIR}/coverage.out" generate_cover_data() {
for d in $(godir) ; do
local output="${coverdir}/${d//\//-}.cover"
go test -coverprofile="${output}" -covermode="$covermode" "$d"
done
for d in "${PACKAGES[@]}"; do echo "mode: $covermode" >"$profile"
go test -coverprofile=profile.out -covermode="$COVERMODE" "$d" grep -h -v "^mode:" "$coverdir"/*.cover >>"$profile"
if [ -f profile.out ]; then }
sed "/mode: $COVERMODE/d" profile.out >> "${COVERDIR}/coverage.out"
rm profile.out push_to_coveralls() {
fi goveralls -coverprofile="${profile}" -service=circle-ci
done }
generate_cover_data
go tool cover -func "${profile}"
case "$1" in
--html)
go tool cover -html "${profile}"
;;
--coveralls)
push_to_coveralls
;;
esac
go tool cover -html "${COVERDIR}/coverage.out" -o "${COVERDIR}/coverage.html"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment