Skip to content

Commit

Permalink
chore(ci): show spotbugs errors on console
Browse files Browse the repository at this point in the history
- Add spotbugsReport task in gradle
- Run spotbugsReport on CI with continueOnFailure = true
in order to execute even when spotbugsMain failed.
- hide spotbugsLANG in other group

Signed-off-by: Hiroshi Miura <[email protected]>
  • Loading branch information
miurahr committed Sep 23, 2023
1 parent e44bb3d commit 7aad7e7
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 3 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/spotbugs-annotate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Run SpotBugs

on:
push:
branches:
- master
- releases/*
pull_request:

jobs:
spotbugs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '11'
- name: run spotbugs
uses: gradle/gradle-build-action@v2
with:
arguments: --continue -PenvIsCi spotbugsMain spotbugsTest
53 changes: 50 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,58 @@ allprojects {
reportLevel = 'high'
}

tasks.findAll { it.name =~ /^spotbugs.*/ }.each {
it.reports {
xml.required = envIsCi
tasks.register('spotbugsMainReport') {
doLast {
def reportFile = file("${projectDir}/build/reports/spotbugs/main.text")
if (reportFile.exists()) {
println()
reportFile.readLines().forEach {
println(it)
}
} else {
didWork = false
}
}
group = 'verification'
}

tasks.register('spotbugsTestReport') {
doLast {
def reportFile = file("${projectDir}/build/reports/spotbugs/test.text")
if (reportFile.exists()) {
println()
reportFile.readLines().forEach {
println(it)
}
} else {
didWork = false
}
}
group = 'verification'
}

spotbugsMain {
if (envIsCi) {
extraArgs = ['-longBugCodes']
jvmArgs = ['-Duser.language=en']
}
reports {
text.required = envIsCi
html.required = !envIsCi
}
finalizedBy(spotbugsMainReport)
}

spotbugsTest {
if (envIsCi) {
extraArgs = ['-longBugCodes']
jvmArgs = ['-Duser.language=en']
}
reports {
text.required = envIsCi
html.required = !envIsCi
}
finalizedBy(spotbugsTestReport)
}

checkstyle {
Expand Down
4 changes: 4 additions & 0 deletions languagetools/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,8 @@ plugins.forEach { args ->
group = 'languagetool'
}
jar.dependsOn "${name}Jar"
def capitalName = name.capitalize()
tasks.getByName("spotbugs${capitalName}") {
group = 'other'
}
}

0 comments on commit 7aad7e7

Please sign in to comment.