|
@@ -1,17 +1,16 @@
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
-#1: GIT_USERNAME
|
|
|
-#2: GIT_TOKEN
|
|
|
-#3: BRANCH
|
|
|
-#4: LOG_USERNAME
|
|
|
-#5: LOG_PASSWORD
|
|
|
-#6: DRONE_BUILD_NUMBER
|
|
|
-#7: PULL_REQUEST_NUMBER
|
|
|
+BRANCH=$1
|
|
|
+LOG_USERNAME=$2
|
|
|
+LOG_PASSWORD=$3
|
|
|
+BUILD_NUMBER=$4
|
|
|
+PR_NUMBER=$5
|
|
|
+
|
|
|
|
|
|
stableBranch="master"
|
|
|
repository="android"
|
|
|
|
|
|
-ruby scripts/analysis/lint-up.rb $1 $2 $3
|
|
|
+ruby scripts/analysis/lint-up.rb
|
|
|
lintValue=$?
|
|
|
|
|
|
curl "https://www.kaminsky.me/nc-dev/$repository-findbugs/$stableBranch.xml" -o "/tmp/$stableBranch.xml"
|
|
@@ -23,37 +22,39 @@ spotbugsValue=$?
|
|
|
# 1: count was increased
|
|
|
# 2: count stayed the same
|
|
|
|
|
|
-echo "Branch: $3"
|
|
|
+source scripts/lib.sh
|
|
|
+
|
|
|
+echo "Branch: $BRANCH"
|
|
|
|
|
|
-if [ $3 = $stableBranch ]; then
|
|
|
+if [ "$BRANCH" = $stableBranch ]; then
|
|
|
echo "New spotbugs 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 app/build/reports/spotbugs/spotbugs.html
|
|
|
- curl 2>/dev/null -u "$4:$5" -X PUT "https://nextcloud.kaminsky.me/remote.php/webdav/$repository-findbugs/$stableBranch.xml" --upload-file app/build/reports/spotbugs/gplayDebug.xml
|
|
|
+ curl -u "${LOG_USERNAME}:${LOG_PASSWORD}" -X PUT https://nextcloud.kaminsky.me/remote.php/webdav/$repository-findbugs/$stableBranch.html --upload-file app/build/reports/spotbugs/spotbugs.html
|
|
|
+ curl 2>/dev/null -u "${LOG_USERNAME}:${LOG_PASSWORD}" -X PUT "https://nextcloud.kaminsky.me/remote.php/webdav/$repository-findbugs/$stableBranch.xml" --upload-file app/build/reports/spotbugs/gplayDebug.xml
|
|
|
|
|
|
if [ $lintValue -ne 1 ]; then
|
|
|
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 app/build/reports/lint/lint.html
|
|
|
+ curl -u "${LOG_USERNAME}:${LOG_PASSWORD}" -X PUT https://nextcloud.kaminsky.me/remote.php/webdav/$repository-lint/$stableBranch.html --upload-file app/build/reports/lint/lint.html
|
|
|
exit 0
|
|
|
fi
|
|
|
else
|
|
|
- if [ -e $6 ]; then
|
|
|
+ if [ -e "${BUILD_NUMBER}" ]; then
|
|
|
6=$stableBranch"-"$(date +%F)
|
|
|
fi
|
|
|
- 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 app/build/reports/lint/lint.html
|
|
|
+ echo "New lint results at https://www.kaminsky.me/nc-dev/$repository-lint/${BUILD_NUMBER}.html"
|
|
|
+ curl 2>/dev/null -u "${LOG_USERNAME}:${LOG_PASSWORD}" -X PUT "https://nextcloud.kaminsky.me/remote.php/webdav/$repository-lint/${BUILD_NUMBER}.html" --upload-file app/build/reports/lint/lint.html
|
|
|
|
|
|
- echo "New spotbugs 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 app/build/reports/spotbugs/spotbugs.html
|
|
|
+ echo "New spotbugs results at https://www.kaminsky.me/nc-dev/$repository-findbugs/${BUILD_NUMBER}.html"
|
|
|
+ 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 app/build/reports/spotbugs/spotbugs.html
|
|
|
|
|
|
# delete all old comments, starting with Codacy
|
|
|
- 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) + "|" + (.body | test("<h1>Codacy.*") | tostring)' | grep "true|true" | tr -d "\"" | cut -f1 -d"|")
|
|
|
+ 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')
|
|
|
|
|
|
- echo $oldComments | while read comment ; do
|
|
|
- curl 2>/dev/null -u $1:$2 -X DELETE https://api.github.com/repos/nextcloud/android/issues/comments/$comment
|
|
|
+ echo "$oldComments" | while read -r comment ; do
|
|
|
+ curl_gh -X DELETE "https://api.github.com/repos/nextcloud/$repository/issues/comments/$comment"
|
|
|
done
|
|
|
|
|
|
# check library, only if base branch is master
|
|
|
- baseBranch=$(scripts/analysis/getBranchBase.sh $1 $2 $7 | tr -d "\"")
|
|
|
+ baseBranch=$(scripts/analysis/getBranchBase.sh "${PR_NUMBER}" | tr -d "\"")
|
|
|
if [ $baseBranch = "master" -a $(grep "androidLibraryVersion = \"master-SNAPSHOT\"" build.gradle -c) -ne 1 ]; then
|
|
|
checkLibraryMessage="<h1>Android-library is not set to master branch in build.gradle</h1>"
|
|
|
checkLibrary=1
|
|
@@ -88,7 +89,7 @@ else
|
|
|
lintWarningNew=0
|
|
|
fi
|
|
|
|
|
|
- lintResultOld=$(curl 2>/dev/null https://raw.githubusercontent.com/nextcloud/android/$stableBranch/scripts/analysis/lint-results.txt)
|
|
|
+ lintResultOld=$(curl 2>/dev/null "https://raw.githubusercontent.com/nextcloud/$repository/$stableBranch/scripts/analysis/lint-results.txt")
|
|
|
lintErrorOld=$(echo $lintResultOld | grep "[0-9]* error" -o | cut -f1 -d" ")
|
|
|
if ( [ -z $lintErrorOld ] ); then
|
|
|
lintErrorOld=0
|
|
@@ -106,9 +107,9 @@ else
|
|
|
codacyResult=""
|
|
|
fi
|
|
|
|
|
|
- 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>"
|
|
|
+ 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/${BUILD_NUMBER}.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>"
|
|
|
|
|
|
- spotbugsResult="<h1>SpotBugs</h1>$(scripts/analysis/spotbugsComparison.py "/tmp/$stableBranch.xml" app/build/reports/spotbugs/gplayDebug.xml --link-new "https://www.kaminsky.me/nc-dev/$repository-findbugs/$6.html" --link-base "https://www.kaminsky.me/nc-dev/$repository-findbugs/$stableBranch.html")"
|
|
|
+ spotbugsResult="<h1>SpotBugs</h1>$(scripts/analysis/spotbugsComparison.py "/tmp/$stableBranch.xml" app/build/reports/spotbugs/gplayDebug.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")"
|
|
|
|
|
|
if ( [ $lintValue -eq 1 ] ) ; then
|
|
|
lintMessage="<h1>Lint increased!</h1>"
|
|
@@ -131,7 +132,7 @@ else
|
|
|
fi
|
|
|
|
|
|
payload="{ \"body\" : \"$codacyResult $lintResult $spotbugsResult $checkLibraryMessage $lintMessage $spotbugsMessage $gplayLimitation $notNull\" }"
|
|
|
- curl -u "$1:$2" -X POST "https://api.github.com/repos/nextcloud/android/issues/$7/comments" -d "$payload"
|
|
|
+ curl_gh -X POST "https://api.github.com/repos/nextcloud/$repository/issues/${PR_NUMBER}/comments" -d "$payload"
|
|
|
|
|
|
if [ ! -z "$gplayLimitation" ]; then
|
|
|
exit 1
|