Skip to content

Commit

Permalink
Move vendor repo logic in getVendorTestMaterial() (#4818)
Browse files Browse the repository at this point in the history
The vendor repo logic is in getFunctionalTestMaterial().
If CLONE_OPENJ9 = false, then vendor repo material will not be cloned.
Move vendor repo logic in another function getVendorTestMaterial().
Clone vendor repo if VENDOR_REPOS is not empty.

Signed-off-by: Lan Xia <[email protected]>
  • Loading branch information
llxia authored and pshipton committed Nov 22, 2023
1 parent f4a92c1 commit e6c5fd4
Showing 1 changed file with 64 additions and 57 deletions.
121 changes: 64 additions & 57 deletions get.sh
Original file line number Diff line number Diff line change
Expand Up @@ -583,74 +583,77 @@ getFunctionalTestMaterial()
fi

rm -rf openj9
}

if [ "$VENDOR_REPOS" != "" ]; then
declare -a vendor_repos_array
declare -a vendor_branches_array
declare -a vendor_shas_array
declare -a vendor_dirs_array
getVendorTestMaterial() {
echo "get vendor test material..."
cd $TESTDIR

# convert VENDOR_REPOS to array
vendor_repos_array=(`echo $VENDOR_REPOS | sed 's/,/\n/g'`)
declare -a vendor_repos_array
declare -a vendor_branches_array
declare -a vendor_shas_array
declare -a vendor_dirs_array

if [ "$VENDOR_BRANCHES" != "" ]; then
# convert VENDOR_BRANCHES to array
vendor_branches_array=(`echo $VENDOR_BRANCHES | sed 's/,/\n/g'`)
fi
# convert VENDOR_REPOS to array
vendor_repos_array=(`echo $VENDOR_REPOS | sed 's/,/\n/g'`)

if [ "$VENDOR_SHAS" != "" ]; then
#convert VENDOR_SHAS to array
vendor_shas_array=(`echo $VENDOR_SHAS | sed 's/,/\n/g'`)
fi
if [ "$VENDOR_BRANCHES" != "" ]; then
# convert VENDOR_BRANCHES to array
vendor_branches_array=(`echo $VENDOR_BRANCHES | sed 's/,/\n/g'`)
fi

if [ "$VENDOR_DIRS" != "" ]; then
#convert VENDOR_DIRS to array
vendor_dirs_array=(`echo $VENDOR_DIRS | sed 's/,/\n/g'`)
fi
if [ "$VENDOR_SHAS" != "" ]; then
#convert VENDOR_SHAS to array
vendor_shas_array=(`echo $VENDOR_SHAS | sed 's/,/\n/g'`)
fi

for i in "${!vendor_repos_array[@]}"; do
# clone vendor source
repoURL=${vendor_repos_array[$i]}
branch=${vendor_branches_array[$i]}
sha=${vendor_shas_array[$i]}
dir=${vendor_dirs_array[$i]}
dest="vendor_${i}"

branchOption=""
if [ "$branch" != "" ]; then
branchOption="-b $branch"
fi
if [ "$VENDOR_DIRS" != "" ]; then
#convert VENDOR_DIRS to array
vendor_dirs_array=(`echo $VENDOR_DIRS | sed 's/,/\n/g'`)
fi

echo "git clone ${branchOption} $repoURL $dest"
git clone -q --depth 1 $branchOption $repoURL $dest
for i in "${!vendor_repos_array[@]}"; do
# clone vendor source
repoURL=${vendor_repos_array[$i]}
branch=${vendor_branches_array[$i]}
sha=${vendor_shas_array[$i]}
dir=${vendor_dirs_array[$i]}
dest="vendor_${i}"

branchOption=""
if [ "$branch" != "" ]; then
branchOption="-b $branch"
fi

if [ "$sha" != "" ]; then
cd $dest
echo "git fetch -q --unshallow"
git fetch -q --unshallow
echo "update to $sha"
git checkout $sha
cd $TESTDIR
fi
echo "git clone ${branchOption} $repoURL $dest"
git clone -q --depth 1 $branchOption $repoURL $dest

# move resources
if [ "$dir" != "" ] && [ -d $dest/$dir ]; then
echo "Stage $dest/$dir to $TESTDIR/$dir"
# already in TESTDIR, thus copy $dir to current directory
cp -r $dest/$dir ./
if [[ "$PLATFORM" == *"zos"* ]]; then
cp -r $dest/.git ./$dir
fi
else
echo "Stage $dest to $TESTDIR"
# already in TESTDIR, thus copy the entire vendor repo content to current directory
cp -r $dest/* ./
if [ "$sha" != "" ]; then
cd $dest
echo "git fetch -q --unshallow"
git fetch -q --unshallow
echo "update to $sha"
git checkout $sha
cd $TESTDIR
fi

# move resources
if [ "$dir" != "" ] && [ -d $dest/$dir ]; then
echo "Stage $dest/$dir to $TESTDIR/$dir"
# already in TESTDIR, thus copy $dir to current directory
cp -r $dest/$dir ./
if [[ "$PLATFORM" == *"zos"* ]]; then
cp -r $dest/.git ./$dir
fi
else
echo "Stage $dest to $TESTDIR"
# already in TESTDIR, thus copy the entire vendor repo content to current directory
cp -r $dest/* ./
fi

# clean up
rm -rf $dest
done
fi
# clean up
rm -rf $dest
done
}

testJavaVersion()
Expand Down Expand Up @@ -782,3 +785,7 @@ fi
if [ $CLONE_OPENJ9 != "false" ]; then
getFunctionalTestMaterial
fi

if [ "$VENDOR_REPOS" != "" ]; then
getVendorTestMaterial
fi

0 comments on commit e6c5fd4

Please sign in to comment.