Add smoke tests.

Add release smoke-tests.

Closes #30
This commit is contained in:
Mark Paluch
2023-02-20 14:27:44 +01:00
parent 651a76ac07
commit 56a77f97e4
12 changed files with 139 additions and 9 deletions

View File

@@ -148,6 +148,20 @@ public class BuildOperations {
logger.log(iteration, "Build finished");
}
/**
* Run smoke tests for a {@link TrainIteration} against a {@link StagingRepository}.
*
* @param iteration
* @param stagingRepository
*/
public void smokeTests(TrainIteration iteration, StagingRepository stagingRepository) {
doWithBuildSystem(iteration.getModule(BUILD), (buildSystem, moduleIteration) -> {
buildSystem.smokeTests(iteration, stagingRepository);
return null;
});
}
public void buildDocumentation(TrainIteration iteration) {
executor.doWithBuildSystemOrdered(Streamable.of(iteration.getModulesExcept(BOM, COMMONS, BUILD)),
@@ -184,6 +198,8 @@ public class BuildOperations {
orchestrator.close(stagingRepository);
}
smokeTests(iteration, stagingRepository);
logger.log(iteration, "Release: %s", summary);
return summary.getExecutions().stream().map(BuildExecutor.ExecutionResult::getResult).collect(Collectors.toList());

View File

@@ -22,6 +22,7 @@ import org.springframework.data.release.model.ModuleIteration;
import org.springframework.data.release.model.Phase;
import org.springframework.data.release.model.Project;
import org.springframework.data.release.model.ProjectAware;
import org.springframework.data.release.model.TrainIteration;
import org.springframework.plugin.core.Plugin;
/**
@@ -57,7 +58,6 @@ interface BuildSystem extends Plugin<Project> {
*/
<M extends ProjectAware> M triggerPreReleaseCheck(M module);
/**
* Open a remote repository for staging artifacts.
*/
@@ -89,6 +89,14 @@ interface BuildSystem extends Plugin<Project> {
*/
DeploymentInformation deploy(ModuleIteration module);
/**
* Run smoke test against a {@link StagingRepository}.
*
* @param iteration
* @param stagingRepository
*/
void smokeTests(TrainIteration iteration, StagingRepository stagingRepository);
/**
* Runs the distribution build.
*

View File

@@ -59,6 +59,7 @@ import org.springframework.data.release.model.Phase;
import org.springframework.data.release.model.Project;
import org.springframework.data.release.model.ProjectAware;
import org.springframework.data.release.model.TrainIteration;
import org.springframework.data.release.model.Version;
import org.springframework.data.release.utils.Logger;
import org.springframework.stereotype.Component;
import org.springframework.util.Assert;
@@ -355,6 +356,37 @@ class MavenBuildSystem implements BuildSystem {
mvn.execute(module.getProject(), arguments);
}
@Override
public void smokeTests(TrainIteration iteration, StagingRepository stagingRepository) {
Assert.notNull(iteration, "Train iteration must not be null!");
Assert.notNull(stagingRepository, "StagingRepository iteration must not be null!");
logger.log(iteration, "🚬 Running smoke test…");
boolean mavenCentral = iteration.getIteration().isPublic();
String profile = mavenCentral ? "maven-central" : "artifactory";
ModuleIteration module = iteration.getModule(BUILD);
doWithProjection(workspace.getFile(POM_XML, SMOKE_TESTS), pom -> {
Version version = module.getVersion();
String targetBootVersion = version.getMajor() == 2 ? "2.7.8" : "3.0.2";
pom.setParentVersion(ArtifactVersion.of(Version.parse(targetBootVersion), true));
});
CommandLine arguments = CommandLine.of(Goal.CLEAN, VERIFY, //
profile(profile), //
arg("spring-data-bom.version").withValue(iteration.getReleaseTrainNameAndVersion())) //
.andIf(mavenCentral, arg("stagingRepository").withValue(stagingRepository.getId()));
mvn.execute(SMOKE_TESTS, arguments);
logger.log(iteration, "✅ Smoke tests passed. Do not smoke 🚭. It's unhealthy.");
}
@Override
public <M extends ProjectAware> M triggerDocumentationBuild(M module) {

View File

@@ -129,7 +129,6 @@ public class MavenRuntime {
mavenLogger.info(String.format("Executing: mvn %s", arguments));
mvn.setGoals(arguments.toCommandLine(it -> properties.getFullyQualifiedPlugin(it.getGoal())));
});
if (result.getExitCode() != 0) {

View File

@@ -223,6 +223,19 @@ class ReleaseCommands extends TimedCommand {
git.checkout(iteration);
}
/**
* Triggers the smoke tests.
*
* @param iteration
* @throws Exception
*/
@CliCommand(value = "release smoke-tests")
public void runSmokeTests(@CliOption(key = "", mandatory = true) TrainIteration iteration,
@CliOption(key = "stagingRepository", mandatory = false) String stagingRepository) throws Exception {
build.smokeTests(iteration,
stagingRepository != null ? StagingRepository.of(stagingRepository) : StagingRepository.EMPTY);
}
/**
* Triggers the distribution of release artifacts for all projects.
*

View File

@@ -43,6 +43,7 @@ import javax.annotation.PostConstruct;
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.ResourcePatternResolver;
import org.springframework.data.release.model.Project;
import org.springframework.data.release.model.Projects;
import org.springframework.data.release.utils.Logger;
import org.springframework.stereotype.Component;
import org.springframework.util.Assert;
@@ -151,6 +152,11 @@ public class Workspace {
public File getProjectDirectory(Project project) {
Assert.notNull(project, "Project must not be null!");
if (project == Projects.SMOKE_TESTS) {
return new File("smoke-tests");
}
return new File(getWorkingDirectory(), project.getFolderName());
}

View File

@@ -70,7 +70,11 @@ public class ArtifactVersion implements Comparable<ArtifactVersion> {
}
public static ArtifactVersion of(Version version) {
return new ArtifactVersion(version, false, RELEASE_SUFFIX);
return of(version, false);
}
public static ArtifactVersion of(Version version, boolean useModifierFormat) {
return new ArtifactVersion(version, useModifierFormat, RELEASE_SUFFIX);
}
/**

View File

@@ -42,6 +42,7 @@ public class Projects {
public static final Project BOM, COMMONS, BUILD, REST, JDBC, RELATIONAL, JPA, MONGO_DB, NEO4J, SOLR, COUCHBASE,
CASSANDRA, ELASTICSEARCH, R2DBC, REDIS, KEY_VALUE, ENVERS, LDAP, GEODE;
public static final List<Project> PROJECTS;
public static final Project SMOKE_TESTS = new Project("SMOKE_TESTS", "Smoke Tests", Tracker.GITHUB);
static {