Move adtsummary2junit invocations into adt-sbuild
authorChristoph Berg <myon@debian.org>
Sat, 3 Oct 2015 07:03:23 +0000 (09:03 +0200)
committerChristoph Berg <myon@debian.org>
Sat, 3 Oct 2015 07:03:23 +0000 (09:03 +0200)
... so failures to invoke adt-sbuild will result into build failures more reliably

debian/pgdg-buildenv.install
jenkins/adt-sbuild
jenkins/sbuild-package

index 7cfcb5e338cd3183512d26717b923252650954f6..5b259d5724fa09ef15ff3b680e1c8819ec2aa661 100644 (file)
@@ -1,3 +1,4 @@
 pgdg-buildenv/etc /
 jenkins/adt-sbuild usr/bin
+jenkins/adtsummary2junit usr/bin
 pgdg-buildenv/sbin usr
index 6e31a3e66ba47c1607c54cea17c1835e49da0caf..aca4addc5267f805a401ac4bc942ed1c08e06036 100755 (executable)
@@ -1,6 +1,7 @@
 #!/bin/sh
 
 # This is a wrapper around adt-run meant to be called from sbuild:
+# export DEB_ADT_SUMMARY=$(mktemp /var/tmp/$PACKAGE.XXXXXX.xml)
 # sbuild --finished-build-commands='adt-sbuild %SBUILD_BUILD_DIR %SBUILD_PKGBUILD_DIR' ...
 
 if [ -z "$DEB_ADT_SUMMARY" ]; then
@@ -21,6 +22,7 @@ cd "$SBUILD_PKGBUILD_DIR"
 
 if [ ! -f debian/tests/control ]; then
        echo "Package does not have autopkgtest support (there is no debian/tests/control file)"
+       adtsummary2junit /dev/null > $DEB_ADT_SUMMARY
        exit 0
 fi
 
@@ -29,11 +31,23 @@ if [ ! -f debian/files ]; then
        exit 1
 fi
 
-set -x
+ADT_SUMMARY=$(mktemp /tmp/adt.XXXXXX.summary)
+trap "rm -f $ADT_SUMMARY" 0 2 3 15
 
-exec sudo adt-run --summary $DEB_ADT_SUMMARY \
+(
+set -x
+sudo adt-run --summary $ADT_SUMMARY \
        $SBUILD_BUILD_DIR/*.deb \
        --built-tree $SBUILD_PKGBUILD_DIR \
        --- adt-virt-null
+) || EXIT=$?
+
+case ${EXIT:-0} in
+       0|2|4|6|8) # all ok or some test failed, exit 0 here and let adtsummary2junit report the failure to jenkins
+               adtsummary2junit $ADT_SUMMARY > $DEB_ADT_SUMMARY
+               exit 0
+               ;;
+esac
 
-# sbuild ignores the exit code here, adtsummary2junit will translate the results so jenkins sees any failures
+# in reality, sbuild ignores failures here, but jenkins will complain if the junit xml result file is empty
+exit $EXIT
index 0287b1f945f464eb9c5c1d178699d4a19de9d749..2a5b208c849afe8ed2a08fc4e25bf0d138e93289 100755 (executable)
@@ -58,7 +58,7 @@ case $architecture in
 esac
 
 # prepare temp file for adt-run results
-export DEB_ADT_SUMMARY=$(mktemp /var/tmp/adt.XXXXXX)
+export DEB_ADT_SUMMARY=$(mktemp /var/tmp/$PACKAGE.XXXXXX.xml)
 cleanup () {
   rm -f "$DEB_ADT_SUMMARY"
 }
@@ -88,5 +88,5 @@ if [ "${FILTER_ARCH_ALL:-}" ]; then
   sed -i -e '/_all\.deb$/d' *.changes
 fi
 
-# convert autopkgtest results to junit format (writes a dummy record if package doesn't have tests)
-adtsummary2junit $DEB_ADT_SUMMARY > autopkgtest.xml
+# copy autopkgtest results back (already in junit format)
+cp $DEB_ADT_SUMMARY autopkgtest.xml