HOWTO populate the integration branch » History » Version 16
Abhishek Lekshmanan, 06/13/2015 05:24 AM
use jq args for release instead of hardcoding
1 | 3 | Loïc Dachary | Before a backported commit can be merged into the release branch, it must be tested in an integration branch. It serves two purposes: |
---|---|---|---|
2 | 3 | Loïc Dachary | |
3 | 3 | Loïc Dachary | * Detect trivial problems that would break the upgrade tests run on the release branch (they are run at the tip of the branch, not at the latest point release) |
4 | 13 | Loïc Dachary | * Do not pollute the release branch with reverted commits (commits would have to be reverted because the stable branch must never be rebased) |
5 | 1 | Loïc Dachary | |
6 | 11 | Loïc Dachary | Let say the release to be tested is *$release* (i.e. giant for instance) and your local clone has two remotes: *origin* which is your read/write fork of the official ceph repository and *ceph* which is the read only official ceph repository. |
7 | 11 | Loïc Dachary | <pre> |
8 | 11 | Loïc Dachary | ceph https://github.com/ceph/ceph.git (fetch) |
9 | 11 | Loïc Dachary | ceph https://github.com/ceph/ceph.git (push) |
10 | 11 | Loïc Dachary | origin git@github.com:dachary/ceph.git (fetch) |
11 | 11 | Loïc Dachary | origin git@github.com:dachary/ceph.git (push) |
12 | 11 | Loïc Dachary | </pre> |
13 | 1 | Loïc Dachary | |
14 | 11 | Loïc Dachary | * Create a $release-backport branch locally if it does not already exists: *git checkout -b $release-backports ceph/$release* |
15 | 11 | Loïc Dachary | * Reset it to ceph/$release: *git reset --hard ceph/$release* |
16 | 11 | Loïc Dachary | * Fetch all pull requests from github. Each pull request XXX has its own branch in the official ceph repository, named *pull/XXX* |
17 | 15 | Abhishek Lekshmanan | ** For finding out the pull requests in github against a milestone; Github's api can be queried. Since github paginates results by default, this has to be run against all the pages. |
18 | 15 | Abhishek Lekshmanan | <pre> |
19 | 15 | Abhishek Lekshmanan | pages=$(curl -Is 'https://api.github.com/repos/ceph/ceph/issues?page=1&per_page=100' | grep ^Link | sed 's/.*?page=\([0-9]\+\).*/\1/') |
20 | 15 | Abhishek Lekshmanan | PRS="" |
21 | 15 | Abhishek Lekshmanan | for i in $(seq 1 $pages) |
22 | 15 | Abhishek Lekshmanan | do |
23 | 16 | Abhishek Lekshmanan | PRS+=$(curl --silent 'https://api.github.com/repos/ceph/ceph/issues?page=$page&per_page=100' | jq --arg release "$release" '.[] | select(.milestone.title == $release) | .number') |
24 | 16 | Abhishek Lekshmanan | PRS+=' ' # otherwise we'll have a PR number that is appending the last PR from this loop |
25 | 15 | Abhishek Lekshmanan | done |
26 | 15 | Abhishek Lekshmanan | </pre> |
27 | 11 | Loïc Dachary | ** Retrieve the commits of the pull request XXX: *git fetch --force ceph +refs/pull/XXX/head:refs/remotes/ceph/pull/XXX/head* |
28 | 12 | Loïc Dachary | ** Get the title of the pull request: *eval title=$(curl --silent https://api.github.com/repos/ceph/ceph/pulls/XXX | jq .title)* |
29 | 11 | Loïc Dachary | ** Merge the pull request in the local integration branch. The *--no-ff* ensures that even if the merge commit could be skipped, it will not be. *git merge --no-ff -m "$(echo -e "Merge XXX: $title\n\nReviewed-by: Myself <me@me.com>")" ceph/pull/XXX/head* |
30 | 11 | Loïc Dachary | * Modify the pull requests individually to fix merge conflicts (i.e. they must merge cleanly, which may involving aggregating two pull requests into a single one designed to properly resolve the conflict). |
31 | 11 | Loïc Dachary | * Push the integration branch to github: *git push --force origin $release-backports* |
32 | 11 | Loïc Dachary | * Verify the integration branch compiles and passes make check |
33 | 11 | Loïc Dachary | ** On the local machine: *./run-make-check.sh* |
34 | 11 | Loïc Dachary | ** Via the make check bot by creating a pull request with the $release-backports* integration branch |
35 | 11 | Loïc Dachary | * Push the integration branch to the official repository: *git push --force ceph $release-backports* (requires write permission to the ceph repository) |
36 | 1 | Loïc Dachary | |
37 | 12 | Loïc Dachary | The following snippet summarizes all the actions above: |
38 | 9 | Loïc Dachary | <pre> |
39 | 10 | Loïc Dachary | release=hammer |
40 | 1 | Loïc Dachary | PRS="3963 4185" |
41 | 10 | Loïc Dachary | reviewer='Loic Dachary <ldachary@redhat.com>' |
42 | 14 | Loïc Dachary | git checkout -b $release-backports ceph/$release |
43 | 10 | Loïc Dachary | git reset --hard ceph/$release |
44 | 9 | Loïc Dachary | git fetch --force ceph $(for ref in $PRS ; do echo +refs/pull/$ref/head:refs/remotes/ceph/pull/$ref/head ; echo +refs/pull/$ref/merge:refs/remotes/ceph/pull/$ref/merge ; done) |
45 | 11 | Loïc Dachary | for pr in $PRS ; do eval title=$(curl --silent https://api.github.com/repos/ceph/ceph/pulls/$pr | jq .title) ; echo $title ; git log --oneline ceph/pull/$pr/merge^1..ceph/pull/$pr/merge^2 ; git merge --no-ff -m "$(echo -e "Merge $pr: $title\n\nReviewed-by: $reviewer")" ceph/pull/$pr/head ; done |
46 | 11 | Loïc Dachary | git push --force origin $release-backports |
47 | 1 | Loïc Dachary | </pre> |