mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
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:
commit
86051dc099
@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
. scripts/report_errors.sh
|
ERROR_LOG="$(mktemp -t check_style_XXXXXX.log)"
|
||||||
|
|
||||||
EXCLUDE_FILES=(
|
EXCLUDE_FILES=(
|
||||||
"libsolutil/picosha2.h"
|
"libsolutil/picosha2.h"
|
||||||
@ -24,6 +24,7 @@ if [[ "$WHITESPACE" != "" ]]
|
|||||||
then
|
then
|
||||||
echo "Error: Trailing whitespace found:" | tee -a $ERROR_LOG
|
echo "Error: Trailing whitespace found:" | tee -a $ERROR_LOG
|
||||||
echo "$WHITESPACE" | tee -a $ERROR_LOG
|
echo "$WHITESPACE" | tee -a $ERROR_LOG
|
||||||
|
scripts/report_errors.sh "$ERROR_LOG"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -52,6 +53,7 @@ if [[ "$FORMATERROR" != "" ]]
|
|||||||
then
|
then
|
||||||
echo "Coding style error:" | tee -a $ERROR_LOG
|
echo "Coding style error:" | tee -a $ERROR_LOG
|
||||||
echo "$FORMATERROR" | tee -a $ERROR_LOG
|
echo "$FORMATERROR" | tee -a $ERROR_LOG
|
||||||
|
scripts/report_errors.sh "$ERROR_LOG"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
)
|
)
|
||||||
|
@ -1,14 +1,9 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
export ERROR_LOG="/tmp/error.log"
|
ERROR_LOG="$1"
|
||||||
|
|
||||||
function report_error_to_github
|
function report_error_to_github
|
||||||
{
|
{
|
||||||
if [ $? -eq 0 ]
|
|
||||||
then
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -z $CIRCLE_PR_NUMBER ]
|
if [ -z $CIRCLE_PR_NUMBER ]
|
||||||
then
|
then
|
||||||
CIRCLE_PR_NUMBER="${CIRCLE_PULL_REQUEST//[^0-9]/}"
|
CIRCLE_PR_NUMBER="${CIRCLE_PULL_REQUEST//[^0-9]/}"
|
||||||
@ -22,16 +17,12 @@ function report_error_to_github
|
|||||||
then
|
then
|
||||||
echo "posting error message to github"
|
echo "posting error message to github"
|
||||||
post_error_to_github
|
post_error_to_github
|
||||||
|
post_review_comment_to_github
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function post_error_to_github
|
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"
|
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')
|
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' \
|
--header 'content-type: application/json' \
|
||||||
-u stackenbotten:$GITHUB_ACCESS_TOKEN \
|
-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.\"}"
|
--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
|
function post_review_comment_to_github
|
||||||
@ -58,6 +47,8 @@ function post_review_comment_to_github
|
|||||||
do
|
do
|
||||||
ERROR_PATH=$(echo $line | grep -oE ".*\.cpp")
|
ERROR_PATH=$(echo $line | grep -oE ".*\.cpp")
|
||||||
ERROR_LINE=$(echo $line | grep -oE "[0-9]*")
|
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 \
|
curl --request POST \
|
||||||
--url $GITHUB_API_URL \
|
--url $GITHUB_API_URL \
|
||||||
@ -68,4 +59,4 @@ function post_review_comment_to_github
|
|||||||
done < $ERROR_LOG
|
done < $ERROR_LOG
|
||||||
}
|
}
|
||||||
|
|
||||||
trap report_error_to_github EXIT
|
report_error_to_github
|
||||||
|
Loading…
Reference in New Issue
Block a user