diff --git a/dev_tools/ci/size-labeler.sh b/dev_tools/ci/size-labeler.sh index defcde544..326d96487 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" @@ -39,14 +39,6 @@ declare -A LIMITS=( ["${LABELS[4]}"]="$((2 ** 63 - 1))" ) -declare -ar IGNORED=( - "*_pb2.py" - "*_pb2.pyi" - "*_pb2_grpc.py" - ".*.lock" - "*.bundle.js" -) - function info() { echo >&2 "INFO: ${*}" } @@ -110,30 +102,20 @@ function api_call() { function compute_changes() { local -r pr="$1" + local page=1 + local 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 response - local change_info - local -r keys_filter='with_entries(select([.key] | inside(["changes", "filename"])))' - response="$(api_call "pulls/${pr}/files")" - 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 - 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))" + changes=$((changes + $(jq_stdin '[0, .[].changes] | add' <<<"${response}"))) + ((page++)) done - echo "$total_changes" + echo "${changes}" } function get_size_label() {