blob: 29f3445b8fae1dc67dd94111f4ce55a7ab48db5c [file] [log] [blame]
Kumar Galabea13182020-06-03 07:02:35 -05001#!/bin/bash
2# Copyright (c) 2020 Linaro Limited
3#
4# SPDX-License-Identifier: Apache-2.0
Anas Nashif08b3e922020-09-04 12:20:31 -04005set -eE
6
7function cleanup()
8{
Anas Nashifa05d0562020-12-07 12:19:58 -05009 # Rename twister junit xml for use with junit-annotate-buildkite-plugin
10 # create dummy file if twister did nothing
11 if [ ! -f twister-out/twister.xml ]; then
12 touch twister-out/twister.xml
Anas Nashif08b3e922020-09-04 12:20:31 -040013 fi
Anas Nashifa05d0562020-12-07 12:19:58 -050014 mv twister-out/twister.xml twister-${BUILDKITE_JOB_ID}.xml
15 buildkite-agent artifact upload twister-${BUILDKITE_JOB_ID}.xml
Anas Nashif08b3e922020-09-04 12:20:31 -040016
17
18 # Upload test_file to get list of tests that are build/run
19 if [ -f test_file.txt ]; then
20 buildkite-agent artifact upload test_file.txt
21 fi
22
23 # ccache stats
24 echo "--- ccache stats at finish"
25 ccache -s
26
Kumar Galabab9ae22021-04-21 01:41:00 -050027 # Cleanup on exit
28 rm -fr *
29
Anas Nashif08b3e922020-09-04 12:20:31 -040030 # disk usage
31 echo "--- disk usage at finish"
32 df -h
33}
34
35trap cleanup ERR
Kumar Galabea13182020-06-03 07:02:35 -050036
37echo "--- run $0"
38
39git log -n 5 --oneline --decorate --abbrev=12
40
41# Setup module cache
42cd /workdir
43ln -s /var/lib/buildkite-agent/zephyr-module-cache/modules
44ln -s /var/lib/buildkite-agent/zephyr-module-cache/tools
45ln -s /var/lib/buildkite-agent/zephyr-module-cache/bootloader
46cd /workdir/zephyr
47
48export JOB_NUM=$((${BUILDKITE_PARALLEL_JOB}+1))
49
50# ccache stats
51echo ""
52echo "--- ccache stats at start"
53ccache -s
54
Ioannis Glaropoulos4ea11f82020-10-15 16:38:34 +020055
Kumar Gala5dcc6ba2020-06-26 15:26:02 -050056if [ -n "${DAILY_BUILD}" ]; then
Maciej Perkowski5bb0d982020-12-14 20:50:30 +010057 TWISTER_OPTIONS=" --inline-logs -N --build-only --all --retry-failed 3 -v "
Kumar Gala5dcc6ba2020-06-26 15:26:02 -050058 echo "--- DAILY BUILD"
59 west init -l .
Martí Bolívar36aa42f2020-08-27 15:33:32 -070060 west update 1> west.update.log || west update 1> west.update-2.log
Kumar Gala5dcc6ba2020-06-26 15:26:02 -050061 west forall -c 'git reset --hard HEAD'
62 source zephyr-env.sh
Maciej Perkowski5bb0d982020-12-14 20:50:30 +010063 ./scripts/twister --subset ${JOB_NUM}/${BUILDKITE_PARALLEL_JOB_COUNT} ${TWISTER_OPTIONS}
Kumar Galabea13182020-06-03 07:02:35 -050064else
Kumar Gala5dcc6ba2020-06-26 15:26:02 -050065 if [ -n "${BUILDKITE_PULL_REQUEST_BASE_BRANCH}" ]; then
66 ./scripts/ci/run_ci.sh -c -b ${BUILDKITE_PULL_REQUEST_BASE_BRANCH} -r origin \
67 -m ${JOB_NUM} -M ${BUILDKITE_PARALLEL_JOB_COUNT} -p ${BUILDKITE_PULL_REQUEST}
68 else
69 ./scripts/ci/run_ci.sh -c -b ${BUILDKITE_BRANCH} -r origin \
Kumar Galabea13182020-06-03 07:02:35 -050070 -m ${JOB_NUM} -M ${BUILDKITE_PARALLEL_JOB_COUNT};
Kumar Gala5dcc6ba2020-06-26 15:26:02 -050071 fi
72fi
Kumar Galabea13182020-06-03 07:02:35 -050073
Maciej Perkowski5bb0d982020-12-14 20:50:30 +010074TWISTER_EXIT_STATUS=$?
Kumar Galabea13182020-06-03 07:02:35 -050075
Anas Nashif08b3e922020-09-04 12:20:31 -040076cleanup
Kumar Galabea13182020-06-03 07:02:35 -050077
Maciej Perkowski5bb0d982020-12-14 20:50:30 +010078exit ${TWISTER_EXIT_STATUS}