1#!/bin/bash 2# Copyright (c) 2020 Linaro Limited 3# 4# SPDX-License-Identifier: Apache-2.0 5set -eE 6 7function cleanup() 8{ 9 # 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 13 fi 14 mv twister-out/twister.xml twister-${BUILDKITE_JOB_ID}.xml 15 buildkite-agent artifact upload twister-${BUILDKITE_JOB_ID}.xml 16 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 27 # Cleanup on exit 28 rm -fr * 29 30 # disk usage 31 echo "--- disk usage at finish" 32 df -h 33} 34 35trap cleanup ERR 36 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 55 56if [ -n "${DAILY_BUILD}" ]; then 57 TWISTER_OPTIONS=" --inline-logs -M -N --build-only --all --retry-failed 3 -v " 58 echo "--- DAILY BUILD" 59 west init -l . 60 west update 1> west.update.log || west update 1> west.update-2.log 61 west forall -c 'git reset --hard HEAD' 62 source zephyr-env.sh 63 ./scripts/twister --subset ${JOB_NUM}/${BUILDKITE_PARALLEL_JOB_COUNT} ${TWISTER_OPTIONS} 64else 65 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 \ 70 -m ${JOB_NUM} -M ${BUILDKITE_PARALLEL_JOB_COUNT}; 71 fi 72fi 73 74TWISTER_EXIT_STATUS=$? 75 76cleanup 77 78exit ${TWISTER_EXIT_STATUS} 79