Issue #3632: pr description validation is moved to shell script
This commit is contained in:
parent
4f64bd427a
commit
bd5ea09b31
|
|
@ -1,5 +1,5 @@
|
|||
#!/bin/bash
|
||||
# Attention, there is no "-x" to avoid disclosure of secret variables
|
||||
# Attention, there is no "-x" to avoid problems on Travis
|
||||
set -e
|
||||
|
||||
case "$GOAL" in
|
||||
|
|
@ -8,6 +8,10 @@ releasenotes-gen)
|
|||
.ci/travis/xtr_releasenotes-gen.sh
|
||||
;;
|
||||
|
||||
pr-description)
|
||||
.ci/travis/xtr_pr-description.sh
|
||||
;;
|
||||
|
||||
all-sevntu-checks)
|
||||
xmlstarlet sel --net --template -m .//module -v "@name" -n config/checkstyle_sevntu_checks.xml \
|
||||
| grep -vE "Checker|TreeWalker|Filter|Holder" | grep -v "^$" \
|
||||
|
|
|
|||
|
|
@ -0,0 +1,29 @@
|
|||
#!/bin/bash
|
||||
# Attention, there is no "-x" to avoid problems on Travis
|
||||
set -e
|
||||
|
||||
if [[ ! $TRAVIS_PULL_REQUEST =~ ^([0-9]*)$ ]]; then exit 0; fi
|
||||
LINK_COMMITS=https://api.github.com/repos/checkstyle/checkstyle/pulls/$TRAVIS_PULL_REQUEST/commits
|
||||
COMMITS=$(curl -s -H "Authorization: token $GITHUB_AUTH_TOKEN" $LINK_COMMITS | jq '.[0] | .commit.message')
|
||||
echo 'Messages from github:'${COMMITS:0:60}...
|
||||
ISSUE_NUMBER=$(echo $COMMITS | sed -e 's/^.*Issue //' | sed -e 's/:.*//')
|
||||
echo 'Issue number:'$ISSUE_NUMBER && RESULT=0
|
||||
if [[ $ISSUE_NUMBER =~ ^#[0-9]+$ ]]; then
|
||||
LINK_PR=https://api.github.com/repos/checkstyle/checkstyle/pulls/$TRAVIS_PULL_REQUEST
|
||||
LINK_ISSUE=https://api.github.com/repos/checkstyle/checkstyle/issues/${ISSUE_NUMBER:1}
|
||||
REGEXP=($ISSUE_NUMBER\|https://github.com/checkstyle/checkstyle/issues/${ISSUE_NUMBER:1})
|
||||
PR_DESC=$(curl -s -H "Authorization: token $GITHUB_AUTH_TOKEN" $LINK_PR | jq '.body' | grep -E $REGEXP | cat )
|
||||
echo 'PR Description grepped:'${PR_DESC:0:80}
|
||||
if [[ -z $PR_DESC ]]; then
|
||||
echo 'Please put a reference of Issue to PR description, this will bind Issue and PR in Github' && RESULT=1;
|
||||
fi
|
||||
LABEL_APRV=$(curl -s -H "Authorization: token $GITHUB_AUTH_TOKEN" $LINK_ISSUE | jq '.labels [] | .name' | grep approved | cat | wc -l )
|
||||
if [[ $LABEL_APRV == 0 ]]; then
|
||||
echo 'You provide PR to Issue that is not approved yes, please ask admins to approve your issue first' && RESULT=1;
|
||||
fi
|
||||
fi
|
||||
if [[ $RESULT == 0 ]]; then
|
||||
echo 'PR validation succeed.';
|
||||
else
|
||||
echo 'PR validation failed.' && false;
|
||||
fi
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
#!/bin/bash
|
||||
# Attention, there is no "-x" to avoid disclosure of AuthToken and other secret variables
|
||||
# Attention, there is no "-x" to avoid problem on Travis
|
||||
set -e
|
||||
|
||||
if [[ $TRAVIS_PULL_REQUEST =~ ^([0-9]*)$ ]]; then exit 0; fi
|
||||
|
|
|
|||
30
.travis.yml
30
.travis.yml
|
|
@ -285,34 +285,8 @@ matrix:
|
|||
# testing of PR format
|
||||
- env:
|
||||
- DESC="test Issue ref in PR description"
|
||||
- CMD_="set -e"
|
||||
- CMD0=" && if [[ ! $TRAVIS_PULL_REQUEST =~ ^([0-9]*)$ ]]; then exit 0; fi "
|
||||
- CMD1=" && LINK_COMMITS=https://api.github.com/repos/checkstyle/checkstyle/pulls/$TRAVIS_PULL_REQUEST/commits "
|
||||
- CMD2=" && COMMITS=\$(curl -s -H 'Authorization: token $GITHUB_AUTH_TOKEN' \$LINK_COMMITS | jq '.[0] | .commit.message') "
|
||||
- CMD3=" && echo 'Messages from github:'\${COMMITS:0:60}... "
|
||||
- CMD4=" && ISSUE_NUMBER=\$( echo \$COMMITS | sed -e 's/^.*Issue //' | sed -e 's/:.*//') "
|
||||
- CMD5=" && echo 'Issue number:'\$ISSUE_NUMBER && RESULT=0"
|
||||
- CMD6=" && if [[ \$ISSUE_NUMBER =~ ^#[0-9]+$ ]]; then "
|
||||
- CMD7=" LINK_PR=https://api.github.com/repos/checkstyle/checkstyle/pulls/$TRAVIS_PULL_REQUEST "
|
||||
- CMD8=" && LINK_ISSUE=https://api.github.com/repos/checkstyle/checkstyle/issues/\${ISSUE_NUMBER:1} "
|
||||
- CMD9=" && REGEXP=(\$ISSUE_NUMBER\|https://github.com/checkstyle/checkstyle/issues/\${ISSUE_NUMBER:1})"
|
||||
- CMD10=" && PR_DESC=\$(curl -s -H 'Authorization: token $GITHUB_AUTH_TOKEN' \$LINK_PR | jq '.body' | grep -E \$REGEXP | cat ) "
|
||||
- CMD11=" && echo 'PR Description grepped:'\${PR_DESC:0:80} "
|
||||
- CMD12=" && if [[ -z \$PR_DESC ]]; then "
|
||||
- CMD13=" echo 'Please put a reference of Issue to PR description, this will bind Issue and PR in Github' && RESULT=1; "
|
||||
- CMD14=" fi "
|
||||
- CMD15=" && LABEL_APRV=\$(curl -s -H 'Authorization: token $GITHUB_AUTH_TOKEN' \$LINK_ISSUE | jq '.labels [] | .name' | grep approved | cat | wc -l ) "
|
||||
- CMD16=" && if [[ \$LABEL_APRV == 0 ]]; then "
|
||||
- CMD17=" echo 'You provide PR to Issue that is not approved yes, please ask admins to approve your issue first' && RESULT=1; "
|
||||
- CMD18=" fi "
|
||||
- CMD19=" fi "
|
||||
- CMD20=" && if [[ \$RESULT == 0 ]]; then "
|
||||
- CMD21=" echo 'PR validation succeed.'; "
|
||||
- CMD22=" else "
|
||||
- CMD23=" echo 'PR validation failed.' && false; "
|
||||
- CMD24=" fi "
|
||||
- CMD=$CMD_$CMD0$CMD1$CMD2$CMD3$CMD4$CMD5$CMD6$CMD7$CMD8$CMD9$CMD10$CMD11$CMD12$CMD13$CMD14$CMD15
|
||||
- CMD=$CMD$CMD16$CMD17$CMD18$CMD19$CMD20$CMD21$CMD22$CMD23$CMD24
|
||||
- GOAL="pr-description"
|
||||
- CMD="./.ci/travis/travis.sh"
|
||||
- COVERAGE_CMD=""
|
||||
|
||||
# Ensure that all Sevntu check are kused
|
||||
|
|
|
|||
Loading…
Reference in New Issue