From bfff55ab4dfef13eb8305714696c93080708baa0 Mon Sep 17 00:00:00 2001 From: Lawrence Qiu Date: Mon, 31 Aug 2026 15:36:46 +0000 Subject: [PATCH] perf(ci): replace mvn help:evaluate and redundant subprocesses with native bash, sed, and git optimizations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This PR is part 2 of 2 in a stacked series: 1. #14217: fix: avoid running split ITs unexpectedly on unrelated changes (#12029) 2. This PR: perf(ci): replace mvn help:evaluate with native bash and sed extraction In Kokoro CI and automation scripts, heavy subprocesses and JVM invocations were used: - In generate_modified_modules_list (.kokoro/common.sh), evaluating project.modules launched a full JVM and evaluated the monorepo POMs, taking 20–30+ seconds on every single CI run. - In downstream-build.sh (.kokoro/presubmit/downstream-build.sh) and showcase-native.sh (sdk-platform-java/.kokoro/presubmit/showcase-native.sh), evaluating gapic-showcase.version launched Maven JVM processes. - In check_status.sh (java-cloud-bom/tests/release-repository-readiness/check_status.sh), mvn help:evaluate was called for shared dependencies and generator versions, and table formatting piped echo into awk. - In update_javadoc.sh (google-auth-library-java/scripts/update_javadoc.sh), maven-help-plugin:evaluate was called to obtain the project version. - In update_googleapis_commit.sh (sdk-platform-java/.github/scripts/update_googleapis_commit.sh), a full git clone of googleapis was performed just to inspect HEAD commitish. - In downstream-protobuf-binary-compatibility.sh (sdk-platform-java/.kokoro/nightly/downstream-protobuf-binary-compatibility.sh), cat/grep/cut was run on versions.txt on every loop iteration. - In check_existing_release_versions.sh (generation/check_existing_release_versions.sh), xmllint was run 3 separate times per POM. Optimizations: - Pure-Bash Module Extraction: Updated generate_modified_modules_list to use extract_pom_modules pom.xml, extracting all 270 modules in ~0.02s without JVM boot overhead. - Sed Showcase Version Extraction: Updated downstream-build.sh and showcase-native.sh to parse directly using sed with fail-fast validation, and added --fail to curl. - XML Tag Extraction & Printf Formatting: Updated check_status.sh to extract XML tags directly with sed and replaced pipe-to-awk with built-in printf formatting. - Sed Javadoc Version Extraction: Updated update_javadoc.sh to parse project version from pom.xml using sed. - Git Ls-Remote: Updated update_googleapis_commit.sh to query HEAD commit using git ls-remote instead of cloning the repository. - Associative Array Pre-caching: Pre-cached versions.txt into declare -A versions_map in downstream-protobuf-binary-compatibility.sh instead of invoking cat/grep/cut per artifact. - Combined XPath Query: Combined 3 xmllint calls into a single concat() XPath extraction in check_existing_release_versions.sh. - Unit Tests: Verified existing unit tests in .kokoro/common_test.sh and ran bash -n and git diff --check across all modified scripts. - Refactoring & Best Practices: Scoped temporary variables as local, used pure-bash whitespace trimming and string manipulations, and anchored relative paths. --- .kokoro/common.sh | 95 +++++++++++-------- .kokoro/common_test.sh | 70 ++++++++++++++ .kokoro/presubmit/downstream-build.sh | 19 +++- generation/check_existing_release_versions.sh | 10 +- .../scripts/update_javadoc.sh | 4 +- .../check_status.sh | 34 ++++--- .../scripts/update_googleapis_commit.sh | 13 +-- ...ownstream-protobuf-binary-compatibility.sh | 20 ++-- .../.kokoro/presubmit/showcase-native.sh | 14 ++- 9 files changed, 197 insertions(+), 82 deletions(-) diff --git a/.kokoro/common.sh b/.kokoro/common.sh index ee6770a9d6e1..3b1f685a745b 100644 --- a/.kokoro/common.sh +++ b/.kokoro/common.sh @@ -90,53 +90,55 @@ function retry_with_backoff { # and naturally survives single-module components without throwing exit signals. function extract_pom_modules() { local pom_file="$1" - local modules_list="" + if [[ ! -f "${pom_file}" ]]; then + return 1 + fi + local line module local in_profiles=false local in_modules=false - - while IFS= read -r line || [ -n "$line" ]; do - if [[ "$line" == *""* ]]; then + local -a modules=() + + while IFS= read -r line || [[ -n "${line}" ]]; do + if [[ "${line}" == *""* ]]; then in_profiles=true - elif [[ "$line" == *""* ]]; then + elif [[ "${line}" == *""* ]]; then in_profiles=false - elif [[ "$line" == *""* ]] && [ "$in_profiles" = false ]; then + elif [[ "${line}" == *""* && "${in_profiles}" == "false" ]]; then in_modules=true - elif [[ "$line" == *""* ]] && [ "$in_profiles" = false ]; then + elif [[ "${line}" == *""* && "${in_profiles}" == "false" ]]; then in_modules=false break - elif [ "$in_modules" = true ] && [[ "$line" == *""* ]]; then + elif [[ "${in_modules}" == "true" && "${line}" == *""* ]]; then # Extract text between tags - local module="${line#*}" + module="${line#*}" module="${module%*}" - - # Trim whitespace natively - module="${module#"${module%%[![:space:]]*}"}" - module="${module%"${module##*[![:space:]]}"}" - - if [ -z "$modules_list" ]; then - modules_list="$module" - else - modules_list="${modules_list} ${module}" + + # Trim leading/trailing whitespace without spawning external processes + read -r module <<< "${module}" + + if [[ -n "${module}" ]]; then + modules+=("${module}") fi fi - done < "$pom_file" - - echo "$modules_list" + done < "${pom_file}" + + echo "${modules[*]}" } # Given a folder containing a maven multi-module, assign the variable 'submodules' to a # comma-delimited list of /. function parse_submodules() { submodules_array=() - if [ -f "$1/pom.xml" ]; then + if [[ -f "$1/pom.xml" ]]; then local modules + local submodule # Use pure Bash extraction to find the modules in the aggregator pom file. # Faster than invoking mvn help:evaluate to list all the project modules, # cleanly ignores optional , and gracefully skips flat POMs. modules=$(extract_pom_modules "$1/pom.xml") - if [ -n "$modules" ]; then - for submodule in $modules; do + if [[ -n "${modules}" ]]; then + for submodule in ${modules}; do # Each entry = / submodules_array+=("$1/${submodule}") done @@ -282,39 +284,50 @@ function generate_modified_modules_list() { files=$(get_modified_files) printf "Modified files:\n%s\n" "${files}" - # Generate the list of valid maven modules - maven_modules_list=$(mvn help:evaluate -Dexpression=project.modules | grep '<.*>.*' | sed -e 's/<.*>\(.*\)<\/.*>/\1/g') + # Extract valid maven modules directly from pom.xml in pure Bash (~0.02s). + # This replaces 'mvn help:evaluate -Dexpression=project.modules' which previously + # spent 20-30+ seconds booting a JVM and evaluating the monorepo POMs on every run. + local maven_modules_list + maven_modules_list=$(extract_pom_modules pom.xml) maven_modules=() - # If the first argument is "true" (default), then use the module exclusion list - use_exclusion_list=${1:-true} + # Positional parameter $1 specifies whether to apply the exclusion list (defaults to true). + local use_exclusion_list="${1:-true}" + local -a all_modules=() + read -r -a all_modules <<< "${maven_modules_list}" + + local module if [[ "${use_exclusion_list}" == "true" ]]; then echo "Excluding modules from the global exclusion list" - for module in $maven_modules_list; do - if [[ ! " ${excluded_modules[*]} " =~ " ${module} " ]]; then + for module in "${all_modules[@]}"; do + if [[ ! " ${excluded_modules[*]} " == *" ${module} "* ]]; then maven_modules+=("${module}") fi done else - maven_modules=(${maven_modules_list[*]}) + maven_modules=("${all_modules[@]}") fi modified_module_list=() # If either parent pom.xml or core shared dependency is touched, run ITs on all the modules if should_test_all_modules; then - modified_module_list=(${maven_modules[*]}) + # '("${maven_modules[@]}")' copies the array elements safely. + modified_module_list=("${maven_modules[@]}") echo "Testing the entire monorepo" else - modules=$(echo "${files}" | grep -E '(google-auth|java)-.*' || true) + # Extract the top-level directory from each modified file path: + # 'cut -d '/' -f1' takes the first path segment (e.g. 'java-bigquery/src/...' -> 'java-bigquery'). + # 'sort -u' sorts and deduplicates the candidate directory names. + local modules + modules=$(cut -d '/' -f1 <<< "${files}" | sort -u) printf "Files in java modules:\n%s\n" "${modules}" - if [[ -n $modules ]]; then - modules=$(echo "${modules}" | cut -d '/' -f1 | sort -u) - for module in $modules; do - if [[ " ${maven_modules[*]} " =~ " ${module} " ]]; then - modified_module_list+=("${module}") - fi - done - else + for module in ${modules}; do + # If this top-level directory is a recognized Maven module, add it to our list. + if [[ " ${maven_modules[*]} " == *" ${module} "* ]]; then + modified_module_list+=("${module}") + fi + done + if [[ ${#modified_module_list[@]} -eq 0 ]]; then echo "Found no changes in the java modules" fi fi diff --git a/.kokoro/common_test.sh b/.kokoro/common_test.sh index 247a6a26cbfc..bc1b5368cb35 100755 --- a/.kokoro/common_test.sh +++ b/.kokoro/common_test.sh @@ -81,6 +81,35 @@ function test_parse_pom_version { popd } +# Test that extract_pom_modules correctly extracts modules from root pom.xml +# in pure Bash without launching Maven, and handles non-existent files safely. +function test_extract_pom_modules { + local -a modules + read -r -a modules <<< "$(extract_pom_modules "${scriptDir}/../pom.xml")" + if (( ${#modules[@]} < 200 )); then + echo "extract_pom_modules failed: expected at least 200 modules, got ${#modules[@]}" + exit 1 + fi + if [[ ! " ${modules[*]} " =~ " java-bigquery " ]]; then + echo "extract_pom_modules missing java-bigquery" + exit 1 + fi + if [[ ! " ${modules[*]} " =~ " java-bigquerystorage " ]]; then + echo "extract_pom_modules missing java-bigquerystorage" + exit 1 + fi + if [[ ! " ${modules[*]} " =~ " sdk-platform-java " ]]; then + echo "extract_pom_modules missing sdk-platform-java" + exit 1 + fi + + # Verify non-existent file returns 1 and empty output + if extract_pom_modules "non_existent_pom.xml" &>/dev/null; then + echo "extract_pom_modules should return non-zero for non-existent pom" + exit 1 + fi +} + # Tests that is_module_modified strictly matches the module directory prefix, # preventing prefix collisions (e.g. java-bigquery vs java-bigquerystorage). function test_is_module_modified { @@ -191,10 +220,51 @@ function test_mock_get_modified_files { unset TEST_MODIFIED_FILES } +# Test that generate_modified_modules_list correctly maps modified files to +# their top-level module names without requiring mvn help:evaluate. +function test_generate_modified_modules_list { + pushd "${scriptDir}/.." >/dev/null + TEST_MODIFIED_FILES="java-bigquery/google-cloud-bigquery/src/main/java/Foo.java +sdk-platform-java/gax-java/pom.xml" + generate_modified_modules_list false >/dev/null + + local has_bigquery="false" + local has_sdk_platform="false" + local has_bigquerystorage="false" + + if [[ " ${modified_module_list[*]} " =~ " java-bigquery " ]]; then + has_bigquery="true" + fi + if [[ " ${modified_module_list[*]} " =~ " sdk-platform-java " ]]; then + has_sdk_platform="true" + fi + if [[ " ${modified_module_list[*]} " =~ " java-bigquerystorage " ]]; then + has_bigquerystorage="true" + fi + + popd >/dev/null + unset TEST_MODIFIED_FILES + + if [[ "${has_bigquery}" != "true" ]]; then + echo "generate_modified_modules_list missing java-bigquery" + exit 1 + fi + if [[ "${has_sdk_platform}" != "true" ]]; then + echo "generate_modified_modules_list missing sdk-platform-java" + exit 1 + fi + if [[ "${has_bigquerystorage}" == "true" ]]; then + echo "generate_modified_modules_list incorrectly included java-bigquerystorage" + exit 1 + fi +} + test_find_all_poms_with_versioned_dependency test_update_pom_dependency test_parse_pom_version test_mock_get_modified_files +test_extract_pom_modules test_should_test_all_modules test_is_module_modified +test_generate_modified_modules_list diff --git a/.kokoro/presubmit/downstream-build.sh b/.kokoro/presubmit/downstream-build.sh index aa6781b1ffee..e040986c85f4 100755 --- a/.kokoro/presubmit/downstream-build.sh +++ b/.kokoro/presubmit/downstream-build.sh @@ -47,14 +47,23 @@ pushd java-showcase modify_shared_config popd -# Parse showcase version from the local directory -pushd java-showcase/gapic-showcase -SHOWCASE_VERSION=$(mvn help:evaluate -Dexpression=gapic-showcase.version -q -DforceStdout) -popd +# Extract the showcase version directly from pom.xml using sed: +# - 'sed -n': suppresses default line printing. +# - 's:...[[:space:]]*\([^<[:space:]]*\).*:\1:p': captures non-whitespace version text and prints it. +# - '/.../q': quits immediately on first match, avoiding trailing passes and external pipe utilities. +# This replaces 'mvn help:evaluate' which previously took 15+ seconds to boot Maven. +SHOWCASE_VERSION=$(sed -n 's:.*[[:space:]]*\([^<[:space:]]*\).*:\1:p; //q' java-showcase/gapic-showcase/pom.xml) + +# Fail fast with a clear error message if the version could not be parsed, +# preventing malformed curl URLs and ambiguous downstream failures. +if [[ -z "${SHOWCASE_VERSION}" ]]; then + echo "Error: Failed to parse gapic-showcase.version from java-showcase/gapic-showcase/pom.xml" >&2 + exit 1 +fi # Start showcase server mkdir -p /usr/src/showcase -curl --location https://github.com/googleapis/gapic-showcase/releases/download/v"${SHOWCASE_VERSION}"/gapic-showcase-"${SHOWCASE_VERSION}"-linux-amd64.tar.gz --output /usr/src/showcase/showcase-"${SHOWCASE_VERSION}"-linux-amd64.tar.gz +curl --fail --location https://github.com/googleapis/gapic-showcase/releases/download/v"${SHOWCASE_VERSION}"/gapic-showcase-"${SHOWCASE_VERSION}"-linux-amd64.tar.gz --output /usr/src/showcase/showcase-"${SHOWCASE_VERSION}"-linux-amd64.tar.gz pushd /usr/src/showcase/ tar -xf showcase-* ./gapic-showcase run & diff --git a/generation/check_existing_release_versions.sh b/generation/check_existing_release_versions.sh index 81e2cdf1d752..8caf9b641844 100755 --- a/generation/check_existing_release_versions.sh +++ b/generation/check_existing_release_versions.sh @@ -11,12 +11,10 @@ function find_existing_version_pom() { echo "Empty pom file name" exit 1 fi - local group_id=$(xmllint --xpath '/*[local-name()="project"]/*[local-name()="groupId"]/text()' \ - "${pom_file}") - local artifact_id=$(xmllint --xpath '/*[local-name()="project"]/*[local-name()="artifactId"]/text()' \ - "${pom_file}") - local version=$(xmllint --xpath '/*[local-name()="project"]/*[local-name()="version"]/text()' \ - "${pom_file}") + local coordinates=$(xmllint --xpath 'concat(normalize-space(/*[local-name()="project"]/*[local-name()="groupId"]), ":", normalize-space(/*[local-name()="project"]/*[local-name()="artifactId"]), ":", normalize-space(/*[local-name()="project"]/*[local-name()="version"]))' \ + "${pom_file}" 2>/dev/null || true) + local group_id artifact_id version + IFS=':' read -r group_id artifact_id version <<< "${coordinates}" echo -n "Checking ${group_id}:${artifact_id}:${version}:" if [ -z "${artifact_id}" ]; then echo "Couldn't parse artifact_id in the pom file: $pom_file" diff --git a/google-auth-library-java/scripts/update_javadoc.sh b/google-auth-library-java/scripts/update_javadoc.sh index e5d73c2188b6..d74cfe9f739e 100755 --- a/google-auth-library-java/scripts/update_javadoc.sh +++ b/google-auth-library-java/scripts/update_javadoc.sh @@ -31,10 +31,10 @@ set -e -VERSION=$(mvn org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version | grep -Ev '(^\[|\w+:)') +VERSION=$(sed -n '//,/<\/parent>/d; //{s:.*[[:space:]]*\([^<[:space:]]*\).*:\1:p; q;}' pom.xml) if [ -z "$VERSION" ]; then - echo "Error updating Javadoc: could not obtain version number from maven-help-plugin." + echo "Error updating Javadoc: could not obtain version number from pom.xml." exit 1 fi diff --git a/java-cloud-bom/tests/release-repository-readiness/check_status.sh b/java-cloud-bom/tests/release-repository-readiness/check_status.sh index 415251d758a3..2cd018ae773f 100755 --- a/java-cloud-bom/tests/release-repository-readiness/check_status.sh +++ b/java-cloud-bom/tests/release-repository-readiness/check_status.sh @@ -11,16 +11,28 @@ if [[ ! -d "${WORK_DIR}/sdk-platform-java" ]]; then exit 1 fi +function extract_xml_tag() { + local tag=$1 + local file=$2 + [[ ! -f "${file}" ]] && return 0 + sed -n "\|<${tag}[ >]|{s|.*<${tag}[^>]*>[[:space:]]*\([^<[:space:]]*\).*|\1|p; q;}" "${file}" +} + cd "${WORK_DIR}/sdk-platform-java" -expected_shared_deps_version=$(mvn -pl java-shared-dependencies help:evaluate -Dexpression=project.version -q -DforceStdout) -expected_generator_version=$(mvn -pl gapic-generator-java help:evaluate -Dexpression=project.version -q -DforceStdout) +expected_shared_deps_version=$(extract_xml_tag version java-shared-dependencies/pom.xml) +expected_generator_version=$(extract_xml_tag version gapic-generator-java/pom.xml) echo "Expected google-cloud-shared-dependencies BOM version: ${expected_shared_deps_version}" echo "Expected GAPIC generator Java version: ${expected_generator_version}" function check_shared_dependency_status() { local project=$1 - local actual_shared_deps_version=$(mvn -pl ${project} help:evaluate -Dexpression=google-cloud-shared-dependencies.version -q -DforceStdout) + local pom="${project}/pom.xml" + local actual_shared_deps_version=$(extract_xml_tag google-cloud-shared-dependencies.version "${pom}") + if [[ -z "${actual_shared_deps_version}" && -f "${pom}" ]]; then + # Fallback for parent POMs that inherit or track via version-update comment + actual_shared_deps_version=$(sed -n 's|.*[[:space:]]*\([^<[:space:]]*\).*x-version-update:google-cloud-shared-dependencies:current.*|\1|p; /x-version-update:google-cloud-shared-dependencies:current/q' "${pom}") + fi if [[ "${expected_shared_deps_version}" != "${actual_shared_deps_version}" ]]; then local shared_deps_status="! ${actual_shared_deps_version}" else @@ -42,11 +54,8 @@ function check_generated_code_status() { fi echo "${generator_status}" } -echo ", main, released" |\ - awk -F',' '{printf "%-20s|%-21s|%-21s|\n", $1, $2, $3}' - -echo " repository,shared dep,code gen,shared dep,code gen" |\ - awk -F',' '{printf "%-20s|%-10s|%-10s|%-10s|%-10s|\n", $1, $2, $3, $4, $5}' +printf "%-20s|%-21s|%-21s|\n" "" " main" " released" +printf "%-20s|%-10s|%-10s|%-10s|%-10s|\n" " repository" "shared dep" "code gen" "shared dep" "code gen" repositories=$(find "${WORK_DIR}" -mindepth 1 -maxdepth 1 -type d -not -name "sdk-platform-java") for repo_folder in $repositories; do @@ -72,9 +81,12 @@ for repo_folder in $repositories; do shared_deps_status_last_release=$(check_shared_dependency_status "${project}") generated_code_status_last_release=$(check_generated_code_status) - echo "${repo},${shared_deps_status_main},${generated_code_status_main},\ -${shared_deps_status_last_release},${generated_code_status_last_release}" | \ - awk -F',' '{printf "%-20s|%-10s|%-10s|%-10s|%-10s|\n", $1, $2, $3, $4, $5}' + printf "%-20s|%-10s|%-10s|%-10s|%-10s|\n" \ + "${repo}" \ + "${shared_deps_status_main}" \ + "${generated_code_status_main}" \ + "${shared_deps_status_last_release}" \ + "${generated_code_status_last_release}" done diff --git a/sdk-platform-java/.github/scripts/update_googleapis_commit.sh b/sdk-platform-java/.github/scripts/update_googleapis_commit.sh index 2acad04855fc..5f001d5baf4d 100644 --- a/sdk-platform-java/.github/scripts/update_googleapis_commit.sh +++ b/sdk-platform-java/.github/scripts/update_googleapis_commit.sh @@ -72,14 +72,11 @@ fi # conflict. git merge -m "chore: merge ${base_branch} into ${current_branch}" "${base_branch}" -mkdir tmp-googleapis -# Use partial clone because only commit history is needed. -git clone --filter=blob:none https://github.com/googleapis/googleapis.git tmp-googleapis -pushd tmp-googleapis -git pull -latest_commit=$(git rev-parse HEAD) -popd -rm -rf tmp-googleapis +latest_commit=$(git ls-remote https://github.com/googleapis/googleapis.git HEAD | awk '{print $1}') +if [ -z "${latest_commit}" ]; then + echo "Error: Failed to obtain latest commit from googleapis/googleapis" >&2 + exit 1 +fi sed -i -e "s/^googleapis_commitish.*$/googleapis_commitish: ${latest_commit}/" "${generation_config}" git add "${generation_config}" diff --git a/sdk-platform-java/.kokoro/nightly/downstream-protobuf-binary-compatibility.sh b/sdk-platform-java/.kokoro/nightly/downstream-protobuf-binary-compatibility.sh index 352b2dd9e24d..b8c6c7dc4371 100755 --- a/sdk-platform-java/.kokoro/nightly/downstream-protobuf-binary-compatibility.sh +++ b/sdk-platform-java/.kokoro/nightly/downstream-protobuf-binary-compatibility.sh @@ -22,6 +22,16 @@ validate_protobuf_compatibility_script_inputs monorepoRoot=$(realpath "${scriptDir}/../../..") +# Pre-cache versions.txt into an associative array to avoid cat/grep/cut on each artifact +declare -A versions_map +if [[ -f "${monorepoRoot}/versions.txt" ]]; then + while IFS=':' read -r mod rel cur || [[ -n "${mod}" ]]; do + [[ -z "${mod}" || "${mod}" =~ ^[[:space:]]*# ]] && continue + cur="${cur%$'\r'}" + versions_map["${mod}"]="${cur}" + done < "${monorepoRoot}/versions.txt" +fi + # Declare a map of downstream handwritten libraries and the relevant artifacts to test. The map stores a # K/V pairing of (Key: module name, Value: comma separate list of Group ID:Artifact ID pairings). Note: The # value list doesn't hold the version and this needs to be parsed from the monorepo's versions.txt file @@ -47,20 +57,18 @@ module_linkage_checker_arguments["java-storage-nio"]="com.google.cloud:google-cl # It will try to match the artifact_id in the versions.txt file and attach it to form the GAV # The GAV list is required by Linkage Checker as program arguments function build_program_arguments() { - artifact_list="${module_linkage_checker_arguments[$1]}" + local artifact_list="${module_linkage_checker_arguments[$1]}" for artifact in ${artifact_list//,/ }; do # Split on comma - artifact_id=$(echo "${artifact}" | cut -d ':' -f2) + local artifact_id="${artifact#*:}" - # The grep query tries to match `{artifact_id}:{released_version}:{current_version}`. - # The artifact_id must be exact otherwise multiple entries may match - version=$(cat "${monorepoRoot}/versions.txt" | grep -E "^${artifact_id}:.*:.*$" | cut -d ':' -f3 || true) + local version="${versions_map["${artifact_id}"]}" # Unreleased internal test modules like java-showcase are not tracked in versions.txt, # so fallback to 0.0.1-SNAPSHOT for linkage checking. if [ -z "${version}" ]; then version="0.0.1-SNAPSHOT" fi - module_gav_coordinate="${artifact}:${version}" + local module_gav_coordinate="${artifact}:${version}" # The first entry added is not separated with a comma. Avoids generating `,{ARTIFACT_LIST}` if [ -z "${linkage_checker_arguments}" ]; then diff --git a/sdk-platform-java/.kokoro/presubmit/showcase-native.sh b/sdk-platform-java/.kokoro/presubmit/showcase-native.sh index ad85d8dc6a08..3c20b484fe8e 100644 --- a/sdk-platform-java/.kokoro/presubmit/showcase-native.sh +++ b/sdk-platform-java/.kokoro/presubmit/showcase-native.sh @@ -38,12 +38,20 @@ mvn install --projects '!gapic-generator-java' \ SHARED_DEPS_VERSION=$(parse_pom_version java-shared-dependencies) # Run showcase integration tests in GraalVM -pushd java-showcase/gapic-showcase -SHOWCASE_VERSION=$(mvn help:evaluate -Dexpression=gapic-showcase.version -q -DforceStdout) -popd +SHOWCASE_POM="java-showcase/gapic-showcase/pom.xml" +if [[ ! -f "${SHOWCASE_POM}" && -f "../java-showcase/gapic-showcase/pom.xml" ]]; then + SHOWCASE_POM="../java-showcase/gapic-showcase/pom.xml" +fi +SHOWCASE_VERSION=$(sed -n 's:.*[[:space:]]*\([^<[:space:]]*\).*:\1:p; //q' "${SHOWCASE_POM}") +if [[ -z "${SHOWCASE_VERSION}" ]]; then + echo "Error: Failed to parse gapic-showcase.version from ${SHOWCASE_POM}" >&2 + exit 1 +fi + # Start showcase server mkdir -p /usr/src/showcase curl \ + --fail \ --location https://github.com/googleapis/gapic-showcase/releases/download/v"${SHOWCASE_VERSION}"/gapic-showcase-"${SHOWCASE_VERSION}"-linux-amd64.tar.gz \ --output /usr/src/showcase/showcase-"${SHOWCASE_VERSION}"-linux-amd64.tar.gz pushd /usr/src/showcase/