diff --git a/.cursor/rules/e2e_tests.mdc b/.cursor/rules/e2e_tests.mdc index da6fbf93d09..2541e169ef2 100644 --- a/.cursor/rules/e2e_tests.mdc +++ b/.cursor/rules/e2e_tests.mdc @@ -62,21 +62,21 @@ jar; each module adds only the dependencies of its Spring Boot line. `AgentApp` per test JVM in a child process, with `ChildJvmApp` and the agent jar passed through `ChildJvmTestArguments`. The suite's task runs with the agent initializing Sentry, and its second target, `integrationTestOtelAgentWithoutAutoInit`, runs the same tests with the Spring Boot starter -doing it. Gradle runs the two in parallel. `otelAgentTests()` in a `springBootMatrix` block registers +doing it. Gradle runs the two in parallel. `otelAgentTests()` in a `jvmTestSuites` block registers both on each version. ## Running them -- The `springBootMatrix` block in each Spring module's build file runs its suites on every version - of its Spring Boot line in `gradle/spring-boot-versions.json`, with a task per suite and version, - e.g. `integrationTestWebfluxBoot3_2_12`. The suites and the SDK compile once, against the - catalog's version; only the runtime classpath changes. `allIntegrationTestsBoot3_2_12` runs one - version's suites, `allIntegrationTestsBoot3` every version's. -- The `spring-boot-{2,3,4}-matrix.yml` workflows read the same file and run each version in its own - job, e.g. `./gradlew :sentry-spring-jakarta:allIntegrationTestsBoot3_2_12 - :sentry-spring-boot-jakarta:allIntegrationTestsBoot3_2_12`. The suites aren't part of `check`, so - a new suite only runs on CI once it's added to its module's `springBootMatrix` block, and a new - module once it's added to its workflow. +- The `dependencyMatrix { jvmTestSuites(...) }` block in each Spring module's build file runs its + suites on every version of its Spring Boot line in `gradle/spring-boot-{2,3,4}-versions.json`, + with a task per suite and version, e.g. `integrationTestWebfluxSpringBoot3_2_12`. The suites and + the SDK compile once, against the catalog's version; only the runtime classpath changes. + `springBootTest3_2_12` runs one version's suites, `springBootTest` every version's, one version + at a time. +- The `spring-boot-{2,3,4}-matrix.yml` workflows run every version in one job, e.g. `./gradlew + :sentry-spring-jakarta:springBootTest :sentry-spring-boot-jakarta:springBootTest --continue`. The + suites aren't part of `check`, so a new suite only runs on CI once it's added to its module's + `jvmTestSuites` block, and a new module once it's added to its workflow. - Suite code may only use APIs that exist in the oldest version of its line. Compiled against a newer one, a missing API fails at runtime with `NoSuchMethodError` or `NoClassDefFoundError`. diff --git a/.github/workflows/spring-boot-2-matrix.yml b/.github/workflows/spring-boot-2-matrix.yml index 9d7baa54425..29ab6e02af1 100644 --- a/.github/workflows/spring-boot-2-matrix.yml +++ b/.github/workflows/spring-boot-2-matrix.yml @@ -14,32 +14,10 @@ concurrency: cancel-in-progress: true jobs: - versions: - runs-on: ubuntu-latest - name: Spring Boot 2.x versions - outputs: - versions: ${{ steps.versions.outputs.versions }} - - steps: - - name: Checkout Repo - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - with: - sparse-checkout: gradle - - - name: Read Spring Boot 2.x versions - id: versions - run: echo "versions=$(jq -c .boot2 gradle/spring-boot-versions.json)" >> "$GITHUB_OUTPUT" - spring-boot-2-matrix: - needs: versions timeout-minutes: 45 runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - springboot-version: ${{ fromJSON(needs.versions.outputs.versions) }} - - name: Spring Boot ${{ matrix.springboot-version }} + name: Spring Boot 2.x steps: - name: Checkout Repo @@ -54,19 +32,16 @@ jobs: - name: Setup Gradle uses: gradle/actions/setup-gradle@8da46b539cd8fe6ab27ca75128919a18d757604c # v6.4.1 + # Runs every version in gradle/spring-boot-2-versions.json; --continue reports each failing + # one. Project paths, unlike a bare task name, keep Gradle from configuring every project. - name: Test integration suites - # Project paths, unlike a bare task name, keep Gradle from configuring every project. - run: | - task="allIntegrationTestsBoot${SPRINGBOOT_VERSION//./_}" - ./gradlew ":sentry-spring:$task" ":sentry-spring-boot:$task" - env: - SPRINGBOOT_VERSION: ${{ matrix.springboot-version }} + run: ./gradlew :sentry-spring:springBootTest :sentry-spring-boot:springBootTest --continue - name: Upload test results if: always() uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7 with: - name: test-results-springboot-2-${{ matrix.springboot-version }} + name: test-results-springboot-2 path: | **/build/reports/* **/build/test-results/**/*.xml @@ -75,7 +50,7 @@ jobs: uses: phoenix-actions/test-reporting@7317eea6e13c47348dd0bb318669485157c518d6 # pin@v16 if: always() with: - name: JUnit Spring Boot 2.x ${{ matrix.springboot-version }} + name: JUnit Spring Boot 2.x path: | **/build/test-results/**/*.xml reporter: java-junit diff --git a/.github/workflows/spring-boot-3-matrix.yml b/.github/workflows/spring-boot-3-matrix.yml index f5e762acfe6..561cadbca0f 100644 --- a/.github/workflows/spring-boot-3-matrix.yml +++ b/.github/workflows/spring-boot-3-matrix.yml @@ -14,32 +14,10 @@ concurrency: cancel-in-progress: true jobs: - versions: - runs-on: ubuntu-latest - name: Spring Boot 3.x versions - outputs: - versions: ${{ steps.versions.outputs.versions }} - - steps: - - name: Checkout Repo - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - with: - sparse-checkout: gradle - - - name: Read Spring Boot 3.x versions - id: versions - run: echo "versions=$(jq -c .boot3 gradle/spring-boot-versions.json)" >> "$GITHUB_OUTPUT" - spring-boot-3-matrix: - needs: versions timeout-minutes: 45 runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - springboot-version: ${{ fromJSON(needs.versions.outputs.versions) }} - - name: Spring Boot ${{ matrix.springboot-version }} + name: Spring Boot 3.x steps: - name: Checkout Repo @@ -54,19 +32,16 @@ jobs: - name: Setup Gradle uses: gradle/actions/setup-gradle@8da46b539cd8fe6ab27ca75128919a18d757604c # v6.4.1 + # Runs every version in gradle/spring-boot-3-versions.json; --continue reports each failing + # one. Project paths, unlike a bare task name, keep Gradle from configuring every project. - name: Test integration suites - # Project paths, unlike a bare task name, keep Gradle from configuring every project. - run: | - task="allIntegrationTestsBoot${SPRINGBOOT_VERSION//./_}" - ./gradlew ":sentry-spring-jakarta:$task" ":sentry-spring-boot-jakarta:$task" - env: - SPRINGBOOT_VERSION: ${{ matrix.springboot-version }} + run: ./gradlew :sentry-spring-jakarta:springBootTest :sentry-spring-boot-jakarta:springBootTest --continue - name: Upload test results if: always() uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7 with: - name: test-results-springboot-3-${{ matrix.springboot-version }} + name: test-results-springboot-3 path: | **/build/reports/* **/build/test-results/**/*.xml @@ -75,7 +50,7 @@ jobs: uses: phoenix-actions/test-reporting@7317eea6e13c47348dd0bb318669485157c518d6 # pin@v16 if: always() with: - name: JUnit Spring Boot 3.x ${{ matrix.springboot-version }} + name: JUnit Spring Boot 3.x path: | **/build/test-results/**/*.xml reporter: java-junit diff --git a/.github/workflows/spring-boot-4-matrix.yml b/.github/workflows/spring-boot-4-matrix.yml index 52268351aec..44cd45c15ce 100644 --- a/.github/workflows/spring-boot-4-matrix.yml +++ b/.github/workflows/spring-boot-4-matrix.yml @@ -14,32 +14,10 @@ concurrency: cancel-in-progress: true jobs: - versions: - runs-on: ubuntu-latest - name: Spring Boot 4.x versions - outputs: - versions: ${{ steps.versions.outputs.versions }} - - steps: - - name: Checkout Repo - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - with: - sparse-checkout: gradle - - - name: Read Spring Boot 4.x versions - id: versions - run: echo "versions=$(jq -c .boot4 gradle/spring-boot-versions.json)" >> "$GITHUB_OUTPUT" - spring-boot-4-matrix: - needs: versions timeout-minutes: 45 runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - springboot-version: ${{ fromJSON(needs.versions.outputs.versions) }} - - name: Spring Boot ${{ matrix.springboot-version }} + name: Spring Boot 4.x steps: - name: Checkout Repo @@ -54,19 +32,16 @@ jobs: - name: Setup Gradle uses: gradle/actions/setup-gradle@8da46b539cd8fe6ab27ca75128919a18d757604c # v6.4.1 + # Runs every version in gradle/spring-boot-4-versions.json; --continue reports each failing + # one. Project paths, unlike a bare task name, keep Gradle from configuring every project. - name: Test integration suites - # Project paths, unlike a bare task name, keep Gradle from configuring every project. - run: | - task="allIntegrationTestsBoot${SPRINGBOOT_VERSION//./_}" - ./gradlew ":sentry-spring-7:$task" ":sentry-spring-boot-4:$task" - env: - SPRINGBOOT_VERSION: ${{ matrix.springboot-version }} + run: ./gradlew :sentry-spring-7:springBootTest :sentry-spring-boot-4:springBootTest --continue - name: Upload test results if: always() uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7 with: - name: test-results-springboot-4-${{ matrix.springboot-version }} + name: test-results-springboot-4 path: | **/build/reports/* **/build/test-results/**/*.xml @@ -75,7 +50,7 @@ jobs: uses: phoenix-actions/test-reporting@7317eea6e13c47348dd0bb318669485157c518d6 # pin@v16 if: always() with: - name: JUnit Spring Boot 4.x ${{ matrix.springboot-version }} + name: JUnit Spring Boot 4.x path: | **/build/test-results/**/*.xml reporter: java-junit diff --git a/build-logic/build.gradle.kts b/build-logic/build.gradle.kts index 532537feb1a..3dcf0a8db9e 100644 --- a/build-logic/build.gradle.kts +++ b/build-logic/build.gradle.kts @@ -46,10 +46,6 @@ gradlePlugin { id = "io.sentry.robolectric" implementationClass = "io.sentry.gradle.SentryRobolectricPlugin" } - register("sentrySpringBootMatrix") { - id = "io.sentry.spring-boot-matrix" - implementationClass = "io.sentry.gradle.SpringBootMatrixPlugin" - } register("sentryDependencyMatrix") { id = "io.sentry.dependency-matrix" implementationClass = "io.sentry.gradle.DependencyMatrixPlugin" diff --git a/build-logic/src/main/kotlin/io/sentry/gradle/DependencyMatrixPlugin.kt b/build-logic/src/main/kotlin/io/sentry/gradle/DependencyMatrixPlugin.kt index 1d2a06f3d8f..fd88734494c 100644 --- a/build-logic/src/main/kotlin/io/sentry/gradle/DependencyMatrixPlugin.kt +++ b/build-logic/src/main/kotlin/io/sentry/gradle/DependencyMatrixPlugin.kt @@ -9,12 +9,14 @@ import javax.inject.Inject import org.gradle.api.Plugin import org.gradle.api.Project import org.gradle.api.artifacts.Configuration +import org.gradle.api.file.FileCollection +import org.gradle.api.tasks.SourceSetContainer import org.gradle.api.tasks.TaskProvider +import org.gradle.api.tasks.testing.Test import org.gradle.language.base.plugins.LifecycleBasePlugin /** - * Runs an Android library module's unit tests on each version of a dependency listed in a - * checked-in JSON file. + * Runs a module's tests on each version of a dependency listed in a checked-in JSON file. * * The module's main code compiles against the version catalog's version, and the tests for each * version in the file run with that version, which is how users run our published artifacts on a @@ -26,50 +28,91 @@ class DependencyMatrixPlugin : Plugin { } } +/** + * A version from a versions file, and the version each dependency group is forced to for it. + * + * An entry in the file is either a version string or an object such as `{"version": "1.8.3", + * "pin": {"androidx.compose.material3": "1.3.2"}}`. The version applies to every group of the + * matrix, and `pin` forces each of its groups to its own version, for test dependencies whose + * current version needs a newer version of the matrix's groups. + */ +internal class MatrixVersion(val version: String, val forced: Map) { + val suffix = version.replace('.', '_').replace('-', '_') +} + abstract class DependencyMatrixExtension @Inject constructor(private val project: Project) { /** - * Registers `Test` for each version in `gradle/`, a JSON list such - * as `["1.12.1", "1.13.0-rc01"]`. Each task runs the module's unit tests with every dependency in - * [groups] at that version. An entry can also be an object such as `{"version": "1.8.3", "pin": - * {"androidx.compose.material3": "1.3.2"}}`, which also forces each group in `pin` to its - * version, for test dependencies whose current version needs a newer [groups] version. - * `Test` runs every version. + * Runs an Android library module's unit tests with every dependency in [groups] at each version + * in `gradle/`, in `Test`, such as `composeUiTest1_13_0_rc01`. */ - fun matrix(name: String, groups: List, versionsFile: String) { - val file = project.layout.settingsDirectory.file("gradle/$versionsFile") - val entries = - JsonSlurper().parseText(project.providers.fileContents(file).asText.get()) as List<*> - check(entries.isNotEmpty()) { "gradle/$versionsFile lists no versions" } + fun androidUnitTests(name: String, groups: List, versionsFile: String) { + matrix(name, groups, versionsFile) { version -> + listOf(androidUnitTest("$name${version.suffix}", version.forced)) + } + } + + /** + * Runs a JVM module's test suites with every dependency in [groups] at each version in + * `gradle/`. [suites] picks the suites; each runs in ``, such + * as `integrationTestSpringBoot3_2_12`, and `Test` runs all of a version's. + */ + fun jvmTestSuites( + name: String, + groups: List, + versionsFile: String, + suites: JvmTestSuitesMatrix.() -> Unit, + ) { + matrix(name, groups, versionsFile) { version -> + JvmTestSuitesMatrix(project, name, version).apply(suites).tests + } + } + + /** + * Registers `Test` for each version in `gradle/`, running the test + * tasks that [tests] returns for it, and `Test` for every version. The versions run one at + * a time: the configuration cache would run them all at once, and their test JVMs together ran + * out of memory with 16 GB. + */ + private fun matrix( + name: String, + groups: List, + versionsFile: String, + tests: (MatrixVersion) -> List, + ) { val all = project.tasks.register("${name}Test") { - description = "Runs the unit tests with every version in gradle/$versionsFile." + description = "Runs the tests with every version in gradle/$versionsFile." group = LifecycleBasePlugin.VERIFICATION_GROUP } - var previous: String? = null - entries.forEach { entry -> - val version = if (entry is Map<*, *>) entry["version"] as String else entry as String - val pin = (entry as? Map<*, *>)?.get("pin") as Map<*, *>? - val forced = - groups.associateWith { version } + - pin.orEmpty().entries.associate { (group, pinned) -> group as String to pinned as String } - val variant = "$name${suffix(version)}" - val test = androidUnitTest(variant, forced) - // One version at a time: each starts its own Robolectric test JVM, and the configuration - // cache would run them all at once, which ran out of memory with 16 GB. - previous?.let { before -> - project.tasks.named { it == test }.configureEach { mustRunAfter(before) } - } - previous = test + var previous = emptyList() + versions(groups, versionsFile).forEach { version -> + val current = tests(version) + val before = previous + project.tasks.named { it in current }.configureEach { mustRunAfter(before) } + previous = current val versionTest = - project.tasks.register("${name}Test${suffix(version)}") { - description = "Runs the unit tests with ${groups.joinToString()} at $version." + project.tasks.register("${name}Test${version.suffix}") { + description = "Runs the tests with ${groups.joinToString()} at ${version.version}." group = LifecycleBasePlugin.VERIFICATION_GROUP - dependsOn(test) + dependsOn(current) } all.configure { dependsOn(versionTest) } } } + private fun versions(groups: List, versionsFile: String): List { + val file = project.layout.settingsDirectory.file("gradle/$versionsFile") + val entries = + JsonSlurper().parseText(project.providers.fileContents(file).asText.get()) as List<*> + check(entries.isNotEmpty()) { "gradle/$versionsFile lists no versions" } + return entries.map { entry -> + val version = if (entry is Map<*, *>) entry["version"] as String else entry as String + val pin = (entry as? Map<*, *>)?.get("pin") as Map<*, *>? + val pinned = pin.orEmpty().entries.associate { (group, v) -> group as String to v as String } + MatrixVersion(version, groups.associateWith { version } + pinned) + } + } + /** * A build type of [name] based on the test build type, whose unit tests compile and run with the * [forced] versions. Android needs a variant per version, because AGP builds the R class and @@ -109,10 +152,71 @@ abstract class DependencyMatrixExtension @Inject constructor(private val project } return unitTest } +} + +/** + * The test suites of a JVM module that run on [version]. The suites and the module compile once, + * against the catalog's version, and each suite's tests run on a runtime classpath resolved for + * [version]. + */ +class JvmTestSuitesMatrix +internal constructor( + private val project: Project, + private val name: String, + private val version: MatrixVersion, +) { + internal val tests = mutableListOf() + private val suffix = name.replaceFirstChar(Char::uppercase) + version.suffix + + /** + * Runs [suite]'s tests in ``. [testName] tells apart several tasks of + * one suite, and [configure] adds what the suite's own task has beyond its classes and classpath. + */ + fun test(suite: String, testName: String = suite, configure: Test.() -> Unit = {}) { + // Created now rather than with the task, so `dependencies --configuration` finds it. + val runtimeClasspath = runtimeClasspath(suite) + val task = "$testName$suffix" + project.tasks.register(task, Test::class.java) { + description = "Runs $testName on $name ${version.version}." + group = LifecycleBasePlugin.VERIFICATION_GROUP + testClassesDirs = sourceSet(suite).output.classesDirs + classpath = runtimeClasspath + useJUnit() + configure() + } + tests += task + } - private fun Configuration.force(versions: Map) { - resolutionStrategy.eachDependency { versions[requested.group]?.let { useVersion(it) } } + /** [sourceSet]'s output and runtime dependencies, with the matrix's groups at [version]. */ + fun runtimeClasspath(sourceSet: String): FileCollection { + val sources = sourceSet(sourceSet) + val configurationName = "$sourceSet${suffix}RuntimeClasspath" + val configurations = project.configurations + val dependencies = + configurations.findByName(configurationName) + ?: configurations + .resolvable(configurationName) { + extendsFrom( + configurations.getByName(sources.implementationConfigurationName), + configurations.getByName(sources.runtimeOnlyConfigurationName), + ) + attributes.addAllLater( + configurations.getByName(sources.runtimeClasspathConfigurationName).attributes + ) + force(version.forced) + } + .get() + return sources.output + dependencies } - private fun suffix(version: String) = version.replace('.', '_').replace('-', '_') + private fun sourceSet(name: String) = + project.extensions.getByType(SourceSetContainer::class.java).getByName(name) +} + +/** + * Has every dependency in a forced group resolve to its version, as setting the version in the + * catalog does. + */ +private fun Configuration.force(versions: Map) { + resolutionStrategy.eachDependency { versions[requested.group]?.let { useVersion(it) } } } diff --git a/build-logic/src/main/kotlin/io/sentry/gradle/OtelAgentTestsPlugin.kt b/build-logic/src/main/kotlin/io/sentry/gradle/OtelAgentTestsPlugin.kt index 0f529fe8e0e..4a0667ddfb1 100644 --- a/build-logic/src/main/kotlin/io/sentry/gradle/OtelAgentTestsPlugin.kt +++ b/build-logic/src/main/kotlin/io/sentry/gradle/OtelAgentTestsPlugin.kt @@ -77,12 +77,10 @@ class OtelAgentTestsPlugin : Plugin { } /** Registers both OpenTelemetry agent test tasks on each Spring Boot version of the matrix. */ -fun SpringBootMatrixExtension.otelAgentTests() { - test(SUITE) { version -> - runAgentFixture(autoInit = true, runtimeClasspath(AGENT_FIXTURE, version)) - } - test(SUITE, name = WITHOUT_AUTO_INIT) { version -> - runAgentFixture(autoInit = false, runtimeClasspath(AGENT_FIXTURE, version)) +fun JvmTestSuitesMatrix.otelAgentTests() { + test(SUITE) { runAgentFixture(autoInit = true, runtimeClasspath(AGENT_FIXTURE)) } + test(SUITE, testName = WITHOUT_AUTO_INIT) { + runAgentFixture(autoInit = false, runtimeClasspath(AGENT_FIXTURE)) } } diff --git a/build-logic/src/main/kotlin/io/sentry/gradle/SpringBootMatrixPlugin.kt b/build-logic/src/main/kotlin/io/sentry/gradle/SpringBootMatrixPlugin.kt deleted file mode 100644 index c75a316651e..00000000000 --- a/build-logic/src/main/kotlin/io/sentry/gradle/SpringBootMatrixPlugin.kt +++ /dev/null @@ -1,109 +0,0 @@ -package io.sentry.gradle - -import groovy.json.JsonSlurper -import javax.inject.Inject -import org.gradle.api.Plugin -import org.gradle.api.Project -import org.gradle.api.file.FileCollection -import org.gradle.api.tasks.SourceSetContainer -import org.gradle.api.tasks.testing.Test -import org.gradle.language.base.plugins.LifecycleBasePlugin - -/** - * Runs integration suites on each Spring Boot version of a line, without recompiling anything. - * - * The suites and the SDK compile once, against the version catalog's Spring Boot version. For each - * version, a suite's test task reuses its compiled classes on a runtime classpath resolved for that - * version, which is how users run our published jars on their Spring Boot version. - */ -class SpringBootMatrixPlugin : Plugin { - override fun apply(project: Project) { - project.extensions.create("springBootMatrix", SpringBootMatrixExtension::class.java) - } -} - -abstract class SpringBootMatrixExtension @Inject constructor(private val project: Project) { - private var versions = emptyList() - - /** - * Registers `allIntegrationTestsBoot` for each version of Spring Boot [line] in - * `gradle/spring-boot-versions.json`, and `allIntegrationTestsBoot` for all of them. The CI - * workflows read the same file and run each version in its own job. A WAR module uses its Boot - * module's line, because the Boot BOM decides its Spring version. - */ - fun versions(line: Int) { - val file = project.layout.settingsDirectory.file("gradle/spring-boot-versions.json") - val lines = - JsonSlurper().parseText(project.providers.fileContents(file).asText.get()) as Map<*, *> - val versions = (lines["boot$line"] as List<*>).map { it as String } - this.versions = versions - project.tasks.register("allIntegrationTestsBoot$line") { - description = "Runs the integration suites on Spring Boot ${versions.joinToString()}." - group = LifecycleBasePlugin.VERIFICATION_GROUP - dependsOn(versions.map { aggregateName(it) }) - } - versions.forEach { version -> - project.tasks.register(aggregateName(version)) { - description = "Runs the integration suites on Spring Boot $version." - group = LifecycleBasePlugin.VERIFICATION_GROUP - } - } - } - - /** - * Registers `Boot` for each version, running [suite]'s tests. [name] tells apart - * several tasks of one suite, and [configure] adds what the suite's own task has beyond its - * classes and classpath. - */ - fun test(suite: String, name: String = suite, configure: Test.(version: String) -> Unit = {}) { - check(versions.isNotEmpty()) { "Call versions() before test()" } - versions.forEach { version -> - // Created now rather than with the task, so `dependencies --configuration` finds it. - val runtimeClasspath = runtimeClasspath(suite, version) - val task = - project.tasks.register("$name${suffix(version)}", Test::class.java) { - description = "Runs $name on Spring Boot $version." - group = LifecycleBasePlugin.VERIFICATION_GROUP - testClassesDirs = sourceSet(suite).output.classesDirs - classpath = runtimeClasspath - useJUnit() - configure(version) - } - project.tasks.named(aggregateName(version)) { dependsOn(task) } - } - } - - /** [sourceSet]'s output and runtime dependencies, with Spring Boot at [version]. */ - fun runtimeClasspath(sourceSet: String, version: String): FileCollection { - val sources = sourceSet(sourceSet) - val name = "$sourceSet${suffix(version)}RuntimeClasspath" - val configurations = project.configurations - val dependencies = - configurations.findByName(name) - ?: configurations - .resolvable(name) { - extendsFrom( - configurations.getByName(sources.implementationConfigurationName), - configurations.getByName(sources.runtimeOnlyConfigurationName), - ) - attributes.addAllLater( - configurations.getByName(sources.runtimeClasspathConfigurationName).attributes - ) - // What setting the version in the catalog does: every Spring Boot artifact, the BOM - // included, is in this group. Libraries pinned to their own version still win - // conflicts. - resolutionStrategy.eachDependency { - if (requested.group == "org.springframework.boot") useVersion(version) - } - } - .get() - return sources.output + dependencies - } - - private fun sourceSet(name: String) = - project.extensions.getByType(SourceSetContainer::class.java).getByName(name) - - private fun aggregateName(version: String) = "allIntegrationTests${suffix(version)}" - - private fun suffix(version: String) = "Boot" + version.replace('.', '_') -} diff --git a/gradle/spring-boot-2-versions.json b/gradle/spring-boot-2-versions.json new file mode 100644 index 00000000000..f5f313389e4 --- /dev/null +++ b/gradle/spring-boot-2-versions.json @@ -0,0 +1 @@ +["2.7.0", "2.7.18"] diff --git a/gradle/spring-boot-3-versions.json b/gradle/spring-boot-3-versions.json new file mode 100644 index 00000000000..2d66ce6a91b --- /dev/null +++ b/gradle/spring-boot-3-versions.json @@ -0,0 +1 @@ +["3.2.12", "3.3.13", "3.4.13", "3.5.13"] diff --git a/gradle/spring-boot-4-versions.json b/gradle/spring-boot-4-versions.json new file mode 100644 index 00000000000..55560d875ff --- /dev/null +++ b/gradle/spring-boot-4-versions.json @@ -0,0 +1 @@ +["4.0.0", "4.0.5", "4.1.0"] diff --git a/gradle/spring-boot-versions.json b/gradle/spring-boot-versions.json deleted file mode 100644 index efe0fdd0624..00000000000 --- a/gradle/spring-boot-versions.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "boot2": ["2.7.0", "2.7.18"], - "boot3": ["3.2.12", "3.3.13", "3.4.13", "3.5.13"], - "boot4": ["4.0.0", "4.0.5", "4.1.0"] -} diff --git a/sentry-android-replay/build.gradle.kts b/sentry-android-replay/build.gradle.kts index ebc57705440..cd03bb41517 100644 --- a/sentry-android-replay/build.gradle.kts +++ b/sentry-android-replay/build.gradle.kts @@ -107,7 +107,7 @@ dependencies { // .github/workflows/compose-ui-matrix.yml runs each version's task. The oldest entry pins material3 // to a version that runs on that Compose UI, because the catalog's material3 needs a newer one. dependencyMatrix { - matrix( + androidUnitTests( name = "composeUi", groups = listOf( diff --git a/sentry-spring-7/build.gradle.kts b/sentry-spring-7/build.gradle.kts index 64c26019256..f230dda4138 100644 --- a/sentry-spring-7/build.gradle.kts +++ b/sentry-spring-7/build.gradle.kts @@ -5,7 +5,7 @@ import org.springframework.boot.gradle.plugin.SpringBootPlugin plugins { `java-library` id("io.sentry.javadoc") - id("io.sentry.spring-boot-matrix") + id("io.sentry.dependency-matrix") alias(libs.plugins.kotlin.jvm) alias(libs.plugins.errorprone) alias(libs.plugins.gradle.versions) @@ -149,7 +149,12 @@ testing { } // The suites on each Spring Boot 4 version the CI matrix tests. -springBootMatrix { - versions(line = 4) - test("integrationTest") +dependencyMatrix { + jvmTestSuites( + name = "springBoot", + groups = listOf("org.springframework.boot"), + versionsFile = "spring-boot-4-versions.json", + ) { + test("integrationTest") + } } diff --git a/sentry-spring-boot-4/build.gradle.kts b/sentry-spring-boot-4/build.gradle.kts index f8488605269..66e66568c23 100644 --- a/sentry-spring-boot-4/build.gradle.kts +++ b/sentry-spring-boot-4/build.gradle.kts @@ -6,7 +6,7 @@ import org.springframework.boot.gradle.plugin.SpringBootPlugin plugins { `java-library` id("io.sentry.javadoc") - id("io.sentry.spring-boot-matrix") + id("io.sentry.dependency-matrix") id("io.sentry.otel-agent-tests") alias(libs.plugins.kotlin.jvm) alias(libs.plugins.kotlin.spring) @@ -385,12 +385,17 @@ listOf( } // The suites on each Spring Boot 4 version the CI matrix tests. -springBootMatrix { - versions(line = 4) - test("integrationTest") - test("integrationTestLog4j2") - test("integrationTestWebflux") - test("integrationTestOtelNoAgent") - test("integrationTestOtlp") - otelAgentTests() +dependencyMatrix { + jvmTestSuites( + name = "springBoot", + groups = listOf("org.springframework.boot"), + versionsFile = "spring-boot-4-versions.json", + ) { + test("integrationTest") + test("integrationTestLog4j2") + test("integrationTestWebflux") + test("integrationTestOtelNoAgent") + test("integrationTestOtlp") + otelAgentTests() + } } diff --git a/sentry-spring-boot-jakarta/build.gradle.kts b/sentry-spring-boot-jakarta/build.gradle.kts index 55fd0d6af17..9d12e7cfa8c 100644 --- a/sentry-spring-boot-jakarta/build.gradle.kts +++ b/sentry-spring-boot-jakarta/build.gradle.kts @@ -6,7 +6,7 @@ import org.springframework.boot.gradle.plugin.SpringBootPlugin plugins { `java-library` id("io.sentry.javadoc") - id("io.sentry.spring-boot-matrix") + id("io.sentry.dependency-matrix") id("io.sentry.otel-agent-tests") alias(libs.plugins.kotlin.jvm) alias(libs.plugins.errorprone) @@ -324,11 +324,16 @@ listOf( } // The suites on each Spring Boot 3 version the CI matrix tests. -springBootMatrix { - versions(line = 3) - test("integrationTest") - test("integrationTestLog4j2") - test("integrationTestWebflux") - test("integrationTestOtelNoAgent") - otelAgentTests() +dependencyMatrix { + jvmTestSuites( + name = "springBoot", + groups = listOf("org.springframework.boot"), + versionsFile = "spring-boot-3-versions.json", + ) { + test("integrationTest") + test("integrationTestLog4j2") + test("integrationTestWebflux") + test("integrationTestOtelNoAgent") + otelAgentTests() + } } diff --git a/sentry-spring-boot/build.gradle.kts b/sentry-spring-boot/build.gradle.kts index 09092b9d7c1..749887c1019 100644 --- a/sentry-spring-boot/build.gradle.kts +++ b/sentry-spring-boot/build.gradle.kts @@ -6,7 +6,7 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile plugins { `java-library` id("io.sentry.javadoc") - id("io.sentry.spring-boot-matrix") + id("io.sentry.dependency-matrix") id("io.sentry.otel-agent-tests") alias(libs.plugins.kotlin.jvm) alias(libs.plugins.errorprone) @@ -270,10 +270,15 @@ listOf( } // The suites on each Spring Boot 2 version the CI matrix tests. -springBootMatrix { - versions(line = 2) - test("integrationTest") - test("integrationTestWebflux") - test("integrationTestOtelNoAgent") - otelAgentTests() +dependencyMatrix { + jvmTestSuites( + name = "springBoot", + groups = listOf("org.springframework.boot"), + versionsFile = "spring-boot-2-versions.json", + ) { + test("integrationTest") + test("integrationTestWebflux") + test("integrationTestOtelNoAgent") + otelAgentTests() + } } diff --git a/sentry-spring-jakarta/build.gradle.kts b/sentry-spring-jakarta/build.gradle.kts index 444d219f244..4aa94456de8 100644 --- a/sentry-spring-jakarta/build.gradle.kts +++ b/sentry-spring-jakarta/build.gradle.kts @@ -5,7 +5,7 @@ import org.springframework.boot.gradle.plugin.SpringBootPlugin plugins { `java-library` id("io.sentry.javadoc") - id("io.sentry.spring-boot-matrix") + id("io.sentry.dependency-matrix") alias(libs.plugins.kotlin.jvm) alias(libs.plugins.errorprone) alias(libs.plugins.gradle.versions) @@ -136,7 +136,12 @@ testing { } // The suites on each Spring Boot 3 version the CI matrix tests. -springBootMatrix { - versions(line = 3) - test("integrationTest") +dependencyMatrix { + jvmTestSuites( + name = "springBoot", + groups = listOf("org.springframework.boot"), + versionsFile = "spring-boot-3-versions.json", + ) { + test("integrationTest") + } } diff --git a/sentry-spring/build.gradle.kts b/sentry-spring/build.gradle.kts index ca68a3f00a6..1aa920156c5 100644 --- a/sentry-spring/build.gradle.kts +++ b/sentry-spring/build.gradle.kts @@ -5,7 +5,7 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile plugins { `java-library` id("io.sentry.javadoc") - id("io.sentry.spring-boot-matrix") + id("io.sentry.dependency-matrix") alias(libs.plugins.kotlin.jvm) alias(libs.plugins.errorprone) alias(libs.plugins.gradle.versions) @@ -124,7 +124,12 @@ testing { } // The suites on each Spring Boot 2 version the CI matrix tests. -springBootMatrix { - versions(line = 2) - test("integrationTest") +dependencyMatrix { + jvmTestSuites( + name = "springBoot", + groups = listOf("org.springframework.boot"), + versionsFile = "spring-boot-2-versions.json", + ) { + test("integrationTest") + } }