@@ -14,76 +14,72 @@ stableBranch="main"
1414repository=" android-singleSignOn"
1515codacyProject=160903
1616
17- ruby scripts/analysis/findbugs-up.rb $1 $2 $3
18- findbugsValue=$?
17+ curl " https://www.kaminsky.me/nc-dev/$repository -findbugs/$stableBranch .xml" -o " /tmp/$stableBranch .xml"
18+ ruby scripts/analysis/spotbugs-up.rb " $stableBranch "
19+ spotbugsValue=$?
1920
2021# exit codes:
2122# 0: count was reduced
2223# 1: count was increased
2324# 2: count stayed the same
2425
25- echo " Branch: $1 "
26+ source scripts/lib.sh
2627
27- if [ $1 = $stableBranch ]; then
28- echo " New findbugs result for $stableBranch at: https://www.kaminsky.me/nc-dev/$repository -findbugs/$stableBranch .html"
29- curl -u " ${LOG_USERNAME} :${LOG_PASSWORD} " -X PUT https://nextcloud.kaminsky.me/remote.php/webdav/$repository -findbugs/$stableBranch .html --upload-file lib/build/reports/spotbugs/spotbugs.html
28+ echo " Branch: $BRANCH "
3029
31- summary=$( sed -n " /<h1>Summary<\/h1>/,/<h1>Warnings<\/h1>/p" lib/build/reports/spotbugs/spotbugs.html | head -n-1 | sed s' /<\/a>//' g | sed s' /<a.*>//' g | sed s" /Summary/SpotBugs ($stableBranch )/" | tr " \" " " \'" | tr -d " \r\n" )
32- curl -u " ${LOG_USERNAME} :${LOG_PASSWORD} " -X PUT -d " $summary " https://nextcloud.kaminsky.me/remote.php/webdav/$repository -findbugs/findbugs-summary-$stableBranch .html
30+ if [ " $BRANCH " = $stableBranch ]; then
31+ echo " New spotbugs result for $stableBranch at: https://www.kaminsky.me/nc-dev/$repository -findbugs/$stableBranch .html"
32+ curl -u " ${LOG_USERNAME} :${LOG_PASSWORD} " -X PUT https://nextcloud.kaminsky.me/remote.php/webdav/$repository -findbugs/$stableBranch .html --upload-file library/build/reports/spotbugs/spotbugs.html
33+ curl 2> /dev/null -u " ${LOG_USERNAME} :${LOG_PASSWORD} " -X PUT " https://nextcloud.kaminsky.me/remote.php/webdav/$repository -findbugs/$stableBranch .xml" --upload-file library/build/reports/spotbugs/debug.xml
3334else
34- if [ -e $6 ]; then
35- name=$stableBranch " -" $( date +%F)
36- else
37- name=$6 ;
35+ if [ -e " ${BUILD_NUMBER} " ]; then
36+ 6=$stableBranch " -" $( date +%F)
3837 fi
3938
40- echo " New findbugs results at https://www.kaminsky.me/nc-dev/$repository -findbugs/$name .html"
41- curl 2> /dev/null -u " ${LOG_USERNAME} :${LOG_PASSWORD} " -X PUT https://nextcloud.kaminsky.me/remote.php/webdav/$repository -findbugs/$name .html --upload-file lib /build/reports/spotbugs/spotbugs.html
39+ echo " New spotbugs results at https://www.kaminsky.me/nc-dev/$repository -findbugs/${BUILD_NUMBER} .html"
40+ curl 2> /dev/null -u " ${LOG_USERNAME} :${LOG_PASSWORD} " -X PUT " https://nextcloud.kaminsky.me/remote.php/webdav/$repository -findbugs/${BUILD_NUMBER} .html" --upload-file library /build/reports/spotbugs/spotbugs.html
4241
4342 # delete all old comments, starting with Codacy
44- oldComments=$( curl 2> /dev/null -u $1 : $2 - X GET https://api.github.com/repos/nextcloud/$repository /issues/$7 /comments | jq ' .[] | (.id |tostring) + "|" + (.user.login | test("nextcloud-android-bot") | tostring) + "|" + (.body | test("<h1>Codacy.*") | tostring) ' | grep " true|true " | tr -d " \" " | cut -f1 -d " | " )
43+ oldComments=$( curl_gh - X GET " https://api.github.com/repos/nextcloud/$repository /issues/${PR_NUMBER} /comments" | jq ' .[] | select( (.user.login | contains("github-actions")) and (.body | test("<h1>Codacy.*"))) | .id ' )
4544
46- echo $oldComments | while read comment ; do
47- curl 2> /dev/null -u " ${LOG_USERNAME} : ${LOG_PASSWORD} " - X DELETE https://api.github.com/repos/nextcloud/$repository /issues/comments/$comment
45+ echo " $oldComments " | while read -r comment ; do
46+ curl_gh - X DELETE " https://api.github.com/repos/nextcloud/$repository /issues/comments/$comment "
4847 done
4948
50- # findbugs file must exist
51- if [ ! -s lib /build/reports/spotbugs/spotbugs.html ] ; then
49+ # spotbugs file must exist
50+ if [ ! -s library /build/reports/spotbugs/spotbugs.html ] ; then
5251 echo " spotbugs.html file is missing!"
5352 exit 1
5453 fi
5554
5655 # add comment with results
57- if [ $stableBranch = " master" ] ; then
58- codacyValue=$( curl 2> /dev/null https://app.codacy.com/dashboards/breakdown\? projectId\= $codacyProject | grep " total issues" | cut -d" >" -f3 | cut -d" <" -f1)
59- codacyResult=" <h1>Codacy</h1>$codacyValue "
60- else
61- codacyResult=" "
62- fi
56+ spotbugsResult=" <h1>SpotBugs</h1>$( scripts/analysis/spotbugsComparison.py " /tmp/$stableBranch .xml" library/build/reports/spotbugs/debug.xml --link-new " https://www.kaminsky.me/nc-dev/$repository -findbugs/${BUILD_NUMBER} .html" --link-base " https://www.kaminsky.me/nc-dev/$repository -findbugs/$stableBranch .html" ) "
6357
64- findbugsResultNew=$( sed -n " /<h1>Summary<\/h1>/,/<h1>Warnings<\/h1>/p" lib/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/$repository -findbugs/$name .html\" >SpotBugs</a> (new)#" | tr " \" " " \'" | tr -d " \n" )
65- findbugsResultOld=$( curl 2> /dev/null https://www.kaminsky.me/nc-dev/$repository -findbugs/findbugs-summary-$stableBranch .html | tr " \" " " \'" | tr -d " \r\n" | sed s" #SpotBugs#<a href=\" https://www.kaminsky.me/nc-dev/$repository -findbugs/$stableBranch .html\" >SpotBugs</a>#" | tr " \" " " \'" | tr -d " \n" )
66-
67- if ( [ $findbugsValue -eq 1 ] ) ; then
68- findbugsMessage=" <h1>SpotBugs increased!</h1>"
58+ if ( [ $spotbugsValue -eq 1 ] ) ; then
59+ spotbugsMessage=" <h1>SpotBugs increased!</h1>"
60+ fi
61+
62+ # check for NotNull
63+ if [[ $( grep org.jetbrains.annotations library/src/main/* -irl | wc -l) -gt 0 ]] ; then
64+ notNull=" org.jetbrains.annotations.* is used. Please use androidx.annotation.* instead.<br><br>"
6965 fi
7066
71- # check gplay limitation: all changelog files must only have 500 chars
72- gplayLimitation=$( scripts/checkGplayLimitation.sh)
67+ bodyContent=" $spotbugsResult $spotbugsMessage $gplayLimitation $notNull "
68+ echo " $bodyContent " >> " $GITHUB_STEP_SUMMARY "
69+ payload=" { \" body\" : \" $bodyContent \" }"
70+ curl_gh -X POST " https://api.github.com/repos/nextcloud/$repository /issues/${PR_NUMBER} /comments" -d " $payload "
7371
7472 if [ ! -z " $gplayLimitation " ]; then
75- gplayLimitation= " <h1>Following files are beyond 500 char limit:</h1><br><br> " $gplayLimitation
73+ exit 1
7674 fi
7775
78- curl -u $1 :$2 -X POST https://api.github.com/repos/nextcloud/$repository /issues/$7 /comments -d " { \" body\" : \" $codacyResult $findbugsResultNew $findbugsResultOld $findbugsMessage $gplayLimitation \" }"
79-
80- if [ ! -z " $gplayLimitation " ]; then
76+ if [ -n " $notNull " ]; then
8177 exit 1
8278 fi
8379
84- if [ $findbugsValue -eq 2 ]; then
80+ if [ $spotbugsValue -eq 2 ]; then
8581 exit 0
8682 else
87- exit $findbugsValue
83+ exit $spotbugsValue
8884 fi
8985fi
0 commit comments