From 64cb3a8a441693b7833a4528eb5a761d6f6e46fd Mon Sep 17 00:00:00 2001 From: mhucka Date: Fri, 3 Apr 2026 01:34:14 +0000 Subject: [PATCH 1/5] Fix error in pattern matching The `IGNORED` list contain path globs, but they were getting tested using bash regex syntax, and this would not produce the right results. --- dev_tools/ci/size-labeler.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/dev_tools/ci/size-labeler.sh b/dev_tools/ci/size-labeler.sh index defcde544..99db30389 100755 --- a/dev_tools/ci/size-labeler.sh +++ b/dev_tools/ci/size-labeler.sh @@ -39,6 +39,7 @@ declare -A LIMITS=( ["${LABELS[4]}"]="$((2 ** 63 - 1))" ) +# Note: these are Bash glob patterns and not regexes. declare -ar IGNORED=( "*_pb2.py" "*_pb2.pyi" @@ -114,7 +115,7 @@ function compute_changes() { local response local change_info local -r keys_filter='with_entries(select([.key] | inside(["changes", "filename"])))' - response="$(api_call "pulls/${pr}/files")" + response="$(api_call "pulls/${pr}/files?per_page=100")" change_info="$(jq_stdin "map(${keys_filter})" <<<"${response}")" local files total_changes @@ -124,7 +125,8 @@ function compute_changes() { local name changes name="$(jq_stdin -r '.filename' <<<"${file}")" for pattern in "${IGNORED[@]}"; do - if [[ "$name" =~ ${pattern} ]]; then + # shellcheck disable=SC2053 # Pattern must be left unquoted here. + if [[ "$name" == ${pattern} ]]; then info "File $name ignored" continue 2 fi From bd2c201789c0a7faa528780eca0b0076b34621f6 Mon Sep 17 00:00:00 2001 From: mhucka Date: Fri, 3 Apr 2026 04:30:52 +0000 Subject: [PATCH 2/5] Support > 100 files in size-labeler.sh This enhances the code to support getting more than 100 files from GitHub. (Written with the help of Gemini CLI.) --- dev_tools/ci/size-labeler.sh | 54 +++++++++++++++++++++--------------- 1 file changed, 31 insertions(+), 23 deletions(-) diff --git a/dev_tools/ci/size-labeler.sh b/dev_tools/ci/size-labeler.sh index 99db30389..6dcaf4824 100755 --- a/dev_tools/ci/size-labeler.sh +++ b/dev_tools/ci/size-labeler.sh @@ -39,7 +39,6 @@ declare -A LIMITS=( ["${LABELS[4]}"]="$((2 ** 63 - 1))" ) -# Note: these are Bash glob patterns and not regexes. declare -ar IGNORED=( "*_pb2.py" "*_pb2.pyi" @@ -111,31 +110,40 @@ function api_call() { function compute_changes() { local -r pr="$1" - - local response - local change_info local -r keys_filter='with_entries(select([.key] | inside(["changes", "filename"])))' - response="$(api_call "pulls/${pr}/files?per_page=100")" - change_info="$(jq_stdin "map(${keys_filter})" <<<"${response}")" - - local files total_changes - readarray -t files < <(jq_stdin -c '.[]' <<<"${change_info}") - total_changes=0 - for file in "${files[@]}"; do - local name changes - name="$(jq_stdin -r '.filename' <<<"${file}")" - for pattern in "${IGNORED[@]}"; do - # shellcheck disable=SC2053 # Pattern must be left unquoted here. - if [[ "$name" == ${pattern} ]]; then - info "File $name ignored" - continue 2 - fi + + local page=1 + local total_changes=0 + while true; do + local response + response="$(api_call "pulls/${pr}/files?per_page=100&page=${page}")" + + if [[ "$(jq_stdin '. | length' <<<"${response}")" -eq 0 ]]; then + break + fi + + local change_info + change_info="$(jq_stdin "map(${keys_filter})" <<<"${response}")" + + local files + readarray -t files < <(jq_stdin -c '.[]' <<<"${change_info}") + for file in "${files[@]}"; do + local name changes + name="$(jq_stdin -r '.filename' <<<"${file}")" + for pattern in "${IGNORED[@]}"; do + # shellcheck disable=SC2053 # Need leave the pattern unquoted. + if [[ "${name}" == ${pattern} ]]; then + info "File ${name} ignored" + continue 2 + fi + done + changes="$(jq_stdin -r '.changes' <<<"${file}")" + info "File ${name} +-${changes}" + total_changes="$((total_changes + changes))" done - changes="$(jq_stdin -r '.changes' <<<"${file}")" - info "File $name +-$changes" - total_changes="$((total_changes + changes))" + ((page++)) done - echo "$total_changes" + echo "${total_changes}" } function get_size_label() { From 32a8a87a945d56e664905370d776b4ea428fb5de Mon Sep 17 00:00:00 2001 From: Michael Hucka Date: Thu, 2 Apr 2026 21:43:31 -0700 Subject: [PATCH 3/5] Performance improvement from Gemini Code Assist Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> --- dev_tools/ci/size-labeler.sh | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/dev_tools/ci/size-labeler.sh b/dev_tools/ci/size-labeler.sh index 6dcaf4824..81f75052a 100755 --- a/dev_tools/ci/size-labeler.sh +++ b/dev_tools/ci/size-labeler.sh @@ -122,14 +122,8 @@ function compute_changes() { break fi - local change_info - change_info="$(jq_stdin "map(${keys_filter})" <<<"${response}")" - - local files - readarray -t files < <(jq_stdin -c '.[]' <<<"${change_info}") - for file in "${files[@]}"; do - local name changes - name="$(jq_stdin -r '.filename' <<<"${file}")" + local name changes + while IFS= read -r name && IFS= read -r changes; do for pattern in "${IGNORED[@]}"; do # shellcheck disable=SC2053 # Need leave the pattern unquoted. if [[ "${name}" == ${pattern} ]]; then @@ -137,10 +131,9 @@ function compute_changes() { continue 2 fi done - changes="$(jq_stdin -r '.changes' <<<"${file}")" info "File ${name} +-${changes}" total_changes="$((total_changes + changes))" - done + done < <(jq_stdin -r '.[] | .filename, .changes' <<<"${response}") ((page++)) done echo "${total_changes}" From de40b7217aa9f6c7766816b4ea1dfd60cef03850 Mon Sep 17 00:00:00 2001 From: mhucka Date: Fri, 3 Apr 2026 05:05:05 +0000 Subject: [PATCH 4/5] Remove no-longer-needed variable --- dev_tools/ci/size-labeler.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/dev_tools/ci/size-labeler.sh b/dev_tools/ci/size-labeler.sh index 81f75052a..2f58b4059 100755 --- a/dev_tools/ci/size-labeler.sh +++ b/dev_tools/ci/size-labeler.sh @@ -110,8 +110,6 @@ function api_call() { function compute_changes() { local -r pr="$1" - local -r keys_filter='with_entries(select([.key] | inside(["changes", "filename"])))' - local page=1 local total_changes=0 while true; do From 1132dedc7bcfdee0f8d157665f48226796edda6f Mon Sep 17 00:00:00 2001 From: mhucka Date: Fri, 3 Apr 2026 05:10:26 +0000 Subject: [PATCH 5/5] Fix inconsistent label capitalization --- dev_tools/ci/size-labeler.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev_tools/ci/size-labeler.sh b/dev_tools/ci/size-labeler.sh index 2f58b4059..4f0d0405b 100755 --- a/dev_tools/ci/size-labeler.sh +++ b/dev_tools/ci/size-labeler.sh @@ -24,7 +24,7 @@ PR_NUMBER, GITHUB_REPOSITORY, GITHUB_TOKEN. The script is intended for automated execution from GitHub Actions workflow." declare -ar LABELS=( - "Size: XS" + "size: XS" "size: S" "size: M" "size: L"