ci: optimize release readiness, commit queries, and version caching - #14229
ci: optimize release readiness, commit queries, and version caching#14229lqiu96 wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
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.
ff9e1c8 to
65b2bf0
Compare
54f0d1a to
d975f64
Compare
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.
d975f64 to
b0c5b5f
Compare
|
|



Problem
In release generation scripts and nightly protobuf compatibility jobs:
check_existing_release_versions.sh(generation/check_existing_release_versions.sh),xmllintwas invoked 3 separate times per POM across all 1,600+ POMs to extract coordinates, introducing a brittle external dependency onxmllint/libxml2-utils.downstream-protobuf-binary-compatibility.sh(sdk-platform-java/.kokoro/nightly/downstream-protobuf-binary-compatibility.sh),cat,grep, andcutwere repeatedly executed againstversions.txtinside a loop for each artifact (~120 subprocesses).Changes
extract_xml_tag): Added a shared, lightweight XML tag extraction function in.kokoro/common.shthat skips<parent>blocks to reliably read project coordinates/properties withoutxmllint. Added unit tests in.kokoro/common_test.sh.check_existing_release_versions.shto source.kokoro/common.sh, useextract_xml_tag(completely removingxmllint), replace memory-buffered$(find ... | sort)with streaming process substitution, and simplify branch checks withcasematching.versions.txtintodeclare -A versions_mapindownstream-protobuf-binary-compatibility.shto avoid per-artifact subprocesses, added--depth 1shallow clone, and added explanatory comments for bash parameter expansion syntax.