Skip to content

Commit 3e5d62d

Browse files
committed
Fail CI if test coverage is lacking
1 parent 51a2ebc commit 3e5d62d

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

script/cibuild

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ fi
6969
if [ "$RSPEC_TEST" = "true" ]; then
7070
SAVED_PATH="$PATH"
7171
RSPEC_EXITCODE="0"
72+
COVERAGE_EXITCODE="0"
7273
for pv in $PUPPET_VERSIONS ; do
7374
export PUPPET_VERSION="$pv"
7475

@@ -106,6 +107,11 @@ if [ "$RSPEC_TEST" = "true" ]; then
106107

107108
# Quick coverage report
108109
cat "$DIR/coverage/coverage.txt"
110+
if grep -q "100% test coverage. You're all set, friend" "$DIR/coverage/coverage.txt"; then
111+
:
112+
else
113+
COVERAGE_EXITCODE=1
114+
fi
109115
echo ""
110116

111117
# To avoid travis getting hung if it gets confused, we'll run each of these
@@ -136,11 +142,16 @@ if [ "$RSPEC_TEST" = "true" ]; then
136142
rm -f "${DIR}/.puppet_version"
137143
else
138144
RSPEC_EXITCODE=-1
145+
COVERAGE_EXITCODE=-1
139146
echo ""
140147
fi
141148

142149
# Finish off script
143150
echo "Finished script/cibuild:"
144-
[ "$RUBOCOP_EXITCODE" -ge 0 ] && echo " - rubocop: exit ${RUBOCOP_EXITCODE}"
145-
[ "$RSPEC_EXITCODE" -ge 0 ] && echo " - rspec: exit ${RSPEC_EXITCODE}"
146-
if [ "$RUBOCOP_EXITCODE" -gt 0 ] || [ "$RSPEC_EXITCODE" -gt 0 ]; then exit 1; else exit 0; fi
151+
[ "$RUBOCOP_EXITCODE" -ge 0 ] && echo " - rubocop: exit ${RUBOCOP_EXITCODE}"
152+
[ "$RSPEC_EXITCODE" -ge 0 ] && echo " - rspec: exit ${RSPEC_EXITCODE}"
153+
[ "$COVERAGE_EXITCODE" -ge 0 ] && echo " - coverage: exit ${COVERAGE_EXITCODE}"
154+
if [ "$RUBOCOP_EXITCODE" -gt 0 ] || [ "$RSPEC_EXITCODE" -gt 0 ] || [ "$COVERAGE_EXITCODE" -gt 0 ]; then
155+
exit 1
156+
fi
157+
exit 0

0 commit comments

Comments
 (0)