Enable caching for system tests in CI

Setting the `systemTest` Gradle task output as never up-to-date ensures
that all system tests are executed each time they are run in CI. The
`--rerun-tasks` Gradle option that was used previously had the same
effect but also disabled build caching.

Closes gh-29029
pull/29089/head
Scott Frederick 3 years ago
parent 3b4d27e4d3
commit 9e6709eda0

@ -18,8 +18,10 @@ package org.springframework.boot.build.test;
import org.gradle.api.Plugin; import org.gradle.api.Plugin;
import org.gradle.api.Project; import org.gradle.api.Project;
import org.gradle.api.Task;
import org.gradle.api.plugins.JavaPlugin; import org.gradle.api.plugins.JavaPlugin;
import org.gradle.api.plugins.JavaPluginConvention; import org.gradle.api.plugins.JavaPluginConvention;
import org.gradle.api.specs.Spec;
import org.gradle.api.tasks.SourceSet; import org.gradle.api.tasks.SourceSet;
import org.gradle.api.tasks.SourceSetContainer; import org.gradle.api.tasks.SourceSetContainer;
import org.gradle.api.tasks.testing.Test; import org.gradle.api.tasks.testing.Test;
@ -35,6 +37,8 @@ import org.gradle.plugins.ide.eclipse.model.EclipseModel;
*/ */
public class SystemTestPlugin implements Plugin<Project> { public class SystemTestPlugin implements Plugin<Project> {
private static final Spec<Task> NEVER = (task) -> false;
/** /**
* Name of the {@code systemTest} task. * Name of the {@code systemTest} task.
*/ */
@ -78,6 +82,13 @@ public class SystemTestPlugin implements Plugin<Project> {
systemTest.setTestClassesDirs(systemTestSourceSet.getOutput().getClassesDirs()); systemTest.setTestClassesDirs(systemTestSourceSet.getOutput().getClassesDirs());
systemTest.setClasspath(systemTestSourceSet.getRuntimeClasspath()); systemTest.setClasspath(systemTestSourceSet.getRuntimeClasspath());
systemTest.shouldRunAfter(JavaPlugin.TEST_TASK_NAME); systemTest.shouldRunAfter(JavaPlugin.TEST_TASK_NAME);
if (isCi()) {
systemTest.getOutputs().upToDateWhen(NEVER);
}
}
private boolean isCi() {
return Boolean.parseBoolean(System.getenv("CI"));
} }
} }

@ -5,8 +5,8 @@ source $(dirname $0)/common.sh
pushd git-repo > /dev/null pushd git-repo > /dev/null
if [[ -d /opt/openjdk-toolchain ]]; then if [[ -d /opt/openjdk-toolchain ]]; then
./gradlew -Dorg.gradle.internal.launcher.welcomeMessageEnabled=false --no-daemon --max-workers=4 --rerun-tasks systemTest -PtoolchainVersion=${TOOLCHAIN_JAVA_VERSION} -Porg.gradle.java.installations.auto-detect=false -Porg.gradle.java.installations.auto-download=false -Porg.gradle.java.installations.paths=/opt/openjdk-toolchain/ ./gradlew -Dorg.gradle.internal.launcher.welcomeMessageEnabled=false --no-daemon --max-workers=4 systemTest -PtoolchainVersion=${TOOLCHAIN_JAVA_VERSION} -Porg.gradle.java.installations.auto-detect=false -Porg.gradle.java.installations.auto-download=false -Porg.gradle.java.installations.paths=/opt/openjdk-toolchain/
else else
./gradlew -Dorg.gradle.internal.launcher.welcomeMessageEnabled=false --no-daemon --max-workers=4 --rerun-tasks systemTest ./gradlew -Dorg.gradle.internal.launcher.welcomeMessageEnabled=false --no-daemon --max-workers=4 systemTest
fi fi
popd > /dev/null popd > /dev/null

Loading…
Cancel
Save