add mergify engine for backport only

This is round 2 attempting to add the mergify engine in Rook. In this
case, we only use the backporting and automerge features.

* auto backport: set a label on your PR and a backport PR will be
automatically created under the right branch
* auto backport PR merge: if the backport PR passes CI, mergify will
merge it.

Signed-off-by: Sébastien Han <seb@redhat.com>
This commit is contained in:
Sébastien Han committed 2019-09-25 08:41:41 +02:00
1 parent 9affd75752
commit cfd2a7be0b
3 files changed
+30 -118

No files matched your search

+24
View File
@@ -0,0 +1,24 @@
pull_request_rules:
# automerge backports if CI successfully ran
- name: automerge backport release-1.1
conditions:
- author=mergify[bot]
- base=release-1.1
- label!=no-not-merge
- 'status-success=DCO'
- 'status-success=continuous-integration/jenkins/pr-head'
actions:
merge:
method: rebase
rebase_fallback: merge
strict: smart
dismiss_reviews: {}
delete_head_branch: {}
# Trigger backport PRs based on label
- actions:
backport:
branches:
- release-1.1
conditions:
- label=backport-release-1.1
name: backport release-1.1
+6 -31
View File
@@ -254,38 +254,13 @@ After the PR is open, you can make changes simply by pushing new commits. Your P
### Backport a Fix to a Release Branch
#### Manual flow
The flow for getting a fix into a release branch is:
The flow for getting a fix into a release branch is to first make the commit to master following the process outlined above.
After the commit is in master, you'll need to cherry-pick the commit to the intended release branch.
You can do this by first creating a local branch that is based off the release branch, for example:
```console
git fetch --all
git checkout -b backport-my-fix upstream/release-0.6
```
Then go ahead and cherry-pick the commit using the hash of the commit itself, **not** the merge commit hash:
```console
git cherry-pick -x 099cc27b73a8d77e0504831f374a7e117ad0a2e4
```
This will immediately create a cherry-picked commit with a nice message saying where the commit was cherry-picked from.
Now go ahead and push to your origin:
```console
git push origin HEAD
```
#### Automated flow
You will find a script at `contrib/backport_to_stable_branch.sh` at the root of the Rook repository.
Execute it and it will do the necessary things and will push the backport branch.
Then go on the Rook Github web page and create your pull request.
#### Create the backport pull request
The last step is to open a PR with the base being the intended release branch.
If you don't know how to do this, [read Github documentation on changing the base branch range](https://help.github.com/en/articles/creating-a-pull-request#changing-the-branch-range-and-destination-repository).
Once the PR is approved and merged, then your backported change will be available in the next release.
1. Open a PR to merge the changes to master following the process outlined above.
1. Add the backport label to that PR such as backport-release-1.1
1. After your PR is merged to master, the mergify bot will automatically open a PR with your commits backported to the release branch
1. If there are any conflicts you will need to resolve them by pulling the branch, resolving the conflicts and force push back the branch
1. After the CI is green, the bot will automatically merge the backport PR.
## Debugging operators locally
-87
View File
@@ -1,87 +0,0 @@
#!/usr/bin/env bash
set -e
shopt -s extglob # enable extended pattern matching features
#############
# VARIABLES #
#############
stable_branch=$1
commit=$2
bkp_branch_name=bkp-$1
bkp_branch_name_prefix=bkp
bkp_branch=$bkp_branch_name-$bkp_branch_name_prefix-$stable_branch
#############
# FUNCTIONS #
#############
verify_commit () {
for com in ${commit//,/ }; do
if [[ $(git cat-file -t "$com" 2>/dev/null) != commit ]]; then
echo "$com does not exist in your tree"
echo "Run 'git fetch upstream master && git pull upstream master --rebase'"
echo "Where 'upstream' is the remote name of the rook/rook repository"
exit 1
fi
done
}
git_status () {
if [[ $(git status --porcelain | wc -l) -gt 0 ]]; then
echo "It looks like you have not committed changes:"
echo ""
git status --short
echo ""
echo ""
echo "Press ENTER to continue or Ctrl+c to break."
read -r
fi
}
checkout () {
git checkout --no-track -b "$bkp_branch" origin/"$stable_branch"
}
cherry_pick () {
local x
for com in ${commit//,/ }; do
x="$x $com"
done
# Trim the first white space and use an array
# Reference: https://github.com/koalaman/shellcheck/wiki/SC2086#exceptions
# shellcheck disable=SC2206
x=(${x##*( )})
git cherry-pick -x -s "${x[@]}"
}
push () {
git push origin "$bkp_branch"
}
cleanup () {
echo "Moving back to previous branch"
git checkout -
git branch -D "$bkp_branch"
}
test_args () {
if [ $# -lt 3 ]; then
echo "Please run the script like this: ./contrib/backport_to_stable_branch.sh STABLE_BRANCH_NAME COMMIT_SHA1 BACKPORT_BRANCH_NAME"
echo "We accept multiple commits as soon as they are commas-separated."
echo "e.g: ./contrib/backport_to_stable_branch.sh release-1.0 6892670d317698771be7e96ce9032bc27d3fd1e5,8756c553cc8c213fc4996fc5202c7b687eb645a3 my-work"
exit 1
fi
}
########
# MAIN #
########
test_args "$@"
git_status
verify_commit
checkout
cherry_pick
push
cleanup