buildkite: trap errors and do proper cleanup
On errors we were aborting immediately skipping any needed cleanup after the error has occured. This will run the cleanup function and upload reports of failure when something bad happens. Signed-off-by: Anas Nashif <anas.nashif@intel.com>
This commit is contained in:
parent
f160dee935
commit
08b3e92662
1 changed files with 29 additions and 20 deletions
|
@ -2,7 +2,34 @@
|
|||
# Copyright (c) 2020 Linaro Limited
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
set -e
|
||||
set -eE
|
||||
|
||||
function cleanup()
|
||||
{
|
||||
# Rename sanitycheck junit xml for use with junit-annotate-buildkite-plugin
|
||||
# create dummy file if sanitycheck did nothing
|
||||
if [ ! -f sanity-out/sanitycheck.xml ]; then
|
||||
touch sanity-out/sanitycheck.xml
|
||||
fi
|
||||
mv sanity-out/sanitycheck.xml sanitycheck-${BUILDKITE_JOB_ID}.xml
|
||||
buildkite-agent artifact upload sanitycheck-${BUILDKITE_JOB_ID}.xml
|
||||
|
||||
|
||||
# Upload test_file to get list of tests that are build/run
|
||||
if [ -f test_file.txt ]; then
|
||||
buildkite-agent artifact upload test_file.txt
|
||||
fi
|
||||
|
||||
# ccache stats
|
||||
echo "--- ccache stats at finish"
|
||||
ccache -s
|
||||
|
||||
# disk usage
|
||||
echo "--- disk usage at finish"
|
||||
df -h
|
||||
}
|
||||
|
||||
trap cleanup ERR
|
||||
|
||||
echo "--- run $0"
|
||||
|
||||
|
@ -46,24 +73,6 @@ fi
|
|||
|
||||
SANITY_EXIT_STATUS=$?
|
||||
|
||||
# Rename sanitycheck junit xml for use with junit-annotate-buildkite-plugin
|
||||
# create dummy file if sanitycheck did nothing
|
||||
if [ ! -f sanity-out/sanitycheck.xml ]; then
|
||||
touch sanity-out/sanitycheck.xml
|
||||
fi
|
||||
mv sanity-out/sanitycheck.xml sanitycheck-${BUILDKITE_JOB_ID}.xml
|
||||
buildkite-agent artifact upload sanitycheck-${BUILDKITE_JOB_ID}.xml
|
||||
|
||||
|
||||
# Upload test_file to get list of tests that are build/run
|
||||
buildkite-agent artifact upload test_file.txt
|
||||
|
||||
# ccache stats
|
||||
echo "--- ccache stats at finish"
|
||||
ccache -s
|
||||
|
||||
# disk usage
|
||||
echo "--- disk usage at finish"
|
||||
df -h
|
||||
cleanup
|
||||
|
||||
exit ${SANITY_EXIT_STATUS}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue