pre-command 1.2 KB

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