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

Check testenv.properties JDKxx_BRANCH tags #5102

Merged
merged 27 commits into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 5 additions & 0 deletions get.sh
Original file line number Diff line number Diff line change
Expand Up @@ -763,16 +763,21 @@ checkOpenJ9RepoSHA()

parseCommandLineArgs "$@"
if [ "$USE_TESTENV_PROPERTIES" = true ]; then
teFile="./testenv/testenv.properties"
if [[ "$PLATFORM" == *"zos"* ]]; then
echo "load ./testenv/testenv_zos.properties"
source ./testenv/testenv_zos.properties
teFile="./testenv/testenv_zos.properties"
elif [[ "$PLATFORM" == *"arm"* ]] && [[ "$JDK_VERSION" == "8" ]] ; then
echo "load ./testenv/testenv_arm32.properties"
source ./testenv/testenv_arm32.properties
teFile="./testenv/testenv_arm32.properties"
else
echo "load ./testenv/testenv.properties"
source ./testenv/testenv.properties
fi
echo "Running checkTags with $teFile and $JDK_VERSION"
./scripts/testenv/checkTags.sh $teFile $JDK_VERSION
else
> ./testenv/testenv.properties
fi
Expand Down
78 changes: 78 additions & 0 deletions scripts/testenv/checkTags.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
#!/usr/bin/env bash
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

#!/usr/bin/env bash

# Check for whether the tag values of the JDKxx_BRANCH variable in the
# testenv.properties file exists. Handle cases where the value is a branch, tag or SHA
# If the value does not exist, strip off -ga and try finding the closest / latest tag
# with the same prefix


teFile=$1
jdkVersion=$2
repoFromPropFile="JDK${jdkVersion}_REPO"
branchFromPropFile="JDK${jdkVersion}_BRANCH"

usage ()
{
echo 'Usage : checkTags.sh testenv.properties JDK_VERSION'
}

getProperty() {
grep "${1}" ${teFile} | cut -d'=' -f2
}

setProperty(){
awk -v pat="^$1=" -v newval="$1=$2" '{ if ($0 ~ pat) print newval; else print $0; }' $teFile > $teFile.tmp
mv $teFile.tmp $teFile
}

workingTag="$(getProperty ${branchFromPropFile})"
workingRepo="$(getProperty ${repoFromPropFile})"

git ls-remote --exit-code -t $workingRepo $workingTag
if [ "$?" -eq "2" ]; then
# tag name does not exist, check if branch name exists
branchExists=$(git ls-remote --heads $workingRepo ${workingTag})
if [[ -z ${branchExists} ]]; then
# check if it is a SHA value
if [[ "$workingTag" =~ ^[a-zA-Z0-9]{7,40}$ ]]; then
# check if the SHA exists in the repository
shaExists=$(git ls-remote --heads --tags $workingRepo)
if [[ $shaExists =~ "$workingTag" ]]; then
echo "SHA $workingTag exists on $workingRepo"
exit 0
fi
fi
# strip out '-ga' from the tag name since it does not exist
workingTagPrefix=${workingTag//"-ga"/""}

# find the latest tag name with the same workingTagPrefix as the ga tag that does not currently exist
latestTag=$(git ls-remote --refs --tags $workingRepo ${workingTagPrefix}\* | cut -d '/' -f 3 | grep -v "_adopt" | tail -n1 )
if [[ $latestTag ]]; then
echo "Update $teFile with $branchFromPropFile=$latestTag instead of non-existent $workingTag"
export $branchFromPropFile=$latestTag
setProperty $branchFromPropFile $latestTag
else
echo "Unable to resolve the latest $branchFromPropFile=$workingTag tag from $repoFromPropFile"
exit 1
fi
else
echo "Use branch name $workingTag from $teFile"
exit 0
fi
else
echo "Use tag name $workingTag from $teFile"
fi
4 changes: 4 additions & 0 deletions testenv/testenv.properties
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,14 @@ JDK11_REPO=https://github.com/adoptium/jdk11u.git
JDK11_BRANCH=dev
JDK17_REPO=https://github.com/adoptium/jdk17u.git
JDK17_BRANCH=dev
JDK21_REPO=https://github.com/adoptium/jdk21u.git
JDK21_BRANCH=dev
JDK8_OPENJ9_REPO=https://github.com/ibmruntimes/openj9-openjdk-jdk8.git
JDK8_OPENJ9_BRANCH=openj9
JDK11_OPENJ9_REPO=https://github.com/ibmruntimes/openj9-openjdk-jdk11.git
JDK11_OPENJ9_BRANCH=openj9
JDK17_OPENJ9_REPO=https://github.com/ibmruntimes/openj9-openjdk-jdk17.git
JDK17_OPENJ9_BRANCH=openj9
JDK21_OPENJ9_REPO=https://github.com/ibmruntimes/openj9-openjdk-jdk21.git
JDK21_OPENJ9_BRANCH=openj9
AQA_REQUIRED_TARGETS=sanity.functional,extended.functional,special.functional,sanity.openjdk,extended.openjdk,sanity.system,extended.system,sanity.perf,extended.perf