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

Update skaraMirror.sh to handle upstream jdk(head) version branching #55

Merged
merged 2 commits into from
Jun 15, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ Historical information about the migration to OpenJDK GitHub from Mercurial is a
The script merges the appropriate latest merged "master" branch code into both "dev" and "release", it also ensures all the
"Adoptium Patches" from the "release" branch are merged into the "dev" branch.

The BRANCH environment variable defines the upstream master branch name, and defaults to "master" if not specified. The dev and release
mirror branches default to "dev" and "release" for "master", for other master branches they are "dev_$BRANCH" and "release_$BRANCH". This is to support
the new upstream OpenJDK head repository stabilization version branches (eg.jdk23, would use mirror branches dev_jdk23 and release_jdk23).
andrew-m-leonard marked this conversation as resolved.
Show resolved Hide resolved

The flow for the merge process is:
```mermaid

Expand Down
4 changes: 2 additions & 2 deletions patches/actions-ignore-branches.patch
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ index ec7e3c9957b..cac8a36dcaf 100644
push:
branches-ignore:
- master
+ - dev
+ - release
+ - dev*
+ - release*
- pr/*
- jdk*
workflow_dispatch:
Expand Down
95 changes: 48 additions & 47 deletions skaraMirror.sh
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,15 @@ function performMergeIntoReleaseFromMaster() {
buildTags=$(git tag --merged origin/"$BRANCH" $TAG_SEARCH || exit 1)
sortedBuildTags=$(echo "$buildTags" | eval "$jdk_sort_tags_cmd" || exit 1)

if ! git checkout -f release ; then
if ! git rev-parse -q --verify "origin/release" ; then
if ! git checkout -f "$RELEASE_BRANCH" ; then
if ! git rev-parse -q --verify "origin/$RELEASE_BRANCH" ; then
currentBuildTag=$(echo "$buildTags" | eval "$jdk_sort_tags_cmd" | tail -1 || exit 1)
git checkout -b release $currentBuildTag || exit 1
git checkout -b "$RELEASE_BRANCH" $currentBuildTag || exit 1
else
git checkout -b release origin/release || exit 1
git checkout -b "$RELEASE_BRANCH" "origin/$RELEASE_BRANCH" || exit 1
fi
else
git reset --hard origin/release || echo "Not resetting as no upstream exists"
git reset --hard "origin/$RELEASE_BRANCH" || echo "Not resetting as no upstream exists"
fi

# Apply our patches to release branch
Expand All @@ -115,7 +115,7 @@ function performMergeIntoReleaseFromMaster() {
fi

# Find the latest release tag that is not in releaseTagExcludeList
releaseTags=$(git tag --merged release $TAG_SEARCH || exit 1)
releaseTags=$(git tag --merged "$RELEASE_BRANCH" $TAG_SEARCH || exit 1)
sortedReleaseTags=$(echo "$releaseTags" | eval "$jdk_sort_tags_cmd" || exit 1)
currentReleaseTag=""
for tag in $sortedReleaseTags; do
Expand All @@ -129,16 +129,12 @@ function performMergeIntoReleaseFromMaster() {
fi
done
fi
if [[ "$tag" == *\-b00 ]] || [[ "$tag" == *\+0 ]]; then
echo "Skipping fork point tag $tag from current list"
skipThisTag=true
fi
if [[ "$skipThisTag" == false ]]; then
currentReleaseTag="$tag"
fi
done

echo "Current release build tag: $currentReleaseTag"
echo "Current $RELEASE_BRANCH build tag: $currentReleaseTag"

# Merge any new builds since current release build tag
foundCurrentReleaseTag=false
Expand All @@ -160,25 +156,21 @@ function performMergeIntoReleaseFromMaster() {
fi
done
fi
if [[ "$tag" == *\-b00 ]] || [[ "$tag" == *\+0 ]]; then
echo "Skipping merge of fork point tag $tag"
mergeTag=false
fi
if [[ "$mergeTag" == true ]]; then
echo "Merging build tag $tag into release branch"
git merge -m"Merging $tag into release" $tag || exit 1
git tag -a "${tag}_adopt" -m "Merged $tag into release" || exit 1
echo "Merging build tag $tag into $RELEASE_BRANCH branch"
git merge -m"Merging $tag into $RELEASE_BRANCH" $tag || exit 1
git tag -a "${tag}_adopt" -m "Merged $tag into $RELEASE_BRANCH" || exit 1
newAdoptTags="${newAdoptTags} ${tag}_adopt"
fi
fi
done

if git rev-parse -q --verify "origin/release" ; then
git --no-pager log --oneline origin/release..release
if git rev-parse -q --verify "origin/$RELEASE_BRANCH" ; then
git --no-pager log --oneline "origin/$RELEASE_BRANCH..$RELEASE_BRANCH"
fi

# Find the latest and previous release tags that is not in releaseTagExcludeList
releaseTags=$(git tag --merged release $TAG_SEARCH || exit 1)
releaseTags=$(git tag --merged "$RELEASE_BRANCH" $TAG_SEARCH || exit 1)
sortedReleaseTags=$(echo "$releaseTags" | eval "$jdk_sort_tags_cmd" || exit 1)
prevReleaseTag=""
currentReleaseTag=""
Expand All @@ -193,18 +185,14 @@ function performMergeIntoReleaseFromMaster() {
fi
done
fi
if [[ "$tag" == *\-b00 ]] || [[ "$tag" == *\+0 ]]; then
echo "Skipping fork point tag $tag from current list"
skipThisTag=true
fi
if [[ "$skipThisTag" == false ]]; then
prevReleaseTag="${currentReleaseTag}"
currentReleaseTag="$tag"
fi
done
echo "New release build tag: $currentReleaseTag"
echo "New $RELEASE_BRANCH build tag: $currentReleaseTag"

git push --tags origin release || exit 1
git push --tags origin "$RELEASE_BRANCH" || exit 1

# Check if the last two build tags are the same commit, and ensure we have tagged both _adopt tags
if [ "x$prevReleaseTag" != "x" ]; then
Expand All @@ -216,8 +204,8 @@ function performMergeIntoReleaseFromMaster() {
currentReleaseAdoptTag="${currentReleaseTag}_adopt"
if [ "$(git tag -l "$prevReleaseAdoptTag")" != "" ]; then
if [ "$(git tag -l "$currentReleaseAdoptTag")" == "" ]; then
echo "Tagging new current release tag ${currentReleaseAdoptTag} which is same commit as the previous ${prevReleaseAdoptTag}"
git tag -a "${currentReleaseAdoptTag}" -m "Merged ${currentReleaseTag} into release" || exit 1
echo "Tagging new current $RELEASE_BRANCH tag ${currentReleaseAdoptTag} which is same commit as the previous ${prevReleaseAdoptTag}"
git tag -a "${currentReleaseAdoptTag}" -m "Merged ${currentReleaseTag} into $RELEASE_BRANCH" || exit 1
newAdoptTags="${newAdoptTags} ${currentReleaseAdoptTag}"
fi
fi
Expand All @@ -242,36 +230,36 @@ function performMergeIntoDevFromMaster() {
# Fetch latest and get latest master build tag
git fetch --all --tags

if ! git checkout -f dev ; then
if ! git rev-parse -q --verify "origin/dev" ; then
git checkout -b dev || exit 1
if ! git checkout -f "$DEV_BRANCH" ; then
if ! git rev-parse -q --verify "origin/$DEV_BRANCH" ; then
git checkout -b "$DEV_BRANCH" || exit 1
else
git checkout -b dev origin/dev || exit 1
git checkout -b "$DEV_BRANCH" "origin/$DEV_BRANCH" || exit 1
fi
else
git reset --hard origin/dev || echo "Not resetting as no upstream exists"
git reset --hard "origin/$DEV_BRANCH" || echo "Not resetting as no upstream exists"
fi

devTags=$(git tag --merged dev $TAG_SEARCH || exit 1)
devTags=$(git tag --merged "$DEV_BRANCH" $TAG_SEARCH || exit 1)
currentDevTag=$(echo "$devTags" | eval "$jdk_sort_tags_cmd" | tail -1 || exit 1)
echo "Current dev build tag: $currentDevTag"
echo "Current $DEV_BRANCH build tag: $currentDevTag"

# Merge master "HEAD"
echo "Merging origin/$BRANCH HEAD into dev branch"
git merge -m"Merging origin/$BRANCH HEAD into dev" origin/"$BRANCH" || exit 1
echo "Merging origin/$BRANCH HEAD into $DEV_BRANCH branch"
git merge -m"Merging origin/$BRANCH HEAD into $DEV_BRANCH" origin/"$BRANCH" || exit 1

# Merge latest patches from "release" branch
git merge -m"Merging latest patches from release branch" origin/release || exit 1
git merge -m"Merging latest patches from $RELEASE_BRANCH branch" "origin/$RELEASE_BRANCH" || exit 1

if git rev-parse -q --verify "origin/dev" ; then
git --no-pager log --oneline origin/dev..dev
if git rev-parse -q --verify "origin/$DEV_BRANCH" ; then
git --no-pager log --oneline "origin/$DEV_BRANCH..$DEV_BRANCH"
fi

devTags=$(git tag --merged dev $TAG_SEARCH || exit 1)
devTags=$(git tag --merged "$DEV_BRANCH" $TAG_SEARCH || exit 1)
currentDevTag=$(echo "$devTags" | eval "$jdk_sort_tags_cmd" | tail -1 || exit 1)
echo "New dev build tag: $currentDevTag"
echo "New $DEV_BRANCH build tag: $currentDevTag"

git push origin dev || exit 1
git push origin "$DEV_BRANCH" || exit 1
}

checkArgs $#
Expand All @@ -281,13 +269,24 @@ GITHUB_REPO="$1"
REPO=${2:-"[email protected]:adoptium/$GITHUB_REPO"}
BRANCH=${BRANCH:=master}

if [[ "${BRANCH}" == "master" ]]; then
RELEASE_BRANCH="release"
DEV_BRANCH="dev"
else
RELEASE_BRANCH="release_${BRANCH}"
DEV_BRANCH="dev_${BRANCH}"
fi

GITHUB_REPO_REMOVE_aarch32=${GITHUB_REPO#"aarch32"}
VERSION=${GITHUB_REPO_REMOVE_aarch32//[!0-9]/}
# Regex expands aarch32-jdk8u as 328
if [[ "${VERSION}" == "8" ]]; then
TAG_SEARCH="jdk${VERSION}*-*"
else
elif [[ -n "${VERSION}" ]]; then
TAG_SEARCH="jdk-${VERSION}*+*"
else
# jdk(head) repo tag sort finds latest tag for this repo & branch, note jdk(head) contains multiple versions
TAG_SEARCH="jdk-*+*"
fi

# JDK11+ tag sorting:
Expand All @@ -300,7 +299,8 @@ fi
jdk11plus_tag_sort1="sort -t+ -k2,2n"
# Second, (stable) sort on (V), (W), (X), (P): P(Patch) is optional and defaulted to "0"
jdk11plus_tag_sort2="sort -t. -k2,2n -k3,3n -k4,4n -k5,5n"
jdk11plus_sort_tags_cmd="grep -v _adopt | sed 's/jdk-/jdk./g' | sed 's/+/.0.0+/g' | $jdk11plus_tag_sort1 | nl -n rz | $jdk11plus_tag_sort2 | sed 's/\.0\.0+/+/g' | cut -f2- | sed 's/jdk./jdk-/g'"
# Ignore "..+0" branch fork point tags
jdk11plus_sort_tags_cmd="grep -v _adopt | grep -v '\+0$' | sed 's/jdk-/jdk./g' | sed 's/+/.0.0+/g' | $jdk11plus_tag_sort1 | nl -n rz | $jdk11plus_tag_sort2 | sed 's/\.0\.0+/+/g' | cut -f2- | sed 's/jdk./jdk-/g'"

# JDK8 tag sorting:
# We use sort and tail to choose the latest tag in case more than one refers the same commit.
Expand All @@ -309,7 +309,8 @@ jdk11plus_sort_tags_cmd="grep -v _adopt | sed 's/jdk-/jdk./g' | sed 's/+/.0.0+/g
jdk8_tag_sort1="sort -tb -k2,2n"
# Second, (stable) sort on (V), (W)
jdk8_tag_sort2="sort -tu -k2,2n"
jdk8_sort_tags_cmd="grep -v _adopt | $jdk8_tag_sort1 | nl -n rz | $jdk8_tag_sort2 | cut -f2-"
# Ignore "..-b00" branch fork point tags
jdk8_sort_tags_cmd="grep -v _adopt | grep -v '\-b00$' | $jdk8_tag_sort1 | nl -n rz | $jdk8_tag_sort2 | cut -f2-"


if [[ "${VERSION}" == "8" ]]; then
Expand Down