Skip to content

Commit

Permalink
get sha for external tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sophia-guo committed Jan 30, 2025
1 parent a88d7bb commit d7d37ff
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion scripts/getSHAs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ usage ()
echo 'Usage : '
echo ' --test_root_dir: optional'
echo ' --shas_file: optional, the file to write the sha info to. Default is to ../SHAs.txt'

}

parseCommandLineArgs()
Expand Down Expand Up @@ -62,14 +61,41 @@ getSHAs()
touch "$SHAs_FILE"
fi

# Get SHA for non-external tests by find .git dir
cd "$TEST_ROOT" || exit
find "$TEST_ROOT" -type d -name ".git" | while read -r gitDir; do
repoDir=$(dirname "$gitDir")
cd "$repoDir" || continue
# append the info into $SHAs_FILR
{ echo "================================================"; echo "timestamp: $(timestamp)"; echo "repo dir: $repoDir"; echo "git repo: "; git remote show origin -n | grep "Fetch URL:"; echo "sha:"; git rev-parse HEAD; } 2>&1 | tee -a "$SHAs_FILE"
done

cd "$TEST_ROOT" || exit
# Get SHA for external tests by test.properties
if [[ "$BUILD_LIST" == *"external"* ]]; then
for subDir in "$JVM_TEST_ROOT"/external/*/; do
if [[ $(find "$subDir" -type f -name 'Dockerfile.*') ]]; then
propertiesFile="$subDir/test.properties"
if [[ -f "$propertiesFile" ]]; then
# read github_url and tag_version
github_url=$(grep '^github_url=' "$propertiesFile" | cut -d"=" -f2 | tr -d '"')
tag_version=$(grep '^tag_version=' "$propertiesFile" | cut -d"=" -f2 | tr -d '"')

if [[ -z "$github_url" || -z "$tag_version" ]]; then
echo "No github_url or tag_version in $propertiesFile"
continue
fi

# Retrieve the SHA using github_url and tag_version
sha=$(git ls-remote "$github_url" "refs/tags/$tag_version" | awk '{print $1}')
# append the info into $SHAs_FILR
{ echo "================================================"; echo "timestamp: $(timestamp)"; echo "repo dir: $subDir"; echo "git repo: $github_url"; echo "sha:$sha";} 2>&1 | tee -a "$SHAs_FILE"
fi
fi
done
fi
}

parseCommandLineArgs "$@"
getSHAs
cd "$workDIR" || exit
Expand Down

0 comments on commit d7d37ff

Please # to comment.