Skip to content

Commit

Permalink
Split checkStyle from precommit into spotless job (#22203)
Browse files Browse the repository at this point in the history
  • Loading branch information
Abacn authored Jul 11, 2022
1 parent 262f2b7 commit 3d8db78
Show file tree
Hide file tree
Showing 20 changed files with 50 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ PostcommitJobBuilder.postCommitJob('beam_PostCommit_Java_Examples_Dataflow_V2_ja
// overloading the machines.
commonJobProperties.setGradleSwitches(delegate, 3 * Runtime.runtime.availableProcessors())
switches '-PdisableSpotlessCheck=true'
switches '-PdisableCheckStyle=true'
switches '-PcompileAndRunTestsWithJava11'
switches '-PskipCheckerFramework'
switches "-Pjava11Home=${commonJobProperties.JAVA_11_HOME}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ PostcommitJobBuilder.postCommitJob('beam_PostCommit_Java_Examples_Dataflow_V2_ja
// overloading the machines.
commonJobProperties.setGradleSwitches(delegate, 3 * Runtime.runtime.availableProcessors())
switches '-PdisableSpotlessCheck=true'
switches '-PdisableCheckStyle=true'
switches '-PcompileAndRunTestsWithJava17'
switches '-PskipCheckerFramework'
switches "-Pjava17Home=${commonJobProperties.JAVA_17_HOME}"
Expand Down
6 changes: 2 additions & 4 deletions .test-infra/jenkins/job_PreCommit_Java.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ PrecommitJobBuilder builder = new PrecommitJobBuilder(
nameBase: 'Java',
gradleTask: ':javaPreCommit',
gradleSwitches: [
'-PdisableSpotlessCheck=true'
'-PdisableSpotlessCheck=true',
'-PdisableCheckStyle=true'
], // spotless checked in separate pre-commit
timeoutMins: 180,
triggerPathPatterns: [
Expand All @@ -45,9 +46,6 @@ builder.build {
tools {
errorProne()
java()
checkStyle {
pattern('**/build/reports/checkstyle/*.xml')
}
spotBugs {
pattern('**/build/reports/spotbugs/*.xml')
}
Expand Down
3 changes: 2 additions & 1 deletion .test-infra/jenkins/job_PreCommit_Java_AWS2_IO_Direct.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ PrecommitJobBuilder builder = new PrecommitJobBuilder(
nameBase: 'Java_Amazon-Web-Services2_IO_Direct',
gradleTask: 'sdks:java:io:amazon-web-services2:integrationTest',
gradleSwitches: [
'-PdisableSpotlessCheck=true'
'-PdisableSpotlessCheck=true',
'-PdisableCheckStyle=true'
], // spotless checked in separate pre-commit
triggerPathPatterns: [
'^sdks/java/io/amazon-web-services2/.*$',
Expand Down
3 changes: 2 additions & 1 deletion .test-infra/jenkins/job_PreCommit_Java_AWS_IO_Direct.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ PrecommitJobBuilder builder = new PrecommitJobBuilder(
nameBase: 'Java_Amazon-Web-Services_IO_Direct',
gradleTask: ':sdks:java:io:amazon-web-services:integrationTest',
gradleSwitches: [
'-PdisableSpotlessCheck=true'
'-PdisableSpotlessCheck=true',
'-PdisableCheckStyle=true'
], // spotless checked in separate pre-commit
triggerPathPatterns: [
'^sdks/java/io/amazon-web-services/.*$',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ PrecommitJobBuilder builder = new PrecommitJobBuilder(
nameBase: 'Java_Debezium_IO_Direct',
gradleTask: ':sdks:java:io:debezium:integrationTest',
gradleSwitches: [
'-PdisableSpotlessCheck=true'
'-PdisableSpotlessCheck=true',
'-PdisableCheckStyle=true'
], // spotless checked in separate pre-commit
triggerPathPatterns: [
'^sdks/java/io/debezium/.*$',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ PrecommitJobBuilder builder = new PrecommitJobBuilder(
nameBase: 'Java_Examples_Dataflow',
gradleTask: ':javaExamplesDataflowPreCommit',
gradleSwitches: [
'-PdisableSpotlessCheck=true'
'-PdisableSpotlessCheck=true',
'-PdisableCheckStyle=true'
], // spotless checked in separate pre-commit
triggerPathPatterns: [
'^model/.*$',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ PrecommitJobBuilder builder = new PrecommitJobBuilder(
gradleTask: ':clean',
gradleSwitches: [
'-PdisableSpotlessCheck=true',
'-PdisableCheckStyle=true',
'-PskipCheckerFramework' // Gradle itself is running under JDK8 so plugin configures wrong for JDK11
], // spotless checked in separate pre-commit
triggerPathPatterns: [
Expand All @@ -47,6 +48,7 @@ builder.build {
rootBuildScriptDir(properties.checkoutDir)
tasks 'javaExamplesDataflowPreCommit'
switches '-PdisableSpotlessCheck=true'
switches '-PdisableCheckStyle=true'
switches '-PskipCheckerFramework' // Gradle itself is running under JDK8 so plugin configures wrong for JDK11
switches '-PcompileAndRunTestsWithJava11'
switches "-Pjava11Home=${properties.JAVA_11_HOME}"
Expand Down
3 changes: 2 additions & 1 deletion .test-infra/jenkins/job_PreCommit_Java_GCP_IO_Direct.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ PrecommitJobBuilder builder = new PrecommitJobBuilder(
nameBase: 'Java_GCP_IO_Direct',
gradleTask: ':sdks:java:io:google-cloud-platform:postCommit',
gradleSwitches: [
'-PdisableSpotlessCheck=true'
'-PdisableSpotlessCheck=true',
'-PdisableCheckStyle=true'
], // spotless checked in separate pre-commit
timeoutMins: 120,
triggerPathPatterns: [
Expand Down
3 changes: 2 additions & 1 deletion .test-infra/jenkins/job_PreCommit_Java_JDBC_IO_Direct.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ PrecommitJobBuilder builder = new PrecommitJobBuilder(
nameBase: 'Java_JDBC_IO_Direct',
gradleTask: ':sdks:java:io:jdbc:integrationTest',
gradleSwitches: [
'-PdisableSpotlessCheck=true'
'-PdisableSpotlessCheck=true',
'-PdisableCheckStyle=true'
], // spotless checked in separate pre-commit
triggerPathPatterns: [
'^sdks/java/io/jdbc/.*$',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ PrecommitJobBuilder builder = new PrecommitJobBuilder(
nameBase: 'Java_Kafka_IO_Direct',
gradleTask: ':sdks:java:io:kafka:kafkaVersionsCompatibilityTest',
gradleSwitches: [
'-PdisableSpotlessCheck=true'
'-PdisableSpotlessCheck=true',
'-PdisableCheckStyle=true'
], // spotless checked in separate pre-commit
triggerPathPatterns: [
'^sdks/java/io/kafka/.*$',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ PrecommitJobBuilder builder = new PrecommitJobBuilder(
nameBase: 'Java_Kinesis_IO_Direct',
gradleTask: ':sdks:java:io:kinesis:integrationTest',
gradleSwitches: [
'-PdisableSpotlessCheck=true'
'-PdisableSpotlessCheck=true',
'-PdisableCheckStyle=true'
], // spotless checked in separate pre-commit
triggerPathPatterns: [
'^sdks/java/io/kinesis/.*$',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ PrecommitJobBuilder builder = new PrecommitJobBuilder(
nameBase: 'Java_Neo4j_IO_Direct',
gradleTask: ':sdks:java:io:neo4j:integrationTest',
gradleSwitches: [
'-PdisableSpotlessCheck=true'
'-PdisableSpotlessCheck=true',
'-PdisableCheckStyle=true'
], // spotless checked in separate pre-commit
triggerPathPatterns: [
'^sdks/java/io/neo4j/.*$',
Expand Down
7 changes: 2 additions & 5 deletions .test-infra/jenkins/job_PreCommit_SQL.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ PrecommitJobBuilder builder = new PrecommitJobBuilder(
nameBase: 'SQL',
gradleTask: ':sqlPreCommit',
gradleSwitches: [
'-PdisableSpotlessCheck=true'
'-PdisableSpotlessCheck=true',
'-PdisableCheckStyle=true'
], // spotless checked in job_PreCommit_Spotless
triggerPathPatterns: [
'^sdks/java/extensions/sql.*$',
Expand All @@ -35,10 +36,6 @@ builder.build {
recordIssues {
tools {
errorProne()
java()
checkStyle {
pattern('**/build/reports/checkstyle/*.xml')
}
spotBugs {
pattern('**/build/reports/spotbugs/*.xml')
}
Expand Down
4 changes: 1 addition & 3 deletions .test-infra/jenkins/job_PreCommit_SQL_Java11.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ PrecommitJobBuilder builder = new PrecommitJobBuilder(
gradleTask: ':sqlPreCommit',
gradleSwitches: [
'-PdisableSpotlessCheck=true',
'-PdisableCheckStyle=true',
'-PcompileAndRunTestsWithJava11',
'-PskipCheckerFramework',
// Gradle itself is running under JDK8 so plugin configures wrong for JDK11
Expand All @@ -41,9 +42,6 @@ builder.build {
tools {
errorProne()
java()
checkStyle {
pattern('**/build/reports/checkstyle/*.xml')
}
spotBugs {
pattern('**/build/reports/spotbugs/*.xml')
}
Expand Down
4 changes: 1 addition & 3 deletions .test-infra/jenkins/job_PreCommit_SQL_Java17.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ PrecommitJobBuilder builder = new PrecommitJobBuilder(
gradleTask: ':sqlPreCommit',
gradleSwitches: [
'-PdisableSpotlessCheck=true',
'-PdisableCheckStyle=true',
'-PcompileAndRunTestsWithJava17',
'-PskipCheckerFramework',
// Gradle itself is running under JDK8 so plugin configures wrong for JDK17
Expand All @@ -40,9 +41,6 @@ builder.build {
recordIssues {
tools {
java()
checkStyle {
pattern('**/build/reports/checkstyle/*.xml')
}
spotBugs {
pattern('**/build/reports/spotbugs/*.xml')
}
Expand Down
15 changes: 13 additions & 2 deletions .test-infra/jenkins/job_PreCommit_Spotless.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import PrecommitJobBuilder
PrecommitJobBuilder builder = new PrecommitJobBuilder(
scope: this,
nameBase: 'Spotless',
gradleTask: 'spotlessCheck',
gradleTask: 'spotlessCheck checkStyleMain checkStyleTest',
triggerPathPatterns: [
'^buildSrc/.*$',
'^sdks/java/.*$',
Expand All @@ -31,4 +31,15 @@ PrecommitJobBuilder builder = new PrecommitJobBuilder(
'^.test-infra/jenkins/.*$',
]
)
builder.build()
builder.build {
publishers {
recordIssues {
tools {
checkStyle {
pattern('**/build/reports/checkstyle/*.xml')
}
}
enabledForFailure(true)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ PrecommitJobBuilder builder = new PrecommitJobBuilder(
gradleTask: ':clean',
gradleSwitches: [
'-PdisableSpotlessCheck=true',
'-PdisableCheckStyle=true',
'-PskipCheckerFramework' // Gradle itself is running under JDK8 so plugin configures wrong for JDK17
], // spotless checked in separate pre-commit
triggerPathPatterns: [
Expand All @@ -47,6 +48,7 @@ builder.build {
rootBuildScriptDir(properties.checkoutDir)
tasks 'javaExamplesDataflowPreCommit'
switches '-PdisableSpotlessCheck=true'
switches '-PdisableCheckStyle=true'
switches '-PskipCheckerFramework' // Gradle itself is running under JDK8 so plugin configures wrong for JDK17
switches '-PcompileAndRunTestsWithJava17'
switches "-Pjava17Home=${properties.JAVA_17_HOME}"
Expand Down
2 changes: 1 addition & 1 deletion .test-infra/jenkins/job_sonarqube_report.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ job('beam_sonarqube_report') {
tasks("sonarqube")
switches("--continue")
switches("-PdisableSpotlessCheck=true")

switches("-PdisableCheckStyle=true")
// disable parallelization to avoid output collisions
switches("--no-parallel")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1079,6 +1079,12 @@ class BeamModulePlugin implements Plugin<Project> {
maxErrors = 0
}
project.checkstyle { toolVersion = "8.23" }
// CheckStyle can be removed from the 'check' task by passing -PdisableCheckStyle=true on the Gradle
// command-line. This is useful for pre-commit which runs checkStyle separately.
def disableCheckStyle = project.hasProperty('disableCheckStyle') &&
project.disableCheckStyle == 'true'
project.checkstyleMain.enabled = !disableCheckStyle
project.checkstyleTest.enabled = !disableCheckStyle

// Configures javadoc plugin and ensure check runs javadoc.
project.tasks.withType(Javadoc) {
Expand Down

0 comments on commit 3d8db78

Please sign in to comment.