1#!/bin/bash 2# Copyright (c) 2020 Linaro Limited 3# 4# SPDX-License-Identifier: Apache-2.0 5 6# Save off where we started so we can go back there 7WORKDIR=${PWD} 8 9echo "--- $0 disk usage" 10df -h 11du -hs /var/lib/buildkite-agent/* 12docker images -a 13docker system df -v 14 15if [ -n "${BUILDKITE_PULL_REQUEST_BASE_BRANCH}" ]; then 16 git fetch -v origin ${BUILDKITE_PULL_REQUEST_BASE_BRANCH} 17 git checkout FETCH_HEAD 18 git config --local user.email "builds@zephyrproject.org" 19 git config --local user.name "Zephyr CI" 20 git merge --no-edit "${BUILDKITE_COMMIT}" || { 21 local merge_result=$? 22 echo "Merge failed: ${merge_result}" 23 git merge --abort 24 exit $merge_result 25 } 26fi 27 28mkdir -p /var/lib/buildkite-agent/zephyr-ccache/ 29 30# create cache dirs, no-op if they already exist 31mkdir -p /var/lib/buildkite-agent/zephyr-module-cache/modules 32mkdir -p /var/lib/buildkite-agent/zephyr-module-cache/tools 33mkdir -p /var/lib/buildkite-agent/zephyr-module-cache/bootloader 34 35# Clean cache - if it already exists 36cd /var/lib/buildkite-agent/zephyr-module-cache 37find -type f -not -path "*/.git/*" -not -name ".git" -delete 38 39# Remove any stale locks 40find -name index.lock -delete 41 42# return from where we started so we can find pipeline files from 43# git repo 44cd ${WORKDIR} 45