Skip to content

Commit 7008a10

Browse files
authored
CI: fail when an example or test build fails (#8590)
scripts/ci/{osx,linux64,msys2}/run_tests.sh have set -e commented out, so a failed make didn't fail the job. On osx the emptyExample and allAddonsExample builds weren't checked at all: allAddonsExample has been failing to link on master (undefined kleidicv:: symbols from the macOS OpenCV package) while build-macos (osx, makefiles) stayed green. On linux64 and msys2 a failed test build only showed up later as a missing binary. Each make now goes through build_or_fail, which stops the job and adds a GitHub error annotation naming the build. The tests' own exit code checks are unchanged.
1 parent 68e7e73 commit 7008a10

3 files changed

Lines changed: 29 additions & 5 deletions

File tree

‎scripts/ci/linux64/run_tests.sh‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22
# set -ev
33
ROOT=${TRAVIS_BUILD_DIR:-"$( cd "$(dirname "$0")/../../.." ; pwd -P )"}
44

5+
# fail the job when a build fails, with an error annotation naming what failed
6+
build_or_fail(){
7+
if ! make "$@"; then
8+
echo "::error title=Build failed::make $* failed in ${PWD#$ROOT/}"
9+
exit 1
10+
fi
11+
}
12+
513
# if [ "$OPT" == "qbs" ]; then
614
# exit 0
715
# else
@@ -21,7 +29,7 @@ for group in *; do
2129
cp ../../../scripts/templates/linux/Makefile .
2230
cp ../../../scripts/templates/linux/config.make .
2331
sleep 0.3
24-
make -j2 Debug
32+
build_or_fail -j2 Debug
2533
sleep 0.3
2634
cd bin
2735
binname=$(basename ${test})

‎scripts/ci/msys2/run_tests.sh‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
#!/bin/bash
22
# set -ev
33
ROOT=$(pwd -P)
4+
5+
# fail the job when a build fails, with an error annotation naming what failed
6+
build_or_fail(){
7+
if ! make "$@"; then
8+
echo "::error title=Build failed::make $* failed in ${PWD#$ROOT/}"
9+
exit 1
10+
fi
11+
}
412
# source $ROOT/scripts/ci/ccache.sh
513

614
echo "##[group]**** Running unit tests ****"
@@ -16,7 +24,7 @@ for group in *; do
1624
cd $test
1725
cp ../../../scripts/templates/msys2/Makefile .
1826
cp ../../../scripts/templates/msys2/config.make .
19-
make -j2 Debug
27+
build_or_fail -j2 Debug
2028
cd bin
2129
binname=$(basename ${test})
2230
#gdb -batch -ex "run" -ex "bt" -ex "q \$_exitcode" ./${binname}_debug

‎scripts/ci/osx/run_tests.sh‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,30 @@
22
#set -ev
33
ROOT=${TRAVIS_BUILD_DIR:-"$( cd "$(dirname "$0")/../../.." ; pwd -P )"}
44

5+
# fail the job when a build fails, with an error annotation naming what failed
6+
build_or_fail(){
7+
if ! make "$@"; then
8+
echo "::error title=Build failed::make $* failed in ${PWD#$ROOT/}"
9+
exit 1
10+
fi
11+
}
12+
513
trap 'for f in ~/Library/Logs/DiagnosticReports/*; do cat $f; done' 11
614

715
echo "##[group]**** Building emptyExample ****"
816
cd $ROOT
917
cp scripts/templates/osx/Makefile examples/templates/emptyExample/
1018
cp scripts/templates/osx/config.make examples/templates/emptyExample/
1119
cd examples/templates/emptyExample/
12-
make -j2 Debug
20+
build_or_fail -j2 Debug
1321
echo "##[endgroup]"
1422

1523
echo "##[group]**** Building allAddonsExample ****"
1624
cd $ROOT
1725
cp scripts/templates/osx/Makefile examples/templates/allAddonsExample/
1826
cp scripts/templates/osx/config.make examples/templates/allAddonsExample/
1927
cd examples/templates/allAddonsExample/
20-
make -j2 Debug
28+
build_or_fail -j2 Debug
2129
echo "##[endgroup]"
2230

2331
echo "##[group]**** Running unit tests ****"
@@ -33,7 +41,7 @@ for group in *; do
3341
cd $test
3442
cp ../../../scripts/templates/osx/Makefile .
3543
cp ../../../scripts/templates/osx/config.make .
36-
make -j2 Debug
44+
build_or_fail -j2 Debug
3745
make RunDebug
3846
errorcode=$?
3947
if [[ $errorcode -ne 0 ]]; then

0 commit comments

Comments
 (0)