2020-06-03 20:02:35 +08:00
|
|
|
#!/bin/bash
|
|
|
|
# Copyright (c) 2020 Linaro Limited
|
|
|
|
#
|
|
|
|
# SPDX-License-Identifier: Apache-2.0
|
2020-09-05 00:20:31 +08:00
|
|
|
set -eE
|
|
|
|
|
|
|
|
function cleanup()
|
|
|
|
{
|
2020-12-08 01:19:58 +08:00
|
|
|
# Rename twister junit xml for use with junit-annotate-buildkite-plugin
|
|
|
|
# create dummy file if twister did nothing
|
|
|
|
if [ ! -f twister-out/twister.xml ]; then
|
|
|
|
touch twister-out/twister.xml
|
2020-09-05 00:20:31 +08:00
|
|
|
fi
|
2020-12-08 01:19:58 +08:00
|
|
|
mv twister-out/twister.xml twister-${BUILDKITE_JOB_ID}.xml
|
|
|
|
buildkite-agent artifact upload twister-${BUILDKITE_JOB_ID}.xml
|
2020-09-05 00:20:31 +08:00
|
|
|
|
|
|
|
|
|
|
|
# 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
|
|
|
|
|
2021-04-21 14:41:00 +08:00
|
|
|
# Cleanup on exit
|
|
|
|
rm -fr *
|
|
|
|
|
2020-09-05 00:20:31 +08:00
|
|
|
# disk usage
|
|
|
|
echo "--- disk usage at finish"
|
|
|
|
df -h
|
|
|
|
}
|
|
|
|
|
|
|
|
trap cleanup ERR
|
2020-06-03 20:02:35 +08:00
|
|
|
|
|
|
|
echo "--- run $0"
|
|
|
|
|
|
|
|
git log -n 5 --oneline --decorate --abbrev=12
|
|
|
|
|
|
|
|
# Setup module cache
|
|
|
|
cd /workdir
|
|
|
|
ln -s /var/lib/buildkite-agent/zephyr-module-cache/modules
|
|
|
|
ln -s /var/lib/buildkite-agent/zephyr-module-cache/tools
|
|
|
|
ln -s /var/lib/buildkite-agent/zephyr-module-cache/bootloader
|
|
|
|
cd /workdir/zephyr
|
|
|
|
|
|
|
|
export JOB_NUM=$((${BUILDKITE_PARALLEL_JOB}+1))
|
|
|
|
|
|
|
|
# ccache stats
|
|
|
|
echo ""
|
|
|
|
echo "--- ccache stats at start"
|
|
|
|
ccache -s
|
|
|
|
|
2020-10-15 22:38:34 +08:00
|
|
|
|
2020-06-27 04:26:02 +08:00
|
|
|
if [ -n "${DAILY_BUILD}" ]; then
|
2021-07-12 20:46:15 +08:00
|
|
|
TWISTER_OPTIONS=" --inline-logs -M -N --build-only --all --retry-failed 3 -v "
|
2020-06-27 04:26:02 +08:00
|
|
|
echo "--- DAILY BUILD"
|
|
|
|
west init -l .
|
2020-08-28 06:33:32 +08:00
|
|
|
west update 1> west.update.log || west update 1> west.update-2.log
|
2020-06-27 04:26:02 +08:00
|
|
|
west forall -c 'git reset --hard HEAD'
|
|
|
|
source zephyr-env.sh
|
2020-12-15 03:50:30 +08:00
|
|
|
./scripts/twister --subset ${JOB_NUM}/${BUILDKITE_PARALLEL_JOB_COUNT} ${TWISTER_OPTIONS}
|
2020-06-03 20:02:35 +08:00
|
|
|
else
|
2020-06-27 04:26:02 +08:00
|
|
|
if [ -n "${BUILDKITE_PULL_REQUEST_BASE_BRANCH}" ]; then
|
|
|
|
./scripts/ci/run_ci.sh -c -b ${BUILDKITE_PULL_REQUEST_BASE_BRANCH} -r origin \
|
|
|
|
-m ${JOB_NUM} -M ${BUILDKITE_PARALLEL_JOB_COUNT} -p ${BUILDKITE_PULL_REQUEST}
|
|
|
|
else
|
|
|
|
./scripts/ci/run_ci.sh -c -b ${BUILDKITE_BRANCH} -r origin \
|
2020-06-03 20:02:35 +08:00
|
|
|
-m ${JOB_NUM} -M ${BUILDKITE_PARALLEL_JOB_COUNT};
|
2020-06-27 04:26:02 +08:00
|
|
|
fi
|
|
|
|
fi
|
2020-06-03 20:02:35 +08:00
|
|
|
|
2020-12-15 03:50:30 +08:00
|
|
|
TWISTER_EXIT_STATUS=$?
|
2020-06-03 20:02:35 +08:00
|
|
|
|
2020-09-05 00:20:31 +08:00
|
|
|
cleanup
|
2020-06-03 20:02:35 +08:00
|
|
|
|
2020-12-15 03:50:30 +08:00
|
|
|
exit ${TWISTER_EXIT_STATUS}
|