Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lk86/fix-merges-cleanly-job Check mergeability against all upstream branches #10133

Merged
merged 10 commits into from
Feb 7, 2022
18 changes: 0 additions & 18 deletions buildkite/scripts/merges-cleanly-to-develop.sh

This file was deleted.

23 changes: 23 additions & 0 deletions buildkite/scripts/merges-cleanly.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash

BRANCH=$1
CURRENT=$(git branch --show-current)
echo 'Testing for conflicts between the current branch `'"${CURRENT}"'` and `'"${BRANCH}"'`...'

# Adapted from this stackoverflow answer: https://stackoverflow.com/a/10856937
# The git merge-tree command shows the content of a 3-way merge without
# touching the index, which we can then search for conflict markers.

git merge-tree `git merge-base origin/$BRANCH HEAD` HEAD origin/$BRANCH | grep -A 25 "^+<<<<<<<"

RET=$?

if [ $RET -eq 0 ]; then
# Found a conflict
echo "[ERROR] This pull request conflicts with $BRANCH, please open a new pull request against $BRANCH at this link:"
echo "https://github.com/MinaProtocol/mina/compare/${BRANCH}...${BUILDKITE_BRANCH}"
exit 1
else
echo "No conflicts found against upstream branch ${BRANCH}"
exit 0
fi
22 changes: 21 additions & 1 deletion buildkite/src/Jobs/Lint/Merge.dhall
Original file line number Diff line number Diff line change
@@ -22,13 +22,33 @@ Pipeline.build
steps = [
Command.build
Command.Config::{
commands = [ Cmd.run "buildkite/scripts/merges-cleanly-to-develop.sh" ]
commands = [ Cmd.run "buildkite/scripts/merges-cleanly.sh compatible"]
, label = "Check merges cleanly into compatible"
, key = "clean-merge-compatible"
, target = Size.Small
, docker = Some Docker::{
image = (../../Constants/ContainerImages.dhall).toolchainBase
}
},
Command.build
Command.Config::{
commands = [ Cmd.run "buildkite/scripts/merges-cleanly.sh develop"]
, label = "Check merges cleanly into develop"
, key = "clean-merge-develop"
, target = Size.Small
, docker = Some Docker::{
image = (../../Constants/ContainerImages.dhall).toolchainBase
}
},
Command.build
Command.Config::{
commands = [ Cmd.run "buildkite/scripts/merges-cleanly.sh feature/snapps-protocol"]
, label = "Check merges cleanly into feature/snapps-protocol"
, key = "clean-merge-snapps"
, target = Size.Small
, docker = Some Docker::{
image = (../../Constants/ContainerImages.dhall).toolchainBase
}
}
]
}