|
| 1 | +# Given the repositories are checked out in the WORK_DIR below |
| 2 | +# find the shared dependencies BOM version in current release |
| 3 | +# and find any missing updates. |
| 4 | + |
| 5 | +set -ef |
| 6 | + |
| 7 | +WORK_DIR=/tmp/release-readiness |
| 8 | + |
| 9 | +if [[ ! -d "${WORK_DIR}/sdk-platform-java" ]]; then |
| 10 | + echo "The repositories are missing in ${WORK_DIR}. Please use clone_repositories.sh first" |
| 11 | + exit 1 |
| 12 | +fi |
| 13 | + |
| 14 | +cd "${WORK_DIR}/sdk-platform-java" |
| 15 | +expected_shared_deps_version=$(mvn -pl java-shared-dependencies help:evaluate -Dexpression=project.version -q -DforceStdout) |
| 16 | +expected_generator_version=$(mvn -pl gapic-generator-java help:evaluate -Dexpression=project.version -q -DforceStdout) |
| 17 | +echo "Expected google-cloud-shared-dependencies BOM version: ${expected_shared_deps_version}" |
| 18 | +echo "Expected GAPIC generator Java version: ${expected_generator_version}" |
| 19 | + |
| 20 | + |
| 21 | +function check_shared_dependency_status() { |
| 22 | + local project=$1 |
| 23 | + local actual_shared_deps_version=$(mvn -pl ${project} help:evaluate -Dexpression=google-cloud-shared-dependencies.version -q -DforceStdout) |
| 24 | + if [[ "${expected_shared_deps_version}" != "${actual_shared_deps_version}" ]]; then |
| 25 | + local shared_deps_status="! ${actual_shared_deps_version}" |
| 26 | + else |
| 27 | + local shared_deps_status="OK" |
| 28 | + fi |
| 29 | + echo "${shared_deps_status}" |
| 30 | +} |
| 31 | + |
| 32 | +function check_generated_code_status() { |
| 33 | + if [ -r "generation_config.yaml" ]; then |
| 34 | + local actual_generator_version=$(perl -nle 'print $1 if m/gapic_generator_version:\s*(.+)/' generation_config.yaml) |
| 35 | + if [[ "${expected_generator_version}" != "${actual_generator_version}" ]]; then |
| 36 | + local generator_status="! ${actual_generator_version}" |
| 37 | + else |
| 38 | + local generator_status="OK" |
| 39 | + fi |
| 40 | + else |
| 41 | + local generator_status="N/A" |
| 42 | + fi |
| 43 | + echo "${generator_status}" |
| 44 | +} |
| 45 | +echo ", main, released" |\ |
| 46 | + awk -F',' '{printf "%-20s|%-21s|%-21s|\n", $1, $2, $3}' |
| 47 | + |
| 48 | +echo " repository,shared dep,code gen,shared dep,code gen" |\ |
| 49 | + awk -F',' '{printf "%-20s|%-10s|%-10s|%-10s|%-10s|\n", $1, $2, $3, $4, $5}' |
| 50 | + |
| 51 | +repositories=$(find "${WORK_DIR}" -mindepth 1 -maxdepth 1 -type d -not -name "sdk-platform-java") |
| 52 | +for repo_folder in $repositories; do |
| 53 | + cd "${repo_folder}" |
| 54 | + repo=$(basename "${repo_folder}") |
| 55 | + git fetch -q origin main > /dev/null |
| 56 | + git checkout -q main > /dev/null |
| 57 | + git pull -q origin main > /dev/null |
| 58 | + if [[ "$repo" == "google-cloud-java" ]]; then |
| 59 | + # In google-cloud-java repository, the parent pom module |
| 60 | + # inherits the property. |
| 61 | + project=google-cloud-pom-parent |
| 62 | + else |
| 63 | + # In normal handwritten libraries, the root project receives the property. |
| 64 | + project=. |
| 65 | + fi |
| 66 | + shared_deps_status_main=$(check_shared_dependency_status "${project}") |
| 67 | + generated_code_status_main=$(check_generated_code_status) |
| 68 | + |
| 69 | + last_release_tag=$(gh release list --limit 1 --order desc --json 'tagName' --jq '.[].tagName') |
| 70 | + git fetch -q origin tag ${last_release_tag} --no-tags > /dev/null |
| 71 | + git checkout -q ${last_release_tag} > /dev/null |
| 72 | + shared_deps_status_last_release=$(check_shared_dependency_status "${project}") |
| 73 | + generated_code_status_last_release=$(check_generated_code_status) |
| 74 | + |
| 75 | + echo "${repo},${shared_deps_status_main},${generated_code_status_main},\ |
| 76 | +${shared_deps_status_last_release},${generated_code_status_last_release}" | \ |
| 77 | + awk -F',' '{printf "%-20s|%-10s|%-10s|%-10s|%-10s|\n", $1, $2, $3, $4, $5}' |
| 78 | +done |
| 79 | + |
| 80 | + |
| 81 | + |
0 commit comments