diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 789ec351da2..3ea3dd72392 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -28,6 +28,7 @@ updates: directory: "/" allow: - dependency-name: "com.gradle*" + - dependency-name: "com.diffplug.spotless" registries: - gradle-plugin-portal schedule: diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 62dd2acc4ef..638e731138f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -96,10 +96,18 @@ jobs: # we should not push empty results to the cache READ_ONLY_REMOTE_GRADLE_CACHE: true run: | - set -o pipefail - TASKS=$(./gradlew --no-daemon --parallel -q testMatrix | jq 'del(.[] | select(. == ":testcontainers:check" or startswith(":docs:")))' --compact-output) - echo $TASKS - echo "matrix={\"gradle_args\":$TASKS}" >> $GITHUB_OUTPUT + set -euo pipefail + MATRIX_FILE="$RUNNER_TEMP/test-matrix.json" + ./gradlew --no-daemon --parallel -q testMatrix -PtestMatrixOutput="$MATRIX_FILE" + TASKS=$(jq --compact-output --exit-status ' + if type == "array" and length > 0 and all(.[]; type == "string" and startswith(":")) + then map(select(. != ":testcontainers:check" and (startswith(":docs:") | not))) + else error("testMatrix output must be a non-empty array of Gradle task paths") + end + | if length > 0 then . else error("testMatrix produced no core Gradle tasks") end + ' "$MATRIX_FILE") + echo "$TASKS" + printf 'matrix={"gradle_args":%s}\n' "$TASKS" >> "$GITHUB_OUTPUT" check: needs: [find_gradle_jobs] strategy: @@ -131,9 +139,17 @@ jobs: # we should not push empty results to the cache READ_ONLY_REMOTE_GRADLE_CACHE: true run: | - TASKS=$(./gradlew --no-daemon --parallel -q testMatrix) - echo $TASKS - echo "matrix={\"gradle_args\":$TASKS}" >> $GITHUB_OUTPUT + set -euo pipefail + MATRIX_FILE="$RUNNER_TEMP/examples-test-matrix.json" + ./gradlew --no-daemon --parallel -q testMatrix -PtestMatrixOutput="$MATRIX_FILE" + TASKS=$(jq --compact-output --exit-status ' + if type == "array" and length > 0 and all(.[]; type == "string" and startswith(":")) + then . + else error("testMatrix output must be a non-empty array of Gradle task paths") + end + ' "$MATRIX_FILE") + echo "$TASKS" + printf 'matrix={"gradle_args":%s}\n' "$TASKS" >> "$GITHUB_OUTPUT" check_examples: needs: [find_examples_jobs] strategy: @@ -165,10 +181,18 @@ jobs: # we should not push empty results to the cache READ_ONLY_REMOTE_GRADLE_CACHE: true run: | - set -o pipefail - TASKS=$(./gradlew --no-daemon --parallel -q testMatrix | jq 'map(select(startswith(":docs:")))' --compact-output) - echo $TASKS - echo "matrix={\"gradle_args\":$TASKS}" >> $GITHUB_OUTPUT + set -euo pipefail + MATRIX_FILE="$RUNNER_TEMP/docs-test-matrix.json" + ./gradlew --no-daemon --parallel -q testMatrix -PtestMatrixOutput="$MATRIX_FILE" + TASKS=$(jq --compact-output --exit-status ' + if type == "array" and length > 0 and all(.[]; type == "string" and startswith(":")) + then map(select(startswith(":docs:"))) + else error("testMatrix output must be a non-empty array of Gradle task paths") + end + | if length > 0 then . else error("testMatrix produced no docs Gradle tasks") end + ' "$MATRIX_FILE") + echo "$TASKS" + printf 'matrix={"gradle_args":%s}\n' "$TASKS" >> "$GITHUB_OUTPUT" check_docs_examples: needs: [find_docs_examples_jobs] strategy: diff --git a/build.gradle b/build.gradle index f405ea2b92c..0c28ad10543 100644 --- a/build.gradle +++ b/build.gradle @@ -14,7 +14,7 @@ plugins { id 'io.franzbecker.gradle-lombok' version '5.0.0' id 'com.gradleup.shadow' version '8.3.9' id 'me.champeau.gradle.japicmp' version '0.4.3' apply false - id 'com.diffplug.spotless' version '6.22.0' apply false + id 'com.diffplug.spotless' version '8.10.1' apply false id 'org.jreleaser' version '1.20.0' apply false } diff --git a/examples/build.gradle b/examples/build.gradle index e80815cdae6..69684942d54 100644 --- a/examples/build.gradle +++ b/examples/build.gradle @@ -1,6 +1,6 @@ // empty build.gradle for dependabot plugins { - id 'com.diffplug.spotless' version '6.22.0' apply false + id 'com.diffplug.spotless' version '8.10.1' apply false } apply from: "$rootDir/../gradle/ci-support.gradle" diff --git a/gradle/ci-support.gradle b/gradle/ci-support.gradle index 5b85837361e..f4490f243dc 100644 --- a/gradle/ci-support.gradle +++ b/gradle/ci-support.gradle @@ -7,28 +7,20 @@ task testMatrix { it.tasks.findByName("check") }.findAll { it != null } - dependsOn(checkTasks) doLast { def checkTaskPaths = checkTasks .collect { it.path } - println(JsonOutput.toJson(checkTaskPaths)) - } - } -} + def json = JsonOutput.toJson(checkTaskPaths) + def outputPath = providers.gradleProperty("testMatrixOutput").getOrNull() -// If we're executing the `testMatrix` task, disable tests and other slow tasks -// so that we can get a result quickly. -gradle.taskGraph.whenReady { - if (it.hasTask(tasks.testMatrix)) { - for (subproject in subprojects) { - subproject.tasks.withType(Test).all { - testExecuter([execute: { spec, processor -> }, stopNow:{}] as org.gradle.api.internal.tasks.testing.TestExecuter) + if (outputPath != null) { + def outputFile = file(outputPath) + outputFile.parentFile.mkdirs() + outputFile.text = json + System.lineSeparator() + } else { + println(json) } - subproject.tasks.findByName("shadowJar")?.enabled = false - subproject.tasks.findByName("javadoc")?.enabled = false - subproject.tasks.findByName("delombok")?.enabled = false - subproject.tasks.findByName("japicmp")?.enabled = false } } } diff --git a/smoke-test/build.gradle b/smoke-test/build.gradle index 781d6e87792..ed1e73ecfb8 100644 --- a/smoke-test/build.gradle +++ b/smoke-test/build.gradle @@ -1,6 +1,6 @@ // empty build.gradle for dependabot plugins { - id 'com.diffplug.spotless' version '6.22.0' apply false + id 'com.diffplug.spotless' version '8.10.1' apply false } apply from: "$rootDir/../gradle/ci-support.gradle"