2018-09-07 14:11:47 +03:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
#1: GIT_USERNAME
|
|
|
|
#2: GIT_TOKEN
|
|
|
|
#3: BRANCH
|
|
|
|
#4: LOG_USERNAME
|
|
|
|
#5: LOG_PASSWORD
|
|
|
|
#6: DRONE_BUILD_NUMBER
|
|
|
|
#7: PULL_REQUEST_NUMBER
|
|
|
|
|
2021-03-26 01:58:20 +03:00
|
|
|
stableBranch="master"
|
|
|
|
|
2018-09-07 14:11:47 +03:00
|
|
|
ruby scripts/analysis/lint-up.rb $1 $2 $3
|
|
|
|
lintValue=$?
|
|
|
|
|
2021-04-29 01:46:35 +03:00
|
|
|
./gradlew assembleGplay app:spotbugs
|
2018-09-07 14:11:47 +03:00
|
|
|
|
|
|
|
# exit codes:
|
|
|
|
# 0: count was reduced
|
|
|
|
# 1: count was increased
|
|
|
|
# 2: count stayed the same
|
|
|
|
|
|
|
|
echo "Branch: $3"
|
|
|
|
|
|
|
|
if [ $3 = "master" ]; then
|
2021-04-29 01:46:35 +03:00
|
|
|
echo "New spotbugs result for master at: https://www.kaminsky.me/nc-dev/talk-spotbugs/master.html"
|
|
|
|
curl -u $4:$5 -X PUT https://nextcloud.kaminsky.me/remote.php/webdav/talk-spotbugs/master.html --upload-file app/build/reports/spotbugs/spotbugs.html
|
2018-09-07 14:11:47 +03:00
|
|
|
|
2021-04-29 01:46:35 +03:00
|
|
|
summary=$(sed -n "/<h1>Summary<\/h1>/,/<h1>Warnings<\/h1>/p" app/build/reports/spotbugs/spotbugs.html | head -n-1 | sed s'/<\/a>//'g | sed s'/<a.*>//'g | sed s'/Summary/Spotbugs (master)/' | tr "\"" "\'" | tr -d "\r\n")
|
|
|
|
curl -u $4:$5 -X PUT -d "$summary" https://nextcloud.kaminsky.me/remote.php/webdav/talk-spotbugs/spotbugs-summary-master.html
|
2018-09-07 14:11:47 +03:00
|
|
|
|
|
|
|
if [ $lintValue -ne 1 ]; then
|
|
|
|
echo "New lint result for master at: https://www.kaminsky.me/nc-dev/talk-lint/master.html"
|
2021-01-22 09:02:37 +03:00
|
|
|
curl -u $4:$5 -X PUT https://nextcloud.kaminsky.me/remote.php/webdav/talk-lint/master.html --upload-file app/build/reports/lint/lint.html
|
2018-09-07 14:11:47 +03:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
if [ -e $6 ]; then
|
|
|
|
6="master-"$(date +%F)
|
|
|
|
fi
|
|
|
|
echo "New lint results at https://www.kaminsky.me/nc-dev/talk-lint/$6.html"
|
2021-01-22 09:02:37 +03:00
|
|
|
curl 2>/dev/null -u $4:$5 -X PUT https://nextcloud.kaminsky.me/remote.php/webdav/talk-lint/$6.html --upload-file app/build/reports/lint/lint.html
|
2018-09-07 14:11:47 +03:00
|
|
|
|
2021-04-29 01:46:35 +03:00
|
|
|
echo "New spotbugs results at https://www.kaminsky.me/nc-dev/talk-spotbugs/$6.html"
|
|
|
|
curl 2>/dev/null -u $4:$5 -X PUT https://nextcloud.kaminsky.me/remote.php/webdav/talk-spotbugs/$6.html --upload-file app/build/reports/spotbugs/spotbugs.html
|
2018-09-07 14:11:47 +03:00
|
|
|
|
|
|
|
# delete all old comments
|
|
|
|
oldComments=$(curl 2>/dev/null -u $1:$2 -X GET https://api.github.com/repos/nextcloud/talk-android/issues/$7/comments | jq '.[] | (.id |tostring) + "|" + (.user.login | test("nextcloud-android-bot") | tostring) ' | grep true | tr -d "\"" | cut -f1 -d"|")
|
|
|
|
|
|
|
|
echo $oldComments | while read comment ; do
|
|
|
|
curl 2>/dev/null -u $1:$2 -X DELETE https://api.github.com/repos/nextcloud/talk-android/issues/comments/$comment
|
|
|
|
done
|
|
|
|
|
|
|
|
# add comment with results
|
2021-03-26 01:58:20 +03:00
|
|
|
lintResultNew=$(grep "Lint Report.* [0-9]* warning" app/build/reports/lint/lint.html | cut -f2 -d':' |cut -f1 -d'<')
|
|
|
|
|
|
|
|
lintErrorNew=$(echo $lintResultNew | grep "[0-9]* error" -o | cut -f1 -d" ")
|
|
|
|
if ( [ -z $lintErrorNew ] ); then
|
|
|
|
lintErrorNew=0
|
|
|
|
fi
|
|
|
|
|
|
|
|
lintWarningNew=$(echo $lintResultNew | grep "[0-9]* warning" -o | cut -f1 -d" ")
|
|
|
|
if ( [ -z $lintWarningNew ] ); then
|
|
|
|
lintWarningNew=0
|
|
|
|
fi
|
|
|
|
|
|
|
|
lintResultOld=$(curl 2>/dev/null https://raw.githubusercontent.com/nextcloud/talk-android/$stableBranch/scripts/analysis/lint-results.txt)
|
|
|
|
lintErrorOld=$(echo $lintResultOld | grep "[0-9]* error" -o | cut -f1 -d" ")
|
|
|
|
if ( [ -z $lintErrorOld ] ); then
|
|
|
|
lintErrorOld=0
|
|
|
|
fi
|
|
|
|
|
|
|
|
lintWarningOld=$(echo $lintResultOld | grep "[0-9]* warning" -o | cut -f1 -d" ")
|
|
|
|
if ( [ -z $lintWarningOld ] ); then
|
|
|
|
lintWarningOld=0
|
|
|
|
fi
|
2018-09-07 15:55:17 +03:00
|
|
|
lintResult="<h1>Lint</h1><table width='500' cellpadding='5' cellspacing='2'><tr class='tablerow0'><td>Type</td><td><a href='https://www.kaminsky.me/nc-dev/talk-lint/master.html'>Master</a></td><td><a href='https://www.kaminsky.me/nc-dev/talk-lint/"$6".html'>PR</a></td></tr><tr class='tablerow1'><td>Warnings</td><td>"$lintWarningOld"</td><td>"$lintWarningNew"</td></tr><tr class='tablerow0'><td>Errors</td><td>"$lintErrorOld"</td><td>"$lintErrorNew"</td></tr></table>"
|
2021-04-29 01:46:35 +03:00
|
|
|
spotbugsResultNew=$(sed -n "/<h1>Summary<\/h1>/,/<h1>Warnings<\/h1>/p" app/build/reports/spotbugs/spotbugs.html |head -n-1 | sed s'/<\/a>//'g | sed s'/<a.*>//'g | sed s"#Summary#<a href=\"https://www.kaminsky.me/nc-dev/talk-spotbugs/$6.html\">SpotBugs</a> (new)#" | tr "\"" "\'" | tr -d "\n")
|
|
|
|
spotbugsResultOld=$(curl 2>/dev/null https://www.kaminsky.me/nc-dev/talk-spotbugs/spotbugs-summary-master.html | tr "\"" "\'" | tr -d "\r\n" | sed s'#SpotBugs#<a href=\"https://www.kaminsky.me/nc-dev/talk-spotbugs/master.html">SpotBugs</a>#'| tr "\"" "\'" | tr -d "\n")
|
2018-09-07 14:11:47 +03:00
|
|
|
curl -u $1:$2 -X POST https://api.github.com/repos/nextcloud/talk-android/issues/$7/comments -d "{ \"body\" : \"$lintResult $findbugsResultNew $findbugsResultOld \" }"
|
|
|
|
|
|
|
|
if [ $lintValue -eq 2 ]; then
|
|
|
|
exit 0
|
|
|
|
else
|
|
|
|
exit $lintValue
|
|
|
|
fi
|
|
|
|
fi
|