mirror of
https://github.com/nextcloud/talk-android
synced 2025-03-06 14:27:24 +00:00
Merge pull request #305 from nextcloud/findbugsLint
Add support for findBugs, lint
This commit is contained in:
commit
1863ed6789
16
.drone.yml
16
.drone.yml
@ -1,22 +1,22 @@
|
|||||||
pipeline:
|
pipeline:
|
||||||
compile:
|
compile:
|
||||||
image: nextcloudci/android:android-33
|
image: nextcloudci/android:android-35
|
||||||
commands:
|
commands:
|
||||||
# build app and assemble APK
|
# build app and assemble APK
|
||||||
- sh -c "if [ '${FLAVOR}' != 'Lint' ]; then ./gradlew assemble${FLAVOR}; fi"
|
- sh -c "if [ '${FLAVOR}' != 'Analysis' ]; then ./gradlew assemble${FLAVOR}; fi"
|
||||||
when:
|
when:
|
||||||
matrix:
|
matrix:
|
||||||
FLAVOR: [Generic, Gplay]
|
FLAVOR: [Generic, Gplay]
|
||||||
|
|
||||||
lint:
|
analysis:
|
||||||
image: nextcloudci/android:android-33
|
image: nextcloudci/android:android-37
|
||||||
commands:
|
commands:
|
||||||
- export BRANCH=$(scripts/lint/getBranchName.sh $GIT_USERNAME $GIT_TOKEN $DRONE_PULL_REQUEST)
|
- export BRANCH=$(scripts/analysis/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
|
- 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 ]
|
secrets: [ GIT_USERNAME, GIT_TOKEN, LOG_USERNAME, LOG_PASSWORD ]
|
||||||
when:
|
when:
|
||||||
matrix:
|
matrix:
|
||||||
FLAVOR: Lint
|
FLAVOR: Analysis
|
||||||
|
|
||||||
notify:
|
notify:
|
||||||
image: drillster/drone-email
|
image: drillster/drone-email
|
||||||
@ -37,6 +37,6 @@ matrix:
|
|||||||
FLAVOR:
|
FLAVOR:
|
||||||
- Generic
|
- Generic
|
||||||
- Gplay
|
- Gplay
|
||||||
- Lint
|
- Analysis
|
||||||
|
|
||||||
branches: master
|
branches: master
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
apply plugin: 'com.android.application'
|
apply plugin: 'com.android.application'
|
||||||
apply plugin: 'kotlin-android'
|
apply plugin: 'kotlin-android'
|
||||||
|
apply plugin: 'findbugs'
|
||||||
|
|
||||||
if (getGradle().getStartParameter().getTaskRequests().toString().contains("Gplay")){
|
def taskRequest = getGradle().getStartParameter().getTaskRequests().toString()
|
||||||
|
if (taskRequest.contains("Gplay") || taskRequest.contains("findbugs") || taskRequest.contains("lint")) {
|
||||||
apply from: 'gplay.gradle'
|
apply from: 'gplay.gradle'
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,6 +64,27 @@ android {
|
|||||||
htmlOutput file("$project.buildDir/reports/lint/lint.html")
|
htmlOutput file("$project.buildDir/reports/lint/lint.html")
|
||||||
disable 'MissingTranslation'
|
disable 'MissingTranslation'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
task findbugs(type: FindBugs) {
|
||||||
|
ignoreFailures = false
|
||||||
|
effort = "max"
|
||||||
|
reportLevel = "medium"
|
||||||
|
classes = fileTree("$project.buildDir/intermediates/classes/gplay/debug/com/nextcloud")
|
||||||
|
excludeFilter = file("${project.rootDir}/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")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ext {
|
ext {
|
||||||
@ -174,4 +197,7 @@ dependencies {
|
|||||||
androidTestImplementation ('com.android.support.test.espresso:espresso-core:3.0.1', {
|
androidTestImplementation ('com.android.support.test.espresso:espresso-core:3.0.1', {
|
||||||
exclude group: 'com.android.support', module: 'support-annotations'
|
exclude group: 'com.android.support', module: 'support-annotations'
|
||||||
})
|
})
|
||||||
|
|
||||||
|
findbugsPlugins 'com.h3xstream.findsecbugs:findsecbugs-plugin:1.8.0'
|
||||||
|
findbugsPlugins 'com.mebigfatguy.fb-contrib:fb-contrib:7.4.3'
|
||||||
}
|
}
|
||||||
|
11
findbugs-filter.xml
Normal file
11
findbugs-filter.xml
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
|
||||||
|
<FindBugsFilter>
|
||||||
|
<Match>
|
||||||
|
<Class name="~.*\.Manifest\$.*"/>
|
||||||
|
</Match>
|
||||||
|
<Match>
|
||||||
|
<Class name="~.*\.R\$.*"/>
|
||||||
|
</Match>
|
||||||
|
</FindBugsFilter>
|
68
scripts/analysis/analysis-wrapper.sh
Executable file
68
scripts/analysis/analysis-wrapper.sh
Executable file
@ -0,0 +1,68 @@
|
|||||||
|
#!/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=$?
|
||||||
|
|
||||||
|
./gradlew assembleGplay app:findbugs
|
||||||
|
|
||||||
|
# exit codes:
|
||||||
|
# 0: count was reduced
|
||||||
|
# 1: count was increased
|
||||||
|
# 2: count stayed the same
|
||||||
|
|
||||||
|
echo "Branch: $3"
|
||||||
|
|
||||||
|
if [ $3 = "master" ]; then
|
||||||
|
echo "New findbugs result for master at: https://www.kaminsky.me/nc-dev/talk-findbugs/master.html"
|
||||||
|
curl -u $4:$5 -X PUT https://nextcloud.kaminsky.me/remote.php/webdav/talk-findbugs/master.html --upload-file app/build/reports/findbugs/findbugs.html
|
||||||
|
|
||||||
|
summary=$(sed -n "/<h1>Summary<\/h1>/,/<h1>Warnings<\/h1>/p" app/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/talk-findbugs/findbugs.html
|
||||||
|
|
||||||
|
if [ $lintValue -ne 1 ]; then
|
||||||
|
echo "New lint result for master at: https://www.kaminsky.me/nc-dev/talk-lint/master.html"
|
||||||
|
curl -u $4:$5 -X PUT https://nextcloud.kaminsky.me/remote.php/webdav/talk-droneLogs/master.html --upload-file app/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/talk-lint/$6.html"
|
||||||
|
curl 2>/dev/null -u $4:$5 -X PUT https://nextcloud.kaminsky.me/remote.php/webdav/talk-droneLogs/$6.html --upload-file app/build/reports/lint/lint.html
|
||||||
|
|
||||||
|
echo "New findbugs results at https://www.kaminsky.me/nc-dev/talk-findbugs/$6.html"
|
||||||
|
curl 2>/dev/null -u $4:$5 -X PUT https://nextcloud.kaminsky.me/remote.php/webdav/talk-findbugs/$6.html --upload-file app/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/talk-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/talk-android/issues/comments/$comment
|
||||||
|
done
|
||||||
|
|
||||||
|
# add comment with results
|
||||||
|
lintResultNew=$(grep "Lint Report.* [0-9]* warnings" app/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/talk-lint/master.html'>Master</a></td><td><a href='https://www.kaminsky.me/nc-dev/talk-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" app/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/talk-findbugs/$6.html\">FindBugs</a> (new)#" | tr "\"" "\'" | tr -d "\n")
|
||||||
|
findbugsResultOld=$(curl 2>/dev/null https://nextcloud.kaminsky.me/index.php/s/YCD729NgcMAYkJT/download | tr "\"" "\'" | tr -d "\r\n" | sed s'#FindBugs#<a href=\"https://www.kaminsky.me/nc-dev/talk-findbugs/master.html">FindBugs</a>#'| tr "\"" "\'" | tr -d "\n")
|
||||||
|
curl -u $1:$2 -X POST https://api.github.com/repos/nextcloud/talk-android/issues/$7/comments -d "{ \"body\" : \"$lintResult $findbugsResultNew $findbugsResultOld \" }"
|
||||||
|
|
||||||
|
if [ $lintValue -eq 2 ]; then
|
||||||
|
exit 0
|
||||||
|
else
|
||||||
|
exit $lintValue
|
||||||
|
fi
|
||||||
|
fi
|
2
scripts/analysis/lint-results.txt
Normal file
2
scripts/analysis/lint-results.txt
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
DO NOT TOUCH; GENERATED BY DRONE
|
||||||
|
<span class="mdl-layout-title">Lint Report: 1 error and 132 warnings</span>
|
@ -21,7 +21,7 @@ TRAVIS_GIT_USERNAME = String.new("Drone CI server")
|
|||||||
LINT_REPORT_FILE = String.new("app/build/reports/lint/lint.html")
|
LINT_REPORT_FILE = String.new("app/build/reports/lint/lint.html")
|
||||||
|
|
||||||
# File name and relative path of previous results of this script.
|
# File name and relative path of previous results of this script.
|
||||||
PREVIOUS_LINT_RESULTS_FILE=String.new("scripts/lint/lint-results.txt")
|
PREVIOUS_LINT_RESULTS_FILE=String.new("scripts/analysis/lint-results.txt")
|
||||||
|
|
||||||
# Flag to evaluate warnings. true = check warnings; false = ignore warnings
|
# Flag to evaluate warnings. true = check warnings; false = ignore warnings
|
||||||
CHECK_WARNINGS = true
|
CHECK_WARNINGS = true
|
@ -1,2 +0,0 @@
|
|||||||
DO NOT TOUCH; GENERATED BY DRONE
|
|
||||||
<span class="mdl-layout-title">Lint Report: 88 warnings</span>
|
|
@ -1,36 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
#1: GIT_USERNAME
|
|
||||||
#2: GIT_TOKEN
|
|
||||||
#3: BRANCH
|
|
||||||
#4: LOG_USERNAME
|
|
||||||
#5: LOG_PASSWORD
|
|
||||||
#6: DRONE_BUILD_NUMBER
|
|
||||||
|
|
||||||
ruby scripts/lint/lint-up.rb $1 $2 $3
|
|
||||||
returnValue=$?
|
|
||||||
|
|
||||||
# exit codes:
|
|
||||||
# 0: count was reduced
|
|
||||||
# 1: count was increased
|
|
||||||
# 2: count stayed the same
|
|
||||||
|
|
||||||
echo "Branch: $3"
|
|
||||||
|
|
||||||
if [ $3 = "master" -a $returnValue -ne 1 ]; then
|
|
||||||
echo "New master at: https://nextcloud.kaminsky.me/index.php/s/fyxdQjc7LCiy57C"
|
|
||||||
curl -u $4:$5 -X PUT https://nextcloud.kaminsky.me/remote.php/webdav/talk-droneLogs/master.html --upload-file app/build/reports/lint/lint.html
|
|
||||||
exit 0
|
|
||||||
else
|
|
||||||
if [ -e $6 ]; then
|
|
||||||
6="master-"$(date +%F)
|
|
||||||
fi
|
|
||||||
echo "New results at https://nextcloud.kaminsky.me/index.php/s/fyxdQjc7LCiy57C ->" $6.html
|
|
||||||
curl -u $4:$5 -X PUT https://nextcloud.kaminsky.me/remote.php/webdav/talk-droneLogs/$6.html --upload-file app/build/reports/lint/lint.html
|
|
||||||
|
|
||||||
if [ $returnValue -eq 2 ]; then
|
|
||||||
exit 0
|
|
||||||
else
|
|
||||||
exit $returnValue
|
|
||||||
fi
|
|
||||||
fi
|
|
Loading…
Reference in New Issue
Block a user