mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-07 21:23:32 +00:00

In order to avoid duplication of the already created comment, already created results will be deleted.
66 lines
1.7 KiB
Bash
66 lines
1.7 KiB
Bash
#!/bin/bash
|
|
|
|
if [[ -z "$GITHUB_TOKEN" ]]; then
|
|
echo "The GITHUB_TOKEN is required."
|
|
exit 1
|
|
fi
|
|
|
|
FILES_LINK=`jq -r '.pull_request._links.self.href' "$GITHUB_EVENT_PATH"`/files
|
|
echo "Files = $FILES_LINK"
|
|
|
|
curl $FILES_LINK > files.json
|
|
FILES_URLS_STRING=`jq -r '.[].raw_url' files.json`
|
|
|
|
readarray -t URLS <<<"$FILES_URLS_STRING"
|
|
|
|
echo "File names: $URLS"
|
|
|
|
mkdir files
|
|
cd files
|
|
for i in "${URLS[@]}"
|
|
do
|
|
echo "Downloading $i"
|
|
curl -LOk --remote-name $i
|
|
done
|
|
|
|
echo "Files downloaded!"
|
|
echo "Performing checkup:"
|
|
|
|
cpplint --filter=-,\
|
|
+whitespace/parens,\
|
|
+whitespace/indent,\
|
|
+whitespace/end_of_line,\
|
|
+whitespace/blank_line \
|
|
--extension=cpp,h,c \
|
|
--recursive \
|
|
./ > cpp-report.txt 2>&1
|
|
|
|
PAYLOAD_CPPLINT=`cat cpp-report.txt`
|
|
COMMENTS_URL=$(cat $GITHUB_EVENT_PATH | jq -r .pull_request.comments_url)
|
|
|
|
echo $COMMENTS_URL
|
|
echo "Cppcheck errors:"
|
|
echo $PAYLOAD_CPPLINT
|
|
|
|
if [[ $PAYLOAD_CPPLINT == *"Total errors found: "* ]]; then
|
|
OUTPUT+=$'\n**CODING STYLE CHECK**:\n'
|
|
OUTPUT+=$'\n```\n'
|
|
OUTPUT+="$PAYLOAD_CPPLINT"
|
|
OUTPUT+=$'\n```\n'
|
|
fi
|
|
|
|
curl $COMMENTS_URL > comments.json
|
|
EXIST_COMMENTS=`jq -r '.[] | select(.body | contains("*CODING STYLE CHECK*")) | .id' comments.json`
|
|
echo $EXIST_COMMENTS
|
|
for exist_comment in $EXIST_COMMENTS
|
|
do
|
|
echo "---------------------"
|
|
echo $exist_comment
|
|
COMMENT_URL="https://api.github.com/repos/Samsung/thorvg/issues/comments/""$exist_comment"
|
|
curl -X "DELETE" -H "Authorization: token $GITHUB_TOKEN" --header "Content-Type: application/vnd.github.VERSION.text+json" "$COMMENT_URL"
|
|
echo "=================="
|
|
done
|
|
|
|
PAYLOAD=$(echo '{}' | jq --arg body "$OUTPUT" '.body = $body')
|
|
|
|
curl -s -S -H "Authorization: token $GITHUB_TOKEN" --header "Content-Type: application/vnd.github.VERSION.text+json" --data "$PAYLOAD" "$COMMENTS_URL"
|