diff --git a/scripts/analysis/analysis-wrapper.sh b/scripts/analysis/analysis-wrapper.sh index ad08fb1579..d6a002fcb0 100755 --- a/scripts/analysis/analysis-wrapper.sh +++ b/scripts/analysis/analysis-wrapper.sh @@ -8,6 +8,9 @@ #6: DRONE_BUILD_NUMBER #7: PULL_REQUEST_NUMBER +stableBranch="master" +repository="android" + ruby scripts/analysis/lint-up.rb $1 $2 $3 lintValue=$? @@ -20,73 +23,73 @@ lintValue=$? echo "Branch: $3" -if [ $3 = "master" ]; then - echo "New findbugs result for master at: https://www.kaminsky.me/nc-dev/client-findbugs/master.html" - curl -u $4:$5 -X PUT https://nextcloud.kaminsky.me/remote.php/webdav/findbugs/master.html --upload-file build/reports/findbugs/findbugs.html - - summary=$(sed -n "/

Summary<\/h1>/,/

Warnings<\/h1>/p" build/reports/findbugs/findbugs.html | head -n-1 | sed s'/<\/a>//'g | sed s'///'g | sed s'/Summary/FindBugs (master)/' | tr "\"" "\'" | tr -d "\r\n") - curl -u $4:$5 -X PUT -d "$summary" https://nextcloud.kaminsky.me/remote.php/webdav/findbugs/findbugs.html - +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 + + summary=$(sed -n "/

Summary<\/h1>/,/

Warnings<\/h1>/p" build/reports/findbugs/findbugs.html | head -n-1 | sed s'/<\/a>//'g | sed s'///'g | sed s'/Summary/FindBugs ($stableBranch)/' | tr "\"" "\'" | tr -d "\r\n") + curl -u $4:$5 -X PUT -d "$summary" https://nextcloud.kaminsky.me/remote.php/webdav/$repository-findbugs/findbugs-summary-$stableBranch.html + if [ $lintValue -ne 1 ]; then - echo "New lint result for master at: https://www.kaminsky.me/nc-dev/client-lint/master.html" - curl -u $4:$5 -X PUT https://nextcloud.kaminsky.me/remote.php/webdav/droneLogs/master.html --upload-file build/reports/lint/lint.html + 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 exit 0 fi else if [ -e $6 ]; then - 6="master-"$(date +%F) + 6=$stableBranch"-"$(date +%F) fi - echo "New lint results at https://www.kaminsky.me/nc-dev/client-lint/$6.html" - curl 2>/dev/null -u $4:$5 -X PUT https://nextcloud.kaminsky.me/remote.php/webdav/droneLogs/$6.html --upload-file build/reports/lint/lint.html - - echo "New findbugs results at https://www.kaminsky.me/nc-dev/client-findbugs/$6.html" - curl 2>/dev/null -u $4:$5 -X PUT https://nextcloud.kaminsky.me/remote.php/webdav/findbugs/$6.html --upload-file build/reports/findbugs/findbugs.html - + 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 + # delete all old comments - 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 + 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 curl 2>/dev/null -u $1:$2 -X DELETE https://api.github.com/repos/nextcloud/android/issues/comments/$comment done - + # 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 checkLibraryMessage="

Android-library is not set to master branch in build.gradle

" checkLibrary=1 - else + else checkLibrary=0 fi - + # lint and findbugs file must exist if [ ! -s build/reports/lint/lint.html ] ; then echo "lint.html file is missing!" exit 1 fi - + if [ ! -s build/reports/findbugs/findbugs.html ] ; then echo "findbugs.html file is missing!" exit 1 - fi - + fi + # add comment with results lintResultNew=$(grep "Lint Report.* [0-9]* warnings" build/reports/lint/lint.html | cut -f2 -d':' |cut -f1 -d'<') - lintErrorNew=$(echo $lintResultNew | grep "[0-9]* error" -o | cut -f1 -d" ") - lintWarningNew=$(echo $lintResultNew | grep "[0-9]* warning" -o | cut -f1 -d" ") + lintErrorNew=$(echo $lintResultNew | grep "[0-9]* error" -o | cut -f1 -d" ") + lintWarningNew=$(echo $lintResultNew | grep "[0-9]* warning" -o | cut -f1 -d" ") 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" ") - lintResult="

Lint

TypeMasterPR
Warnings"$lintWarningOld""$lintWarningNew"
Errors"$lintErrorOld""$lintErrorNew"
" - findbugsResultNew=$(sed -n "/

Summary<\/h1>/,/

Warnings<\/h1>/p" build/reports/findbugs/findbugs.html |head -n-1 | sed s'/<\/a>//'g | sed s'///'g | sed s"#Summary#FindBugs (new)#" | tr "\"" "\'" | tr -d "\n") - findbugsResultOld=$(curl 2>/dev/null https://nextcloud.kaminsky.me/index.php/s/YaHngKMM6ERmBeg/download | tr "\"" "\'" | tr -d "\r\n" | sed s'#FindBugs#FindBugs#'| tr "\"" "\'" | tr -d "\n") + lintResult="

Lint

Type$stableBranchPR
Warnings"$lintWarningOld""$lintWarningNew"
Errors"$lintErrorOld""$lintErrorNew"
" + findbugsResultNew=$(sed -n "/

Summary<\/h1>/,/

Warnings<\/h1>/p" build/reports/findbugs/findbugs.html |head -n-1 | sed s'/<\/a>//'g | sed s'///'g | sed s"#Summary#FindBugs (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#FindBugs#" | tr "\"" "\'" | tr -d "\n") curl -u $1:$2 -X POST https://api.github.com/repos/nextcloud/android/issues/$7/comments -d "{ \"body\" : \"$lintResult $findbugsResultNew $findbugsResultOld $checkLibraryMessage \" }" - + if [ $checkLibrary -eq 1 ]; then exit 1 fi - + if [ $lintValue -eq 2 ]; then exit 0 else exit $lintValue - fi + fi fi diff --git a/scripts/uploadReport.sh b/scripts/uploadReport.sh index 3ba9aa5605..70509c6fa4 100755 --- a/scripts/uploadReport.sh +++ b/scripts/uploadReport.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -URL=https://nextcloud.kaminsky.me/remote.php/webdav/integrationTests +URL=https://nextcloud.kaminsky.me/remote.php/webdav/android-integrationTests ID=$3 USER=$1 PASS=$2 @@ -8,12 +8,12 @@ TYPE=$4 if [ $TYPE = "IT" ]; then cd build/reports/androidTests/connected/flavors/GPLAY -else +else cd build/reports/tests/testGplayDebugUnitTest fi find . -type d -exec curl -u $USER:$PASS -X MKCOL $URL/$ID/$(echo {} | sed s#\./##) \; find . -type f -exec curl -u $USER:$PASS -X PUT $URL/$ID/$(echo {} | sed s#\./##) --upload-file {} \; -echo "Uploaded failing tests to https://nextcloud.kaminsky.me/index.php/s/XqY52jBr9ZYfDiz -> $ID" +echo "Uploaded failing tests to https://www.kaminsky.me/nc-dev/android-integrationTests/$ID" exit 1