Merge pull request #10792 from ethereum/fix-github-api-errors-from-check-style

Fix github API errors in check_style CI jobs
This commit is contained in:
chriseth 2021-01-19 13:46:15 +01:00 committed by GitHub
commit 86051dc099
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 15 deletions

View File

@ -1,6 +1,6 @@
#!/usr/bin/env bash
. scripts/report_errors.sh
ERROR_LOG="$(mktemp -t check_style_XXXXXX.log)"
EXCLUDE_FILES=(
"libsolutil/picosha2.h"
@ -24,6 +24,7 @@ if [[ "$WHITESPACE" != "" ]]
then
echo "Error: Trailing whitespace found:" | tee -a $ERROR_LOG
echo "$WHITESPACE" | tee -a $ERROR_LOG
scripts/report_errors.sh "$ERROR_LOG"
exit 1
fi
@ -52,6 +53,7 @@ if [[ "$FORMATERROR" != "" ]]
then
echo "Coding style error:" | tee -a $ERROR_LOG
echo "$FORMATERROR" | tee -a $ERROR_LOG
scripts/report_errors.sh "$ERROR_LOG"
exit 1
fi
)

View File

@ -1,14 +1,9 @@
#!/usr/bin/env bash
export ERROR_LOG="/tmp/error.log"
ERROR_LOG="$1"
function report_error_to_github
{
if [ $? -eq 0 ]
then
exit 0
fi
if [ -z $CIRCLE_PR_NUMBER ]
then
CIRCLE_PR_NUMBER="${CIRCLE_PULL_REQUEST//[^0-9]/}"
@ -22,16 +17,12 @@ function report_error_to_github
then
echo "posting error message to github"
post_error_to_github
post_review_comment_to_github
fi
}
function post_error_to_github
{
if [ -z $CIRCLE_PR_NUMBER ]
then
CIRCLE_PR_NUMBER="${CIRCLE_PULL_REQUEST//[^0-9]/}"
fi
GITHUB_API_URL="https://api.github.com/repos/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME/issues/$CIRCLE_PR_NUMBER/comments"
ESCAPED_ERROR_MSG=$(cat -e $ERROR_LOG | sed 's/\\/\\\\/g' | sed 's/"/\\\"/g')
@ -44,8 +35,6 @@ function post_error_to_github
--header 'content-type: application/json' \
-u stackenbotten:$GITHUB_ACCESS_TOKEN \
--data "{\"body\": \"There was an error when running \`$CIRCLE_JOB\` for commit \`$CIRCLE_SHA1\`:\n\`\`\`\n$FORMATTED_ERROR_MSG\n\`\`\`\nPlease check that your changes are working as intended.\"}"
post_review_comment_to_github
}
function post_review_comment_to_github
@ -58,6 +47,8 @@ function post_review_comment_to_github
do
ERROR_PATH=$(echo $line | grep -oE ".*\.cpp")
ERROR_LINE=$(echo $line | grep -oE "[0-9]*")
[[ $ERROR_PATH != "" ]] || { echo "ERROR: Error message does not contain file path."; exit 1; }
[[ $ERROR_LINE != "" ]] || { echo "ERROR: Error message does not contain line number."; exit 1; }
curl --request POST \
--url $GITHUB_API_URL \
@ -68,4 +59,4 @@ function post_review_comment_to_github
done < $ERROR_LOG
}
trap report_error_to_github EXIT
report_error_to_github