From: Don Zickus on gitlab.com Merge Request: https://gitlab.com/cki-project/kernel-ark/-/merge_requests/2969
The nightly rt merging cronjob immediately failed the second night because I forgot to push the intermediary branch rt-automated-devel. So when it got rebuilt the next night from scratch it got merged into rt-devel and automotive-devel in a way that required those branches to be forced pushed. Not good for development.
The easy way is to push that branch but that requires re-pushing rt-devel and automotive-devel. Not hard. Instead I wanted to remove that intermediary branch leaving less complicated logic and rely on an octopus merge. Should work better now and simpler to read.
Signed-off-by: Don Zickus dzickus@redhat.com
--- redhat/scripts/ci/ark-ci-env.sh | 24 +++++++---- redhat/scripts/ci/ark-merge-rt.sh | 81 ++++++++++++++++---------------------- 2 files changed, 50 insertions(+), 55 deletions(-)
From: Don Zickus dzickus@redhat.com
Add support for CI octopus merging
The intermediate branch rt-automated-devel was getting in the way as it needed to be pushed with rt-devel and automotive-devel. In prep to remove that logic, add support for an octopus merge.
This requires creating another temporary branch for rebasing and changing how ark_git_merge logic works.
Signed-off-by: Don Zickus dzickus@redhat.com
diff --git a/redhat/scripts/ci/ark-ci-env.sh b/redhat/scripts/ci/ark-ci-env.sh index blahblah..blahblah 100644 --- a/redhat/scripts/ci/ark-ci-env.sh +++ b/redhat/scripts/ci/ark-ci-env.sh @@ -56,22 +56,28 @@ ark_git_mirror() # Merge wrapper in case issues arise ark_git_merge() { - source_branch="$1" - target_branch="$2" - reset_branch="$3" + target_branch="$1" + branches="$2"
prev_branch="$(git rev-parse --abbrev-ref HEAD)" - ark_git_branch "$target_branch" "$source_branch" + + # support octopus merge with branches variable. + # can't find a better way to convert multi branch string into + # something consumable for git-merge. So convert to array and feed + # the array to git-merge. Ugly but it works. + read -r -a source_branch <<< "$branches" + ark_git_branch "$target_branch" "${source_branch[@]}" git checkout "$target_branch" - if test -n "$reset_branch"; then - # there are cases when the initial merge is a reset - git reset --hard "$source_branch" || die "git reset $source_branch failed" - elif ! git merge -m "Merge '$source_branch' into '$target_branch'" "$source_branch"; then + + # array causes headache to git-merge, use temp var msg + msg="Merge '${source_branch[@]}' into '$target_branch'" + + if ! git merge -m "$msg" "${source_branch[@]}"; then git merge --abort printf "Merge conflict; halting!\n" printf "To reproduce:\n" printf "* git checkout %s\n" "${target_branch}" - printf "* git merge %s\n" "${source_branch}" + printf "* git merge %s\n" "${source_branch[@]}" die "Merge conflicts" fi
diff --git a/redhat/scripts/ci/ark-merge-rt.sh b/redhat/scripts/ci/ark-merge-rt.sh index blahblah..blahblah 100755 --- a/redhat/scripts/ci/ark-merge-rt.sh +++ b/redhat/scripts/ci/ark-merge-rt.sh @@ -111,6 +111,7 @@ if test "$UPSTREAM_RT_DEVEL_VER" != "$OS_BUILD_VER"; then # os-build stable tag OS_BUILD_BASE_BRANCH="kernel-${MASTER_RT_DEVEL_VER}.0-0" fi +UPSTREAM_RT_PREV_BRANCH=""
# verify the core branches exist or use provided defaults UPSTREAM_RT_DEVEL_BRANCH="linux-${UPSTREAM_RT_DEVEL_VER}.y-rt" @@ -140,33 +141,48 @@ ark_git_mirror "$DOWNSTREAM_RT_BRANCH" "$UPSTREAM_RT_TREE_NAME" "$UPSTREAM_RT_DE # finally merge the two correct branches ark_git_merge "$OS_BUILD_BASE_BRANCH" "$RT_AUTOMATED_BRANCH" "$RT_REBASE" ark_git_merge "$DOWNSTREAM_RT_BRANCH" "$RT_AUTOMATED_BRANCH" +# handle rebasing +if test "$UPSTREAM_RT_DEVEL_VER" != "$RT_DEVEL_VER" -o \ + "$UPSTREAM_RT_DEVEL_VER" != "$AUTOMOTIVE_DEVEL_VER"; then + # we need the previous rt branch for rebase purposes + UPSTREAM_RT_PREV_BRANCH="linux-${OS_BUILD_VER_prev}.y-rt" + git fetch -q "$UPSTREAM_RT_TREE_NAME" "$UPSTREAM_RT_PREV_BRANCH"
-## MERGE the upstream branches to the development branches -if test -n "$RT_REBASE"; then # handle the rebase # rebases usually go from prev version to new version - # rebuild the prev merge base in case the previous automated one is - # corrupted. + # rebuild the prev merge base as it isn't saved. + # then rebuild the current merge base as it isn't saved either + # because we use an octopus merge below. prev_branch="$(git rev-parse --abbrev-ref HEAD)" - temp_branch="_temp_rt_devel_$(date +%F)" - git branch -D "$temp_branch" 2>/dev/null - git checkout -b "$temp_branch" "kernel-${OS_BUILD_VER_prev}.0-0" - git merge "$UPSTREAM_RT_TREE_NAME/linux-${OS_BUILD_VER_prev}.y-rt" + temp_prev_branch="_temp_prev_rt_devel_$(date +%F)" + git branch -D "$temp_prev_branch" 2>/dev/null + git fetch "$UPSTREAM_RT_TREE_NAME" "$UPSTREAM_RT_PREV_BRANCH" + git checkout -b "$temp_prev_branch" "kernel-${OS_BUILD_VER_prev}.0-0" + git merge "$UPSTREAM_RT_TREE_NAME/$UPSTREAM_RT_PREV_BRANCH" + + # create devel merge branch to base octopus merge on. + temp_devel_branch="_temp_devel_rt_devel_$(date +%F)" + git branch -D "$temp_devel_branch" 2>/dev/null + git checkout -b "$temp_devel_branch" "$OS_BUILD_BASE_BRANCH" + git merge "$UPSTREAM_RT_TREE_NAME/$UPSTREAM_RT_DEVEL_BRANCH" + git checkout "$prev_branch" - ark_git_rebase "$RT_DEVEL_BRANCH" "$temp_branch" "$RT_AUTOMATED_BRANCH" - ark_git_rebase "$AUTOMOTIVE_DEVEL_BRANCH" "$temp_branch" "$RT_AUTOMATED_BRANCH" - git branch -D "$temp_branch" + # do the git rebase --onto $temp_devel_branch $temp_prev_branch + ark_git_rebase "$RT_DEVEL_BRANCH" "$temp_prev_branch" "$temp_devel_branch" + ark_git_rebase "$AUTOMOTIVE_DEVEL_BRANCH" "$temp_prev_branch" "$temp_devel_branch" + git branch -D "$temp_prev_branch" + git branch -D "$temp_devel_branch" fi
## Build -rt-devel branch, generate pending-rhel configs -ark_git_merge "$RT_AUTOMATED_BRANCH" "$RT_DEVEL_BRANCH" +ark_git_merge "$RT_DEVEL_BRANCH" "$OS_BUILD_BASE_BRANCH $UPSTREAM_RT_TREE_NAME/$UPSTREAM_RT_DEVEL_BRANCH" # don't care if configs were added or not hence '|| true' ark_update_configs "$RT_DEVEL_BRANCH" || true # skip pushing config update MRs, keep them in pending-rhel ark_push_changes "$RT_DEVEL_BRANCH" "skip"
## Build -automotive-devel branch, generate pending-rhel configs -ark_git_merge "$RT_AUTOMATED_BRANCH" "$AUTOMOTIVE_DEVEL_BRANCH" +ark_git_merge "$AUTOMOTIVE_DEVEL_BRANCH" "$OS_BUILD_BASE_BRANCH $UPSTREAM_RT_TREE_NAME/$UPSTREAM_RT_DEVEL_BRANCH" # don't care if configs were added or not hence '|| true' ark_update_configs "$AUTOMOTIVE_DEVEL_BRANCH" || true # skip pushing config update MRs, keep them in pending-rhel
-- https://gitlab.com/cki-project/kernel-ark/-/merge_requests/2969
From: Don Zickus dzickus@redhat.com
Remove rt-automated and master-rt-devel logic
Rely on less branch logic to build and maintain the rt tree. Using the rt-automated-devel and master-rt-devel branches requires pushing them and keeping them in sync. With octopus merging, we don't need them and can rely on temporary branches instead.
Remove the logic for those two branches.
Signed-off-by: Don Zickus dzickus@redhat.com
diff --git a/redhat/scripts/ci/ark-merge-rt.sh b/redhat/scripts/ci/ark-merge-rt.sh index blahblah..blahblah 100755 --- a/redhat/scripts/ci/ark-merge-rt.sh +++ b/redhat/scripts/ci/ark-merge-rt.sh @@ -24,8 +24,6 @@ set -e #Upstream RT tree git://git.kernel.org/pub/scm/linux/kernel/git/rt/linux-rt-devel.git UPSTREAM_RT_TREE_URL="git://git.kernel.org/pub/scm/linux/kernel/git/rt/linux-rt-devel.git" UPSTREAM_RT_TREE_NAME="linux-rt-devel" -DOWNSTREAM_RT_BRANCH="master-rt-devel" -RT_AUTOMATED_BRANCH="os-build-rt-automated" RT_DEVEL_BRANCH="os-build-rt-devel" AUTOMOTIVE_DEVEL_BRANCH="os-build-automotive-devel"
@@ -41,10 +39,6 @@ ark_git_mirror "master" "origin" "master" # make sure tags are available for git-describe to correctly work git fetch -t origin
-# upstream -rt devel branches are aligned with version numbers and are not -# always up to date with master. Figure out which branch to mirror based on -# version number and existance. We may have to trigger a rebase. - # what are the current versions of rt-devel and os-build (use 'master' to # avoid fedora tagging of kernel-X.Y.0.0.....) # use git tags which are always 'vX.Y-rcZ-aaa-gbbbbb' or 'vX.Y-aaa-gbbbbb' @@ -94,56 +88,35 @@ get_prev_version() OS_BUILD_VER="$(get_upstream_version os-build)" OS_BUILD_VER_prev="$(get_prev_version "$OS_BUILD_VER")"
+# upstream -rt devel branches are aligned with version numbers and are not +# always up to date with master. Figure out which branch to mirror based on +# version number and existance. We may have to trigger a rebase. + # check latest upstream RT branch if git fetch -q "$UPSTREAM_RT_TREE_NAME" "linux-${OS_BUILD_VER}.y-rt"; then UPSTREAM_RT_DEVEL_VER="${OS_BUILD_VER}" + OS_BUILD_BASE_BRANCH="os-build" elif git fetch -q "$UPSTREAM_RT_TREE_NAME" "linux-${OS_BUILD_VER_prev}.y-rt"; then UPSTREAM_RT_DEVEL_VER="${OS_BUILD_VER_prev}" + OS_BUILD_BASE_BRANCH="kernel-${UPSTREAM_RT_DEVEL_VER}.0-0" else die "Neither version ($OS_BUILD_VER, $OS_BUILD_VER_prev) in upstream tree: $UPSTREAM_RT_TREE_NAME" fi
-OS_BUILD_BASE_BRANCH="os-build" -RT_REBASE="" - -if test "$UPSTREAM_RT_DEVEL_VER" != "$OS_BUILD_VER"; then - # no newer upstream branch to rebase onto, continue with an - # os-build stable tag - OS_BUILD_BASE_BRANCH="kernel-${MASTER_RT_DEVEL_VER}.0-0" -fi UPSTREAM_RT_PREV_BRANCH=""
# verify the core branches exist or use provided defaults UPSTREAM_RT_DEVEL_BRANCH="linux-${UPSTREAM_RT_DEVEL_VER}.y-rt" -ark_git_branch "$DOWNSTREAM_RT_BRANCH" "$UPSTREAM_RT_TREE_NAME/$UPSTREAM_RT_DEVEL_BRANCH" -ark_git_branch "$RT_AUTOMATED_BRANCH" "$OS_BUILD_BASE_BRANCH" ark_git_branch "$RT_DEVEL_BRANCH" "$OS_BUILD_BASE_BRANCH" ark_git_branch "$AUTOMOTIVE_DEVEL_BRANCH" "$OS_BUILD_BASE_BRANCH"
-MASTER_RT_DEVEL_VER="$(get_upstream_version "$DOWNSTREAM_RT_BRANCH")" -RT_AUTOMATED_VER="$(get_upstream_version $RT_AUTOMATED_BRANCH)" RT_DEVEL_VER="$(get_upstream_version $RT_DEVEL_BRANCH)" AUTOMOTIVE_DEVEL_VER="$(get_upstream_version $AUTOMOTIVE_DEVEL_BRANCH)"
-# sanity check, sometimes broken scripts leave a mess -if test "$MASTER_RT_DEVEL_VER" != "$UPSTREAM_RT_DEVEL_VER" -o \ - "$MASTER_RT_DEVEL_VER" != "$RT_AUTOMATED_VER" -o \ - "$MASTER_RT_DEVEL_VER" != "$RT_DEVEL_VER" -o \ - "$MASTER_RT_DEVEL_VER" != "$AUTOMOTIVE_DEVEL_VER"; then - # rebase time - RT_REBASE="yes" -fi - -## PREP the upstream branches -# on a rebase, propogate all the git resets -# fetch the determined rt-devel branch -ark_git_mirror "$DOWNSTREAM_RT_BRANCH" "$UPSTREAM_RT_TREE_NAME" "$UPSTREAM_RT_DEVEL_BRANCH" "$RT_REBASE" -# finally merge the two correct branches -ark_git_merge "$OS_BUILD_BASE_BRANCH" "$RT_AUTOMATED_BRANCH" "$RT_REBASE" -ark_git_merge "$DOWNSTREAM_RT_BRANCH" "$RT_AUTOMATED_BRANCH" # handle rebasing if test "$UPSTREAM_RT_DEVEL_VER" != "$RT_DEVEL_VER" -o \ "$UPSTREAM_RT_DEVEL_VER" != "$AUTOMOTIVE_DEVEL_VER"; then + # we need the previous rt branch for rebase purposes UPSTREAM_RT_PREV_BRANCH="linux-${OS_BUILD_VER_prev}.y-rt" git fetch -q "$UPSTREAM_RT_TREE_NAME" "$UPSTREAM_RT_PREV_BRANCH"
-- https://gitlab.com/cki-project/kernel-ark/-/merge_requests/2969
kernel@lists.fedoraproject.org