Kumar Gala | bea1318 | 2020-06-03 07:02:35 -0500 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # Copyright (c) 2020 Linaro Limited |
| 3 | # |
| 4 | # SPDX-License-Identifier: Apache-2.0 |
Anas Nashif | 08b3e92 | 2020-09-04 12:20:31 -0400 | [diff] [blame] | 5 | set -eE |
| 6 | |
| 7 | function cleanup() |
| 8 | { |
Anas Nashif | a05d056 | 2020-12-07 12:19:58 -0500 | [diff] [blame] | 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 |
Anas Nashif | 08b3e92 | 2020-09-04 12:20:31 -0400 | [diff] [blame] | 13 | fi |
Anas Nashif | a05d056 | 2020-12-07 12:19:58 -0500 | [diff] [blame] | 14 | mv twister-out/twister.xml twister-${BUILDKITE_JOB_ID}.xml |
| 15 | buildkite-agent artifact upload twister-${BUILDKITE_JOB_ID}.xml |
Anas Nashif | 08b3e92 | 2020-09-04 12:20:31 -0400 | [diff] [blame] | 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 | |
Kumar Gala | bab9ae2 | 2021-04-21 01:41:00 -0500 | [diff] [blame] | 27 | # Cleanup on exit |
| 28 | rm -fr * |
| 29 | |
Anas Nashif | 08b3e92 | 2020-09-04 12:20:31 -0400 | [diff] [blame] | 30 | # disk usage |
| 31 | echo "--- disk usage at finish" |
| 32 | df -h |
| 33 | } |
| 34 | |
| 35 | trap cleanup ERR |
Kumar Gala | bea1318 | 2020-06-03 07:02:35 -0500 | [diff] [blame] | 36 | |
| 37 | echo "--- run $0" |
| 38 | |
| 39 | git log -n 5 --oneline --decorate --abbrev=12 |
| 40 | |
| 41 | # Setup module cache |
| 42 | cd /workdir |
| 43 | ln -s /var/lib/buildkite-agent/zephyr-module-cache/modules |
| 44 | ln -s /var/lib/buildkite-agent/zephyr-module-cache/tools |
| 45 | ln -s /var/lib/buildkite-agent/zephyr-module-cache/bootloader |
| 46 | cd /workdir/zephyr |
| 47 | |
| 48 | export JOB_NUM=$((${BUILDKITE_PARALLEL_JOB}+1)) |
| 49 | |
| 50 | # ccache stats |
| 51 | echo "" |
| 52 | echo "--- ccache stats at start" |
| 53 | ccache -s |
| 54 | |
Ioannis Glaropoulos | 4ea11f8 | 2020-10-15 16:38:34 +0200 | [diff] [blame] | 55 | |
Kumar Gala | 5dcc6ba | 2020-06-26 15:26:02 -0500 | [diff] [blame] | 56 | if [ -n "${DAILY_BUILD}" ]; then |
Maciej Perkowski | 5bb0d98 | 2020-12-14 20:50:30 +0100 | [diff] [blame] | 57 | TWISTER_OPTIONS=" --inline-logs -N --build-only --all --retry-failed 3 -v " |
Kumar Gala | 5dcc6ba | 2020-06-26 15:26:02 -0500 | [diff] [blame] | 58 | echo "--- DAILY BUILD" |
| 59 | west init -l . |
Martí Bolívar | 36aa42f | 2020-08-27 15:33:32 -0700 | [diff] [blame] | 60 | west update 1> west.update.log || west update 1> west.update-2.log |
Kumar Gala | 5dcc6ba | 2020-06-26 15:26:02 -0500 | [diff] [blame] | 61 | west forall -c 'git reset --hard HEAD' |
| 62 | source zephyr-env.sh |
Maciej Perkowski | 5bb0d98 | 2020-12-14 20:50:30 +0100 | [diff] [blame] | 63 | ./scripts/twister --subset ${JOB_NUM}/${BUILDKITE_PARALLEL_JOB_COUNT} ${TWISTER_OPTIONS} |
Kumar Gala | bea1318 | 2020-06-03 07:02:35 -0500 | [diff] [blame] | 64 | else |
Kumar Gala | 5dcc6ba | 2020-06-26 15:26:02 -0500 | [diff] [blame] | 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 \ |
Kumar Gala | bea1318 | 2020-06-03 07:02:35 -0500 | [diff] [blame] | 70 | -m ${JOB_NUM} -M ${BUILDKITE_PARALLEL_JOB_COUNT}; |
Kumar Gala | 5dcc6ba | 2020-06-26 15:26:02 -0500 | [diff] [blame] | 71 | fi |
| 72 | fi |
Kumar Gala | bea1318 | 2020-06-03 07:02:35 -0500 | [diff] [blame] | 73 | |
Maciej Perkowski | 5bb0d98 | 2020-12-14 20:50:30 +0100 | [diff] [blame] | 74 | TWISTER_EXIT_STATUS=$? |
Kumar Gala | bea1318 | 2020-06-03 07:02:35 -0500 | [diff] [blame] | 75 | |
Anas Nashif | 08b3e92 | 2020-09-04 12:20:31 -0400 | [diff] [blame] | 76 | cleanup |
Kumar Gala | bea1318 | 2020-06-03 07:02:35 -0500 | [diff] [blame] | 77 | |
Maciej Perkowski | 5bb0d98 | 2020-12-14 20:50:30 +0100 | [diff] [blame] | 78 | exit ${TWISTER_EXIT_STATUS} |