zephyr/.buildkite/hooks/pre-command
Kumar Gala bea131835d ci: Add initial buildkite ci setup
Add setup to utilize buildkite for CI purposes:

1. .buildkite/hooks/pre-command:
   * Handles getting git checkout setup against upstream repo
   * Setup some west module cache (dirs, clean out files & locks)
   * init dir for ccache

2. .buildkite/hooks/post-command:
   * Report disk usage (meant for possible debugging)

3. .buildkite/pipeline.yml [uses to determine what to do]:
   * setup zephyr env vars
   * set which docker container to use
     (export some local disk caches for git, west modules, and ccache)
   * uses plug to general build annotation on failure (junit-annotate)

4. .buildkite/run.sh [ buildkite wrapper to invoke scripts/ci/run.sh ]

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-06-09 15:28:48 -04:00

38 lines
1.1 KiB
Bash
Executable file

#!/bin/bash
# Copyright (c) 2020 Linaro Limited
#
# SPDX-License-Identifier: Apache-2.0
# Save off where we started so we can go back there
WORKDIR=${PWD}
if [ -n "${BUILDKITE_PULL_REQUEST_BASE_BRANCH}" ]; then
git fetch -v origin ${BUILDKITE_PULL_REQUEST_BASE_BRANCH}
git checkout FETCH_HEAD
git config --local user.email "builds@zephyrproject.org"
git config --local user.name "Zephyr CI"
git merge --no-edit "${BUILDKITE_COMMIT}" || {
local merge_result=$?
echo "Merge failed: ${merge_result}"
git merge --abort
exit $merge_result
}
fi
mkdir -p /var/lib/buildkite-agent/zephyr-ccache/
# create cache dirs, no-op if they already exist
mkdir -p /var/lib/buildkite-agent/zephyr-module-cache/modules
mkdir -p /var/lib/buildkite-agent/zephyr-module-cache/tools
mkdir -p /var/lib/buildkite-agent/zephyr-module-cache/bootloader
# Clean cache - if it already exists
cd /var/lib/buildkite-agent/zephyr-module-cache
find -type f -not -path "*/.git/*" -not -name ".git" -delete
# Remove any stale locks
find -name index.lock -delete
# return from where we started so we can find pipeline files from
# git repo
cd ${WORKDIR}