Skip to content

Commit 8b3f6bd

Browse files
committed
Add CheckerFramework to GitHub Actions CI
CheckerFramework needs an annotated JDK, so it is not activated by default
1 parent f0aff98 commit 8b3f6bd

File tree

5 files changed

+58
-0
lines changed

5 files changed

+58
-0
lines changed

.github/workflows/main.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,3 +129,20 @@ jobs:
129129
with:
130130
job-id: jdk8
131131
arguments: --scan --no-parallel --no-daemon testSlow
132+
133+
linux-checkerframework:
134+
name: 'CheckerFramework (JDK 11)'
135+
runs-on: ubuntu-latest
136+
steps:
137+
- uses: actions/checkout@v2
138+
with:
139+
fetch-depth: 50
140+
- name: 'Set up JDK 11'
141+
uses: actions/setup-java@v1
142+
with:
143+
java-version: 11
144+
- name: 'Run CheckerFramework'
145+
uses: burrunan/gradle-cache-action@v1
146+
with:
147+
job-id: checkerframework-jdk11
148+
arguments: --scan --no-parallel --no-daemon -PenableCheckerframework classes

bom/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ dependencies {
4646
// In other words, marking dependency as "runtime" would avoid accidental
4747
// dependency on it during compilation
4848
apiv("com.beust:jcommander")
49+
apiv("org.checkerframework:checker-qual", "checkerframework")
4950
apiv("com.datastax.cassandra:cassandra-driver-core")
5051
apiv("com.esri.geometry:esri-geometry-api")
5152
apiv("com.fasterxml.jackson.core:jackson-annotations", "jackson")

build.gradle.kts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ plugins {
3333
// Verification
3434
checkstyle
3535
calcite.buildext
36+
id("org.checkerframework") apply false
3637
id("com.github.autostyle")
3738
id("org.nosphere.apache.rat")
3839
id("com.github.spotbugs")
@@ -63,6 +64,7 @@ val enableSpotBugs = props.bool("spotbugs")
6364
val skipCheckstyle by props()
6465
val skipAutostyle by props()
6566
val skipJavadoc by props()
67+
val enableCheckerframework by props()
6668
val enableMavenLocal by props()
6769
val enableGradleMetadata by props()
6870
// Inherited from stage-vote-release-plugin: skipSign, useGpgCmd
@@ -506,6 +508,38 @@ allprojects {
506508
signaturesFiles = files("$rootDir/src/main/config/forbidden-apis/signatures.txt")
507509
}
508510

511+
if (enableCheckerframework) {
512+
apply(plugin = "org.checkerframework")
513+
dependencies {
514+
"checkerFramework"("org.checkerframework:checker:${"checkerframework".v}")
515+
// CheckerFramework annotations might be used in the code as follows:
516+
// dependencies {
517+
// "compileOnly"("org.checkerframework:checker-qual")
518+
// "testCompileOnly"("org.checkerframework:checker-qual")
519+
// }
520+
if (JavaVersion.current() == JavaVersion.VERSION_1_8) {
521+
// only needed for JDK 8
522+
"checkerFrameworkAnnotatedJDK"("org.checkerframework:jdk8")
523+
}
524+
}
525+
configure<org.checkerframework.gradle.plugin.CheckerFrameworkExtension> {
526+
skipVersionCheck = true
527+
// See https://checkerframework.org/manual/#introduction
528+
checkers.add("org.checkerframework.checker.nullness.NullnessChecker")
529+
// Below checkers take significant time and they do not provide much value :-/
530+
// checkers.add("org.checkerframework.checker.optional.OptionalChecker")
531+
// checkers.add("org.checkerframework.checker.regex.RegexChecker")
532+
// https://checkerframework.org/manual/#creating-debugging-options-progress
533+
// extraJavacArgs.add("-Afilenames")
534+
// https://checkerframework.org/manual/#stub-using
535+
extraJavacArgs.add("-Astubs=" +
536+
fileTree("$rootDir/src/main/config/checkerframework") {
537+
include("*.astub")
538+
}.asPath
539+
)
540+
}
541+
}
542+
509543
tasks {
510544
configureEach<Jar> {
511545
manifest {
@@ -535,6 +569,9 @@ allprojects {
535569
configureEach<JavaCompile> {
536570
options.encoding = "UTF-8"
537571
options.compilerArgs.addAll(listOf("-Xlint:deprecation", "-Werror"))
572+
if (enableCheckerframework) {
573+
options.forkOptions.memoryMaximumSize = "2g"
574+
}
538575
}
539576
configureEach<Test> {
540577
outputs.cacheIf("test results depend on the database configuration, so we souldn't cache it") {

gradle.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ calcite.avatica.version=1.17.0
4141
# publishGradleMetadata=true
4242

4343
# Plugins
44+
org.checkerframework.version=0.5.9
4445
com.github.autostyle.version=3.0
4546
com.github.johnrengelman.shadow.version=5.1.0
4647
com.github.spotbugs.version=2.0.0
@@ -71,6 +72,7 @@ bouncycastle.version=1.60
7172
cassandra-all.version=3.11.2
7273
cassandra-driver-core.version=3.6.0
7374
cassandra-unit.version=3.5.0.1
75+
checkerframework.version=3.6.0
7476
chinook-data-hsqldb.version=0.1
7577
commons-codec.version=1.12
7678
commons-dbcp2.version=2.6.0

settings.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ pluginManagement {
1919
fun String.v() = extra["$this.version"].toString()
2020
fun PluginDependenciesSpec.idv(id: String, key: String = id) = id(id) version key.v()
2121

22+
idv("org.checkerframework")
2223
idv("com.github.autostyle")
2324
idv("com.github.johnrengelman.shadow")
2425
idv("com.github.spotbugs")

0 commit comments

Comments
 (0)