Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions .github/workflows/sanity-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Sanity Check 🕊
on:
push:
branches:
- main
- 'releases/**'
paths:
- '.github/**'
pull_request:
paths:
- '.github/**'
permissions: {}
jobs:
validate:
name: Validate 📊
runs-on: ubuntu-latest
permissions:
security-events: write
steps:
- name: Checkout Repository 📥
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
with:
persist-credentials: false
- name: Checkstyle ☑️
uses: ./.github/actions/run-gradle
with:
encryptionKey: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
arguments: checkstyleMain
- name: Spotless ✨
uses: ./.github/actions/run-gradle
with:
encryptionKey: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
arguments: spotlessCheck
- name: ArchUnit 🏛️
uses: ./.github/actions/run-gradle
with:
encryptionKey: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
arguments: archUnit
- name: OSGi 🧩
uses: ./.github/actions/run-gradle
with:
encryptionKey: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
arguments: verifyOSGiTask
- name: Rewrite ⚙️
uses: ./.github/actions/run-gradle
with:
encryptionKey: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
arguments: rewriteDryRun # -Dorg.gradle.jvmargs=-Xmx2G
9 changes: 9 additions & 0 deletions gradle/config/rewrite.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
type: specs.openrewrite.org/v1beta/recipe
name: org.junit.openrewrite.SanityCheck
displayName: Apply all common best practices
description: Comprehensive code quality recipe combining modernization, security, and best practices.
recipeList:
- org.openrewrite.java.testing.junit5.CleanupAssertions
# - org.openrewrite.java.testing.junit.JupiterBestPractices
---
1 change: 1 addition & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ commonCustomUserData = { id = "com.gradle.common-custom-user-data-gradle-plugin"
develocity = { id = "com.gradle.develocity", version = "4.2.2" }
download = { id = "de.undercouch.download", version = "5.6.0" }
errorProne = { id = "net.ltgt.errorprone", version = "4.3.0" }
rewrite = { id = "org.openrewrite.rewrite", version = "7.22.0" }
foojayResolver = { id = "org.gradle.toolchains.foojay-resolver", version = "1.0.0" }
jmh = { id = "me.champeau.jmh", version = "0.7.3" }
jreleaser = { id = "org.jreleaser", version = "1.21.0" }
Expand Down
5 changes: 3 additions & 2 deletions gradle/plugins/common/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,17 @@ plugins {

dependencies {
implementation("junitbuild.base:dsl-extensions")
implementation(projects.buildParameters)
implementation(projects.backwardCompatibility)
implementation(libs.plugins.kotlin.markerCoordinates)
implementation(projects.buildParameters)
implementation(libs.plugins.bnd.markerCoordinates)
implementation(libs.plugins.commonCustomUserData.markerCoordinates)
implementation(libs.plugins.develocity.markerCoordinates)
implementation(libs.plugins.errorProne.markerCoordinates)
implementation(libs.plugins.foojayResolver.markerCoordinates)
implementation(libs.plugins.jmh.markerCoordinates)
implementation(libs.plugins.kotlin.markerCoordinates)
implementation(libs.plugins.nullaway.markerCoordinates)
implementation(libs.plugins.rewrite.markerCoordinates)
implementation(libs.plugins.shadow.markerCoordinates)
implementation(libs.plugins.spotless.markerCoordinates)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,3 @@ checkstyle {
toolVersion = requiredVersionFromLibs("checkstyle")
configDirectory = rootProject.layout.projectDirectory.dir("gradle/config/checkstyle")
}

tasks.check {
dependsOn(tasks.withType<Checkstyle>())
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ plugins {
id("junitbuild.eclipse-conventions")
id("junitbuild.jacoco-java-conventions")
id("junitbuild.java-errorprone-conventions")
id("junitbuild.rewrite-conventions")
}

val mavenizedProjects: List<Project> by rootProject.extra
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,21 @@ val osgiVerificationClasspath = configurations.resolvable("osgiVerificationClass
extendsFrom(osgiVerification.get())
}

// Make the task available for calling from outside
tasks.register("verifyOSGiTask") {
description = "Verifies OSGi metadata in the built jar"
group = "verification"
dependsOn(verify)
}

// Bnd's Resolve task is what verifies that a jar can be used in OSGi and
// that its metadata is valid. If the metadata is invalid this task will
// fail.
val verifyOSGi by tasks.registering(Resolve::class) {
val verify by tasks.registering(Resolve::class) {
bndrun = osgiProperties.flatMap { it.destinationFile }
outputBndrun = layout.buildDirectory.file("resolvedOSGiProperties.bndrun")
isReportOptional = false
// By default bnd will use jars found in:
// By default, bnd will use jars found in:
// 1. project.sourceSets.main.runtimeClasspath
// 2. project.configurations.archives.artifacts.files
// to validate the metadata.
Expand All @@ -116,7 +123,3 @@ val verifyOSGi by tasks.registering(Resolve::class) {
bundles(osgiVerificationClasspath)
properties.empty()
}

tasks.check {
dependsOn(verifyOSGi)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
plugins {
id("org.openrewrite.rewrite")
}

dependencies {
rewrite("org.openrewrite.recipe:rewrite-testing-frameworks:3.23.0")
}

rewrite {
activeRecipe("org.junit.openrewrite.SanityCheck")
configFile = project.getRootProject().file("gradle/config/rewrite.yml")
exclusion(
// "**AssertionsTests.java", // https://github.com/openrewrite/rewrite-static-analysis/issues/799
// legacy
"**TestCase.java",
"**TestCases.java",
"**documentation/src/test/java/example**",
"**testFixtures/java/org/junit/vintage/engine/samples**",
)
setExportDatatables(true)
setFailOnDryRunResults(true)
}
Original file line number Diff line number Diff line change
Expand Up @@ -116,21 +116,21 @@ void beforeAndAfterMethodsInTestClassHierarchy() {
// @formatter:on

// @formatter:off
assertEquals(asList(
"beforeAll1",
assertEquals(callSequence, asList(
"beforeAll1",
"beforeAll2",
"beforeAll3",
"beforeEach1",
"beforeEach2",
"beforeEach3",
"test3",
"afterEach3",
"afterEach2",
"afterEach1",
"afterAll3",
"beforeAll3",
"beforeEach1",
"beforeEach2",
"beforeEach3",
"test3",
"afterEach3",
"afterEach2",
"afterEach1",
"afterAll3",
"afterAll2",
"afterAll1"
), callSequence, "wrong call sequence");
"afterAll1"
), "wrong call sequence");
// @formatter:on
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ private void performAssertions(Class<?> testClass, Map<String, String> configPar
executionResults.testEvents().assertStatistics(//
stats -> stats.started(numTests).finished(numTests));

assertEquals(Arrays.asList(methods), methodsInvoked);
assertEquals(methodsInvoked, Arrays.asList(methods));
}

// -------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ private void assertBeforeAllAndAfterAllCallbacks(Class<?> testClass, int testsSt
executeTestsForClass(testClass).testEvents()//
.assertStatistics(stats -> stats.started(testsStarted).succeeded(testsSuccessful));

assertEquals(asList(expectedCalls), callSequence, () -> "wrong call sequence for " + testClass.getName());
assertEquals(callSequence, asList(expectedCalls), () -> "wrong call sequence for " + testClass.getName());
}

// -------------------------------------------------------------------------
Expand Down
Loading
Loading