Skip to content

Commit

Permalink
chore: add kokoro job for verifying presence of docker image (#664)
Browse files Browse the repository at this point in the history
* chore: add kokoro job for verifying presence of docker image
  • Loading branch information
mpeddada1 authored Oct 5, 2023
1 parent 8a6445f commit 87d50ee
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
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

0 comments on commit 87d50ee

Please sign in to comment.