2018-06-21 10:06:33 +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
|
|
|
|
|
2018-11-01 12:59:08 +03:00
|
|
|
stableBranch="master"
|
|
|
|
repository="android"
|
|
|
|
|
2018-06-21 10:06:33 +03:00
|
|
|
ruby scripts/analysis/lint-up.rb $1 $2 $3
|
|
|
|
lintValue=$?
|
|
|
|
|
|
|
|
# exit codes:
|
|
|
|
# 0: count was reduced
|
|
|
|
# 1: count was increased
|
|
|
|
# 2: count stayed the same
|
|
|
|
|
2018-09-25 12:55:53 +03:00
|
|
|
./gradlew findbugs
|
|
|
|
|
2018-06-21 10:06:33 +03:00
|
|
|
echo "Branch: $3"
|
|
|
|
|
2018-11-01 12:59:08 +03:00
|
|
|
if [ $3 = $stableBranch ]; then
|
|
|
|
echo "New findbugs result for $stableBranch at: https://www.kaminsky.me/nc-dev/$repository-findbugs/$stableBranch.html"
|
|
|
|
curl -u $4:$5 -X PUT https://nextcloud.kaminsky.me/remote.php/webdav/$repository-findbugs/$stableBranch.html --upload-file build/reports/findbugs/findbugs.html
|
|
|
|
|
2018-11-05 14:55:43 +03:00
|
|
|
summary=$(sed -n "/<h1>Summary<\/h1>/,/<h1>Warnings<\/h1>/p" build/reports/findbugs/findbugs.html | head -n-1 | sed s'/<\/a>//'g | sed s'/<a.*>//'g | sed s"/Summary/FindBugs ($stableBranch)/" | tr "\"" "\'" | tr -d "\r\n")
|
2018-11-01 12:59:08 +03:00
|
|
|
curl -u $4:$5 -X PUT -d "$summary" https://nextcloud.kaminsky.me/remote.php/webdav/$repository-findbugs/findbugs-summary-$stableBranch.html
|
|
|
|
|
2018-06-21 10:06:33 +03:00
|
|
|
if [ $lintValue -ne 1 ]; then
|
2018-11-01 12:59:08 +03:00
|
|
|
echo "New lint result for $stableBranch at: https://www.kaminsky.me/nc-dev/$repository-lint/$stableBranch.html"
|
|
|
|
curl -u $4:$5 -X PUT https://nextcloud.kaminsky.me/remote.php/webdav/$repository-lint/$stableBranch.html --upload-file build/reports/lint/lint.html
|
2018-06-21 10:06:33 +03:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
if [ -e $6 ]; then
|
2018-11-01 12:59:08 +03:00
|
|
|
6=$stableBranch"-"$(date +%F)
|
2018-06-21 10:06:33 +03:00
|
|
|
fi
|
2018-11-01 12:59:08 +03:00
|
|
|
echo "New lint results at https://www.kaminsky.me/nc-dev/$repository-lint/$6.html"
|
|
|
|
curl 2>/dev/null -u $4:$5 -X PUT https://nextcloud.kaminsky.me/remote.php/webdav/$repository-lint/$6.html --upload-file build/reports/lint/lint.html
|
|
|
|
|
|
|
|
echo "New findbugs results at https://www.kaminsky.me/nc-dev/$repository-findbugs/$6.html"
|
|
|
|
curl 2>/dev/null -u $4:$5 -X PUT https://nextcloud.kaminsky.me/remote.php/webdav/$repository-findbugs/$6.html --upload-file build/reports/findbugs/findbugs.html
|
|
|
|
|
2018-06-21 15:11:55 +03:00
|
|
|
# delete all old comments
|
2018-11-01 12:59:08 +03:00
|
|
|
oldComments=$(curl 2>/dev/null -u $1:$2 -X GET https://api.github.com/repos/nextcloud/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
|
2018-06-22 12:45:00 +03:00
|
|
|
curl 2>/dev/null -u $1:$2 -X DELETE https://api.github.com/repos/nextcloud/android/issues/comments/$comment
|
2018-06-21 15:11:55 +03:00
|
|
|
done
|
2018-11-01 12:59:08 +03:00
|
|
|
|
2018-08-30 13:24:50 +03:00
|
|
|
# check library, only if base branch is master
|
|
|
|
baseBranch=$(scripts/analysis/getBranchBase.sh $1 $2 $7 | tr -d "\"")
|
|
|
|
if [ $baseBranch = "master" -a $(grep "android-library:master" build.gradle -c) -ne 3 ]; then
|
2018-08-27 17:15:23 +03:00
|
|
|
checkLibraryMessage="<h1>Android-library is not set to master branch in build.gradle</h1>"
|
|
|
|
checkLibrary=1
|
2018-11-01 12:59:08 +03:00
|
|
|
else
|
2018-08-27 17:15:23 +03:00
|
|
|
checkLibrary=0
|
|
|
|
fi
|
2018-11-01 12:59:08 +03:00
|
|
|
|
2018-09-25 12:55:53 +03:00
|
|
|
# lint and findbugs file must exist
|
|
|
|
if [ ! -s build/reports/lint/lint.html ] ; then
|
|
|
|
echo "lint.html file is missing!"
|
|
|
|
exit 1
|
|
|
|
fi
|
2018-11-01 12:59:08 +03:00
|
|
|
|
2018-09-25 12:55:53 +03:00
|
|
|
if [ ! -s build/reports/findbugs/findbugs.html ] ; then
|
|
|
|
echo "findbugs.html file is missing!"
|
|
|
|
exit 1
|
2018-11-01 12:59:08 +03:00
|
|
|
fi
|
|
|
|
|
2018-06-21 10:06:33 +03:00
|
|
|
# add comment with results
|
2018-07-03 10:05:21 +03:00
|
|
|
lintResultNew=$(grep "Lint Report.* [0-9]* warnings" build/reports/lint/lint.html | cut -f2 -d':' |cut -f1 -d'<')
|
2018-11-01 12:59:08 +03:00
|
|
|
lintErrorNew=$(echo $lintResultNew | grep "[0-9]* error" -o | cut -f1 -d" ")
|
|
|
|
lintWarningNew=$(echo $lintResultNew | grep "[0-9]* warning" -o | cut -f1 -d" ")
|
2018-07-04 16:59:10 +03:00
|
|
|
lintErrorOld=$(grep "[0-9]* error" scripts/analysis/lint-results.txt -o | cut -f1 -d" ")
|
|
|
|
lintWarningOld=$(grep "[0-9]* warning" scripts/analysis/lint-results.txt -o | cut -f1 -d" ")
|
2018-11-01 12:59:08 +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/"$repository"-lint/"$stableBranch".html'>$stableBranch</a></td><td><a href='https://www.kaminsky.me/nc-dev/"$repository"-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>"
|
|
|
|
findbugsResultNew=$(sed -n "/<h1>Summary<\/h1>/,/<h1>Warnings<\/h1>/p" build/reports/findbugs/findbugs.html |head -n-1 | sed s'/<\/a>//'g | sed s'/<a.*>//'g | sed s"#Summary#<a href=\"https://www.kaminsky.me/nc-dev/$repository-findbugs/$6.html\">FindBugs</a> (new)#" | tr "\"" "\'" | tr -d "\n")
|
|
|
|
findbugsResultOld=$(curl 2>/dev/null https://www.kaminsky.me/nc-dev/$repository-findbugs/findbugs-summary-$stableBranch.html | tr "\"" "\'" | tr -d "\r\n" | sed s"#FindBugs#<a href=\"https://www.kaminsky.me/nc-dev/$repository-findbugs/$stableBranch.html\">FindBugs</a>#" | tr "\"" "\'" | tr -d "\n")
|
2018-08-27 17:15:23 +03:00
|
|
|
curl -u $1:$2 -X POST https://api.github.com/repos/nextcloud/android/issues/$7/comments -d "{ \"body\" : \"$lintResult $findbugsResultNew $findbugsResultOld $checkLibraryMessage \" }"
|
2018-11-01 12:59:08 +03:00
|
|
|
|
2018-08-27 17:15:23 +03:00
|
|
|
if [ $checkLibrary -eq 1 ]; then
|
|
|
|
exit 1
|
|
|
|
fi
|
2018-11-01 12:59:08 +03:00
|
|
|
|
2018-06-21 10:06:33 +03:00
|
|
|
if [ $lintValue -eq 2 ]; then
|
|
|
|
exit 0
|
|
|
|
else
|
|
|
|
exit $lintValue
|
2018-11-01 12:59:08 +03:00
|
|
|
fi
|
2018-06-21 10:06:33 +03:00
|
|
|
fi
|