diff --git a/scripts/check_style.sh b/scripts/check_style.sh index 2ae991678..d99ec3556 100755 --- a/scripts/check_style.sh +++ b/scripts/check_style.sh @@ -2,8 +2,6 @@ ERROR_LOG="$(mktemp -t check_style_XXXXXX.log)" -. scripts/report_errors.sh - EXCLUDE_FILES=( "libsolutil/picosha2.h" "test/libsolutil/UTF8.cpp" @@ -23,6 +21,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 @@ -51,6 +50,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 ) diff --git a/scripts/report_errors.sh b/scripts/report_errors.sh index 8b465d4a7..0e6647356 100755 --- a/scripts/report_errors.sh +++ b/scripts/report_errors.sh @@ -1,12 +1,9 @@ #!/usr/bin/env bash +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]/}" @@ -20,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') @@ -42,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 @@ -66,4 +57,4 @@ function post_review_comment_to_github done < $ERROR_LOG } -trap report_error_to_github EXIT +report_error_to_github