diff --git a/.github/bot-pr-format-base.sh b/.github/bot-pr-format-base.sh index d89d3f2ee2a..8d213dcfe69 100644 --- a/.github/bot-pr-format-base.sh +++ b/.github/bot-pr-format-base.sh @@ -7,7 +7,26 @@ FORMAT_HEADER_REGEX='^(benchmark|core|cuda|hip|include/ginkgo/core|omp|reference FORMAT_REGEX='^(common|examples|test_install)/' echo "Retrieving PR file list" -PR_FILES="$(api_get "$PR_URL/files?&per_page=1000" | jq -er '.[] | .filename')" +PR_FILES="" +PAGE="1" +while true; do + # this api allows 100 items per page + # github action uses `bash -e`. The last empty page will leads jq error, use `|| :` to ignore the error. + PR_PAGE_FILES=$(api_get "$PR_URL/files?&per_page=100&page=${PAGE}" | jq -er '.[] | .filename' || :) + if [ "${PR_PAGE_FILES}" = "" ]; then + break + fi + echo "Retrieving PR file list - ${PAGE} pages" + if [ ! "${PR_FILES}" = "" ]; then + # add the same new line format as jq output + PR_FILES="${PR_FILES}"$'\n' + fi + PR_FILES="${PR_FILES}${PR_PAGE_FILES}" + PAGE=$(( PAGE + 1 )) +done +NUM=$(echo "${PR_FILES}" | wc -l) +echo "PR has ${NUM} changed files" + TO_FORMAT="$(echo "$PR_FILES" | grep -E $EXTENSION_REGEX || true)" git remote add fork "$HEAD_URL" diff --git a/.github/label.sh b/.github/label.sh index 3cd5023829b..860e520720c 100755 --- a/.github/label.sh +++ b/.github/label.sh @@ -3,7 +3,25 @@ source .github/bot-pr-base.sh echo "Retrieving PR file list" -PR_FILES=$(api_get "$PR_URL/files?&per_page=1000" | jq -er '.[] | .filename') +PR_FILES="" +PAGE="1" +while true; do + # this api allows 100 items per page + # github action uses `bash -e`. The last empty page will leads jq error, use `|| :` to ignore the error. + PR_PAGE_FILES=$(api_get "$PR_URL/files?&per_page=100&page=${PAGE}" | jq -er '.[] | .filename' || :) + if [ "${PR_PAGE_FILES}" = "" ]; then + break + fi + echo "Retrieving PR file list - ${PAGE} pages" + if [ ! "${PR_FILES}" = "" ]; then + # add the same new line format as jq output + PR_FILES="${PR_FILES}"$'\n' + fi + PR_FILES="${PR_FILES}${PR_PAGE_FILES}" + PAGE=$(( PAGE + 1 )) +done +NUM=$(echo "${PR_FILES}" | wc -l) +echo "PR has ${NUM} changed files" echo "Retrieving PR label list" OLD_LABELS=$(api_get "$ISSUE_URL" | jq -er '[.labels | .[] | .name]') @@ -17,18 +35,18 @@ label_match() { LABELS="[]" LABELS=$LABELS$(label_match mod:core '(^core/|^include/)') -LABELS=$LABELS$(label_match mod:reference ^reference/) -LABELS=$LABELS$(label_match mod:openmp ^omp/) +LABELS=$LABELS$(label_match mod:reference '^reference/') +LABELS=$LABELS$(label_match mod:openmp '^omp/') LABELS=$LABELS$(label_match mod:cuda '(^cuda/|^common/)') LABELS=$LABELS$(label_match mod:hip '(^hip/|^common/)') -LABELS=$LABELS$(label_match mod:dpcpp ^dpcpp/) -LABELS=$LABELS$(label_match reg:benchmarking ^benchmark/) -LABELS=$LABELS$(label_match reg:example ^examples/) +LABELS=$LABELS$(label_match mod:dpcpp '^dpcpp/') +LABELS=$LABELS$(label_match reg:benchmarking '^benchmark/') +LABELS=$LABELS$(label_match reg:example '^examples/') LABELS=$LABELS$(label_match reg:build '(cm|CM)ake') -LABELS=$LABELS$(label_match reg:ci-cd '.yml$') -LABELS=$LABELS$(label_match reg:documentation ^doc/) +LABELS=$LABELS$(label_match reg:ci-cd '(^\.github/|\.yml$)') +LABELS=$LABELS$(label_match reg:documentation '^doc/') LABELS=$LABELS$(label_match reg:testing /test/) -LABELS=$LABELS$(label_match reg:helper-scripts ^dev_tools/) +LABELS=$LABELS$(label_match reg:helper-scripts '^dev_tools/') LABELS=$LABELS$(label_match type:factorization /factorization/) LABELS=$LABELS$(label_match type:matrix-format /matrix/) LABELS=$LABELS$(label_match type:multigrid /multigrid/)