Skip to content

ci: optimize release readiness, commit queries, and version caching - #14229

Open
lqiu96 wants to merge 1 commit into
mainfrom
perf-release-automation
Open

ci: optimize release readiness, commit queries, and version caching#14229
lqiu96 wants to merge 1 commit into
mainfrom
perf-release-automation

Conversation

@lqiu96

@lqiu96 lqiu96 commented Sep 1, 2026

Copy link
Copy Markdown
Member

Problem

In release generation scripts and nightly protobuf compatibility jobs:

  • In check_existing_release_versions.sh (generation/check_existing_release_versions.sh), xmllint was invoked 3 separate times per POM across all 1,600+ POMs to extract coordinates, introducing a brittle external dependency on xmllint/libxml2-utils.
  • In downstream-protobuf-binary-compatibility.sh (sdk-platform-java/.kokoro/nightly/downstream-protobuf-binary-compatibility.sh), cat, grep, and cut were repeatedly executed against versions.txt inside a loop for each artifact (~120 subprocesses).

Changes

  • Common XML Tag Extraction (extract_xml_tag): Added a shared, lightweight XML tag extraction function in .kokoro/common.sh that skips <parent> blocks to reliably read project coordinates/properties without xmllint. Added unit tests in .kokoro/common_test.sh.
  • Generation Version Checker Optimization: Updated check_existing_release_versions.sh to source .kokoro/common.sh, use extract_xml_tag (completely removing xmllint), replace memory-buffered $(find ... | sort) with streaming process substitution, and simplify branch checks with case matching.
  • Associative Array Pre-caching: Pre-cached versions.txt into declare -A versions_map in downstream-protobuf-binary-compatibility.sh to avoid per-artifact subprocesses, added --depth 1 shallow clone, and added explanatory comments for bash parameter expansion syntax.

@lqiu96
lqiu96 requested review from a team as code owners September 1, 2026 14:58

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request optimizes several shell scripts by replacing slow operations (such as mvn help:evaluate and full git clone commands) with faster alternatives like local XML parsing, git ls-remote, and associative array caching. However, the introduction of a sed-based XML parser in check_status.sh is fragile and can incorrectly extract parent POM versions instead of the project's own version. It is recommended to use xmllint with a robust XPath query to safely parse the POM files.

Comment thread java-cloud-bom/tests/release-repository-readiness/check_status.sh Outdated
@lqiu96
lqiu96 force-pushed the perf-release-automation branch from ff9e1c8 to 65b2bf0 Compare September 1, 2026 15:09
@lqiu96 lqiu96 changed the title perf(ci): optimize release readiness, commit queries, and version caching ci: optimize release readiness, commit queries, and version caching Sep 1, 2026
@lqiu96
lqiu96 force-pushed the perf-release-automation branch 7 times, most recently from 54f0d1a to d975f64 Compare September 1, 2026 22:26
In release generation scripts and nightly protobuf compatibility jobs:
- In .kokoro/common.sh & .kokoro/common_test.sh:
  * Centralized extract_xml_tag to avoid duplicating XML tag extraction across release scripts.
  * Added automated unit test test_extract_xml_tag in common_test.sh.
- In check_existing_release_versions.sh (generation/check_existing_release_versions.sh):
  * Replaced external xmllint calls with centralized extract_xml_tag from .kokoro/common.sh,
    eliminating the xmllint / libxml2-utils dependency completely while avoiding parent-tag collisions.
  * Replaced memory-buffered $(find ... | sort) with streaming process substitution.
  * Replaced complex chained if condition with clean case pattern matching.
- In downstream-protobuf-binary-compatibility.sh (sdk-platform-java/.kokoro/nightly/downstream-protobuf-binary-compatibility.sh):
  * Pre-cached versions.txt into associative array declare -A versions_map, eliminating ~120
    cat/grep/cut subprocesses and 40 redundant file reads.
  * Added --depth 1 shallow clone for cloud-opensource-java, saving 98.5% of git objects and ~10MB.
  * Replaced space-substitution word-splitting with idiomatic IFS=, read -ra array operations.
  * Added explanatory comments for bash parameter expansion artifactId extraction.
@lqiu96
lqiu96 force-pushed the perf-release-automation branch from d975f64 to b0c5b5f Compare September 1, 2026 22:43
@sonarqubecloud

sonarqubecloud Bot commented Sep 1, 2026

Copy link
Copy Markdown

@sonarqubecloud

sonarqubecloud Bot commented Sep 1, 2026

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant