Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit 707f7b6b authored by Tobias Kaminsky's avatar Tobias Kaminsky Committed by GitHub
Browse files

Merge d30bdd23 into af200775

parents af200775 d30bdd23
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -19,11 +19,11 @@ pipeline:
        - bash ./codecov.sh -t 2eec98c3-ff20-4cad-9e08-463471a33431
      secrets: [ LOG_USERNAME, LOG_PASSWORD ]

  lint:
      image: nextcloudci/android:android-33
  analysis:
    image: nextcloudci/android:android-42
    commands:
        - export BRANCH=$(scripts/lint/getBranchName.sh $GIT_USERNAME $GIT_TOKEN $DRONE_PULL_REQUEST)
        - scripts/lint/lint-up-wrapper.sh $GIT_USERNAME $GIT_TOKEN $BRANCH $LOG_USERNAME $LOG_PASSWORD $DRONE_BUILD_NUMBER
      - export BRANCH=$(scripts/analysis/getBranchName.sh $GIT_USERNAME $GIT_TOKEN $DRONE_PULL_REQUEST)
      - scripts/analysis/analysis-wrapper.sh $GIT_USERNAME $GIT_TOKEN $BRANCH $LOG_USERNAME $LOG_PASSWORD $DRONE_BUILD_NUMBER $DRONE_PULL_REQUEST
    secrets: [ GIT_USERNAME, GIT_TOKEN, LOG_USERNAME, LOG_PASSWORD ]

  notify:
+25 −0
Original line number Diff line number Diff line
@@ -11,6 +11,7 @@ buildscript {

apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'findbugs'

repositories {
    google()
@@ -23,6 +24,9 @@ dependencies {
    annotationProcessor 'org.parceler:parceler:1.1.9'
    implementation group: 'com.google.code.gson', name: 'gson', version: '2.8.5'
    implementation "com.android.support:support-annotations:28.0.0"
    
    findbugsPlugins 'com.h3xstream.findsecbugs:findsecbugs-plugin:1.8.0'
    findbugsPlugins 'com.mebigfatguy.fb-contrib:fb-contrib:7.4.3'
}

android {
@@ -62,4 +66,25 @@ android {
        minSdkVersion 14
        targetSdkVersion 28
    }

    task findbugs(type: FindBugs) {
        ignoreFailures = false
        effort = "max"
        reportLevel = "medium"
        classes = fileTree("$project.buildDir/intermediates/javac/debug/compileDebugJavaWithJavac/classes/")
        excludeFilter = file("${project.rootDir}/scripts/analysis/findbugs-filter.xml")
        source = fileTree('src/main/java')
        pluginClasspath = project.configurations.findbugsPlugins
        classpath = files()
        include '**/*.java'
        exclude '**/gen/**'

        reports {
            xml.enabled = false
            html.enabled = true
            html {
                destination = file("$project.buildDir/reports/findbugs/findbugs.html")
            }
        }
    }
}
+79 −0
Original line number Diff line number Diff line
#!/bin/sh

#1: GIT_USERNAME
#2: GIT_TOKEN
#3: BRANCH
#4: LOG_USERNAME
#5: LOG_PASSWORD
#6: DRONE_BUILD_NUMBER
#7: PULL_REQUEST_NUMBER

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

./gradlew findbugs

echo "Branch: $3"

if [ $3 = "master" ]; then
    echo "New findbugs result for master at: https://www.kaminsky.me/nc-dev/library-findbugs/master.html"
    curl -u $4:$5 -X PUT https://nextcloud.kaminsky.me/remote.php/webdav/library-findbugs/master.html --upload-file build/reports/findbugs/findbugs.html
    
    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 (master)/' | tr "\"" "\'" | tr -d "\r\n")
    curl -u $4:$5 -X PUT -d "$summary" https://nextcloud.kaminsky.me/remote.php/webdav/library-findbugs/findbugs.html
    
    if [ $lintValue -ne 1 ]; then
        echo "New lint result for master at: https://www.kaminsky.me/nc-dev/library-lint/master.html"
        curl -u $4:$5 -X PUT https://nextcloud.kaminsky.me/remote.php/webdav/library-lint/master.html --upload-file build/reports/lint/lint.html
        exit 0
    fi
else
    if [ -e $6 ]; then
        6="master-"$(date +%F)
    fi
    echo "New lint results at https://www.kaminsky.me/nc-dev/library-lint/$6.html"
    curl 2>/dev/null -u $4:$5 -X PUT https://nextcloud.kaminsky.me/remote.php/webdav/library-lint/$6.html --upload-file build/reports/lint/lint.html
    
    echo "New findbugs results at https://www.kaminsky.me/nc-dev/library-findbugs/$6.html"
    curl 2>/dev/null -u $4:$5 -X PUT https://nextcloud.kaminsky.me/remote.php/webdav/library-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-library/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-library/issues/comments/$comment
    done
    
    # 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 
    
    # 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" ")
    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="<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/library-lint/master.html'>Master</a></td><td><a href='https://www.kaminsky.me/nc-dev/library-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/library-findbugs/$6.html\">FindBugs</a> (new)#" | tr "\"" "\'" | tr -d "\n")
    findbugsResultOld=$(curl 2>/dev/null https://nextcloud.kaminsky.me/index.php/s/9BjSFLsWY988ZKR/download | tr "\"" "\'" | tr -d "\r\n" | sed s'#FindBugs#<a href=\"https://www.kaminsky.me/nc-dev/library-findbugs/master.html">FindBugs</a>#'| tr "\"" "\'" | tr -d "\n") 
    curl -u $1:$2 -X POST https://api.github.com/repos/nextcloud/android-library/issues/$7/comments -d "{ \"body\" : \"$lintResult $findbugsResultNew $findbugsResultOld \" }"

    if [ $lintValue -eq 2 ]; then
        exit 0
    else
        exit $lintValue
    fi  
fi
+11 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="UTF-8"?>


<FindBugsFilter>
    <Match>
        <Class name="~.*\.Manifest\$.*" />
    </Match>
    <Match>
        <Class name="~.*\.R\$.*" />
    </Match>
</FindBugsFilter>
+9 −0
Original line number Diff line number Diff line
#!/bin/bash

# $1: username, $2: password/token, $3: pull request number

if [ -z $3 ] ; then
    echo "master";
else
    curl 2>/dev/null -u $1:$2 https://api.github.com/repos/nextcloud/android-library/pulls/$3 | jq .base.ref
fi
Loading