Skip to content

Commit

Permalink
allow bot to run all pages and update label regex
Browse files Browse the repository at this point in the history
- if label use regex, use quote
- add .github match for reg:ci-cd

Co-authored-by: Terry Cojean <terry.cojean@kit.edu>
  • Loading branch information
yhmtsai and tcojean committed Jan 6, 2021
1 parent 4a44dbd commit d9c950a
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 10 deletions.
21 changes: 20 additions & 1 deletion .github/bot-pr-format-base.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
36 changes: 27 additions & 9 deletions .github/label.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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]')
Expand All @@ -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/)
Expand Down

0 comments on commit d9c950a

Please sign in to comment.