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

chore: add kokoro job for verifying presence of docker image #664

Merged
merged 10 commits into from
Oct 5, 2023
12 changes: 12 additions & 0 deletions .kokoro/presubmit/graalvm-docker.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Format: //devtools/kokoro/config/proto/build.proto

# Configure the docker image for kokoro-trampoline.
env_vars: {
key: "TRAMPOLINE_IMAGE"
value: "gcr.io/cloud-devrel-kokoro-resources/java8"
}

env_vars: {
key: "TRAMPOLINE_BUILD_FILE"
value: "github/java-shared-config/.kokoro/verify-docker-images.sh"
}
37 changes: 37 additions & 0 deletions .kokoro/verify-docker-images.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/bash

# Script to verify the presence of GraalVM docker test images tagged with the latest java-shared-config version.

function fetch_image_names() {
imageNames="$(grep " - gcr.io/cloud-devrel-public-resources/" .cloudbuild/cloudbuild.yaml | cut -d "/" -f 3 | cut -d ":" -f 1)"
export imageNames
echo "$imageNames"
}

# Get the directory of the build script
scriptDir=$(realpath "$(dirname "${BASH_SOURCE[0]}")")
# cd to the parent directory, i.e. the root of the git repo
cd ${scriptDir}/.. || exit

# Fetch the java-shared-config version in source of the current commit.
javaSharedConfigVersion="$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)"

branchName=$(git name-rev "$KOKORO_GIT_COMMIT" | sed 's/.* //')
gitCommitMessage=$(git log -1 "$(git rev-parse --short "$KOKORO_GIT_COMMIT")" | grep "chore(main): release *")

# GraalVM docker images are not tagged with SNAPSHOT versions.
if [[ "${branchName}" == *"release-please--branches--main"* ]] && [[ ! $gitCommitMessage =~ "SNAPSHOT" ]]; then
imageNames=$(fetch_image_names)
for name in $imageNames; do
fullContainerName="gcr.io/cloud-devrel-public-resources/${name}:${javaSharedConfigVersion}"
echo "Verifying presence of ${fullContainerName}."
gcloud container images describe "${fullContainerName}" > /dev/null; exit_status=$?
if [[ $exit_status = 0 ]]; then
echo "Success. Found $fullContainerName."
fi
done
RETURN_CODE=$?
else
echo "Skipping check for non-release and SNAPSHOT update branches"
exit 0
fi