diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2020-01-29 10:12:35 -0800 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2020-01-29 10:12:35 -0800 |
commit | 3e723e85c2a82ce79e6be8872f16bf0558a94308 (patch) | |
tree | 9906a8fdb25eadfe1c678c4232a384629402fbaf /.buildkite | |
parent | 7b9a24982efb8f8c4f02ec70d0219e8ab7ada59a (diff) | |
download | chef-3e723e85c2a82ce79e6be8872f16bf0558a94308.tar.gz |
add bk testing against merge commit
mostly copied from https://github.com/chef/automate/blob/master/.buildkite/hooks/pre-command
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
Diffstat (limited to '.buildkite')
-rw-r--r-- | .buildkite/hooks/pre-command | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/.buildkite/hooks/pre-command b/.buildkite/hooks/pre-command new file mode 100644 index 0000000000..386c5bb655 --- /dev/null +++ b/.buildkite/hooks/pre-command @@ -0,0 +1,35 @@ +#!/bin/bash + +set -eu + +docker ps || true +free -m + +# We've now seen cases where origin/master on the build hosts can get +# out of date. This causes us to build components unnecessarily. +# Fetching it here hopefully will prevent this situation. +echo "Fetching origin/master" +git fetch origin master + +# DEBUGGING FOR RELENG +# Fetch the git tags to see if that addresses the weird smart build behavior for Habitat +git fetch --tags --force + +# Rebase onto current master to ensure this PR is closer to what happens when it's merged. +# Only do this if it's actually a branch (i.e. a PR or a manually created build), not a +# post-merge CI run of master. +if [[ "$BUILDKITE_BRANCH" != "master" ]]; then + git config user.email "you@example.com" # these are needed for the rebase attempt + git config user.name "Your Name" + master=$(git show-ref -s --abbrev origin/master) + pr_head=$(git show-ref -s --abbrev HEAD) + github="https://github.com/chef/automate/commit/" + if git rebase origin/master >/dev/null; then + buildkite-agent annotate --style success --context "rebase-pr-branch-${master}" \ + "Rebased onto master ([${master}](${github}${master}))." + else + git rebase --abort + buildkite-agent annotate --style warning --context "rebase-pr-branch-${master}" \ + "Couldn't rebase onto master ([${master}](${github}${master})), building PR HEAD ([${pr_head}](${github}${pr_head}))." + fi +fi |