aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/report_errors.sh
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2018-12-03 22:48:03 +0800
committerGitHub <noreply@github.com>2018-12-03 22:48:03 +0800
commitc8a2cb62832afb2dc09ccee6fd42c1516dfdb981 (patch)
tree7977e9dcbbc215088c05b847f849871ef5d4ae66 /scripts/report_errors.sh
parent1d4f565a64988a3400847d2655ca24f73f234bc6 (diff)
parent590be1d84cea9850ce69b68be3dc5294b39041e5 (diff)
downloaddexon-solidity-c8a2cb62832afb2dc09ccee6fd42c1516dfdb981.tar
dexon-solidity-c8a2cb62832afb2dc09ccee6fd42c1516dfdb981.tar.gz
dexon-solidity-c8a2cb62832afb2dc09ccee6fd42c1516dfdb981.tar.bz2
dexon-solidity-c8a2cb62832afb2dc09ccee6fd42c1516dfdb981.tar.lz
dexon-solidity-c8a2cb62832afb2dc09ccee6fd42c1516dfdb981.tar.xz
dexon-solidity-c8a2cb62832afb2dc09ccee6fd42c1516dfdb981.tar.zst
dexon-solidity-c8a2cb62832afb2dc09ccee6fd42c1516dfdb981.zip
Merge pull request #5571 from ethereum/develop
Version 0.5.1
Diffstat (limited to 'scripts/report_errors.sh')
-rwxr-xr-xscripts/report_errors.sh49
1 files changed, 49 insertions, 0 deletions
diff --git a/scripts/report_errors.sh b/scripts/report_errors.sh
new file mode 100755
index 00000000..55fc2e8c
--- /dev/null
+++ b/scripts/report_errors.sh
@@ -0,0 +1,49 @@
+#!/usr/bin/env bash
+
+export ERROR_LOG="/tmp/error.log"
+
+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]/}"
+ fi
+
+ ERROR_MSG=$(cat $ERROR_LOG)
+
+ echo $ERROR_MSG
+
+ if [ ! -z $CI ]
+ then
+ echo "posting error message to github"
+ post_error_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')
+
+ FORMATTED_ERROR_MSG=$(echo $ESCAPED_ERROR_MSG | sed 's/\$/\\n/g' | tr -d '\n')
+
+ curl --request POST \
+ --url $GITHUB_API_URL \
+ --header 'accept: application/vnd.github.v3+json' \
+ --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.\"}"
+}
+
+trap report_error_to_github EXIT