Generate Release Train Docs; fixes gh-91

This commit is contained in:
Marcin Grzejszczak
2018-10-25 17:45:37 +02:00
parent a39c179b34
commit 0ff2b4a2b8
11 changed files with 220 additions and 27 deletions

View File

@@ -232,4 +232,13 @@ public class Releaser {
log.warn("\nUnable to update and run samples", e);
}
}
public void generateReleaseTrainDocumentation(Projects projects) {
try {
this.postReleaseActions.generateReleaseTrainDocumentation(projects);
log.info("\nSuccessfully updated and generated release train documentation");
} catch (Exception e) {
log.warn("\nUnable to update and generate release train documentation", e);
}
}
}

View File

@@ -156,6 +156,11 @@ public class ReleaserProperties implements Serializable {
*/
private String testSamplesProjectUrl = "https://github.com/spring-cloud/spring-cloud-core-tests";
/**
* URL to the release train documentation
*/
private String releaseTrainDocsUrl = "https://github.com/spring-cloud-samples/scripts";
/**
* Branch to check out for the documentation project
*/
@@ -172,9 +177,9 @@ public class ReleaserProperties implements Serializable {
private String testSamplesBranch = "master";
/**
* If {@code false}, will not update the documentation repository.
* Branch to check out for the release train docs
*/
private boolean updateDocumentationRepo = true;
private String releaseTrainDocsBranch = "master";
/**
* Where should the Spring Cloud Release repo get cloned to. If {@code null} defaults to a temporary directory
@@ -207,6 +212,11 @@ public class ReleaserProperties implements Serializable {
*/
private Integer numberOfCheckedMilestones = 10;
/**
* If {@code false}, will not update the documentation repository.
*/
private boolean updateDocumentationRepo = true;
/**
* If set to {@code false}, will not update Spring Guides for a release train.
*/
@@ -223,6 +233,11 @@ public class ReleaserProperties implements Serializable {
*/
private boolean runUpdatedSamples = true;
/**
* If set to {@code false}, will not update the release train docs
*/
private boolean updateReleaseTrainDocs = true;
public String getReleaseTrainBomUrl() {
return this.releaseTrainBomUrl;
}
@@ -359,6 +374,30 @@ public class ReleaserProperties implements Serializable {
this.updateSpringProject = updateSpringProject;
}
public String getReleaseTrainDocsUrl() {
return releaseTrainDocsUrl;
}
public void setReleaseTrainDocsUrl(String releaseTrainDocsUrl) {
this.releaseTrainDocsUrl = releaseTrainDocsUrl;
}
public String getReleaseTrainDocsBranch() {
return releaseTrainDocsBranch;
}
public void setReleaseTrainDocsBranch(String releaseTrainDocsBranch) {
this.releaseTrainDocsBranch = releaseTrainDocsBranch;
}
public boolean isUpdateReleaseTrainDocs() {
return updateReleaseTrainDocs;
}
public void setUpdateReleaseTrainDocs(boolean updateReleaseTrainDocs) {
this.updateReleaseTrainDocs = updateReleaseTrainDocs;
}
@Override
public String toString() {
return "Git{" +
@@ -486,6 +525,11 @@ public class ReleaserProperties implements Serializable {
"./target/gh-pages.sh -v {{version}} -c"
};
/**
* Command to be executed to generate release train documentation
*/
private String generateReleaseTrainDocsCommand = "./release_train.sh --retrieveversions --version {{version}} --ghpages --auto";
public static final String SYSTEM_PROPS_PLACEHOLDER = "{{systemProps}}";
/**
@@ -527,6 +571,14 @@ public class ReleaserProperties implements Serializable {
return this.publishDocsCommands;
}
public String getGenerateReleaseTrainDocsCommand() {
return this.generateReleaseTrainDocsCommand;
}
public void setGenerateReleaseTrainDocsCommand(String generateReleaseTrainDocsCommand) {
this.generateReleaseTrainDocsCommand = generateReleaseTrainDocsCommand;
}
public void setPublishDocsCommands(String[] publishDocsCommands) {
this.publishDocsCommands = publishDocsCommands;
}
@@ -542,8 +594,9 @@ public class ReleaserProperties implements Serializable {
@Override public String toString() {
return "Maven{" + "buildCommand='" + this.buildCommand + '\'' + ", deployCommand='"
+ this.deployCommand + '\'' + ", publishDocsCommands=" + Arrays
.toString(this.publishDocsCommands) + ", waitTimeInMinutes="
+ this.waitTimeInMinutes + '}';
.toString(this.publishDocsCommands) +
"generateReleaseTrainDocsCommand='" + this.generateReleaseTrainDocsCommand + '\'' +
", waitTimeInMinutes=" + this.waitTimeInMinutes + '}';
}
}

View File

@@ -76,6 +76,11 @@ public class ProjectGitHandler implements ReleaserPropertiesAware {
return cloneProject(this.properties.getGit().getReleaseTrainBomUrl());
}
public File cloneReleaseTrainDocumentationProject() {
return cloneAndCheckOut(this.properties.getGit().getReleaseTrainDocsUrl(),
this.properties.getGit().getReleaseTrainDocsBranch());
}
public File cloneDocumentationProject() {
return cloneAndCheckOut(this.properties.getGit()
.getDocumentationUrl(), this.properties.getGit()

View File

@@ -36,7 +36,7 @@ public class PostReleaseActions {
/**
* Clones the test project, updates it and runs tests
*
* @param projects - set of project with versions to assert agains
* @param projects - set of project with versions to assert against
*/
public void runUpdatedTests(Projects projects) {
if (!this.properties.getGit().isRunUpdatedSamples() ||
@@ -47,16 +47,40 @@ public class PostReleaseActions {
}
File file = this.projectGitHandler.cloneTestSamplesProject();
ProjectVersion projectVersion = new ProjectVersion(file);
Projects newProjects = addVersionForTestsProject(projects, projectVersion);
String releaseTrainVersion =
projects.forName(this.properties.getMetaRelease().getReleaseTrainProjectName()).version;
Projects newProjects = addVersionForTestsProject(projects, projectVersion, releaseTrainVersion);
this.projectPomUpdater
.updateProjectFromReleaseTrain(file, newProjects, projectVersion, false);
this.projectBuilder.build(projectVersion, file.getAbsolutePath());
}
private Projects addVersionForTestsProject(Projects projects, ProjectVersion projectVersion) {
/**
* Clones the release train documentation project
*
* @param projects - set of project with versions to assert against
*/
public void generateReleaseTrainDocumentation(Projects projects) {
if (!this.properties.getGit().isUpdateReleaseTrainDocs() ||
!this.properties.getMetaRelease().isEnabled()) {
log.info("Will not update the release train documentation, since the switch to do so "
+ "is off. Set [releaser.git.update-release-train-docs] to [true] to change that");
return;
}
File file = this.projectGitHandler.cloneReleaseTrainDocumentationProject();
ProjectVersion projectVersion = new ProjectVersion(file);
String releaseTrainVersion =
projects.forName(this.properties.getMetaRelease().getReleaseTrainProjectName()).version;
Projects newProjects = addVersionForTestsProject(projects, projectVersion, releaseTrainVersion);
this.projectPomUpdater
.updateProjectFromReleaseTrain(file, newProjects, projectVersion, false);
this.projectBuilder.generateReleaseTrainDocs(releaseTrainVersion, file.getAbsolutePath());
}
private Projects addVersionForTestsProject(Projects projects, ProjectVersion projectVersion,
String releaseTrainVersion) {
Projects newProjects = new Projects(projects);
newProjects.add(new ProjectVersion(projectVersion.projectName,
projects.forName(this.properties.getMetaRelease().getReleaseTrainProjectName()).version));
newProjects.add(new ProjectVersion(projectVersion.projectName, releaseTrainVersion));
return newProjects;
}
}

View File

@@ -53,6 +53,18 @@ public class ProjectBuilder implements ReleaserPropertiesAware {
}
}
public void generateReleaseTrainDocs(String version, String projectRoot) {
try {
String updatedCommand =
this.properties.getMaven().getGenerateReleaseTrainDocsCommand().replace(VERSION_MUSTACHE, version);
runCommand(projectRoot, updatedCommand.split(" "));
assertNoHtmlFilesInDocsContainUnresolvedTags(this.properties.getWorkingDir());
log.info("No HTML files from docs contain unresolved tags");
} catch (Exception e) {
throw new IllegalStateException(e);
}
}
private String commandWithSystemProps(String command,
ProjectVersion version) {
if (command.contains(ReleaserProperties.Maven.SYSTEM_PROPS_PLACEHOLDER)) {
@@ -184,13 +196,13 @@ class ProcessExecutor implements ReleaserPropertiesAware {
void runCommand(String[] commands, long waitTimeInMinutes) {
try {
String workingDir = this.workingDir;
log.debug("Will run the build from [{}] via {} and wait for result for [{}] minutes",
log.debug("Will run the command from [{}] via {} and wait for result for [{}] minutes",
workingDir, commands, waitTimeInMinutes);
ProcessBuilder builder = builder(commands, workingDir);
Process process = startProcess(builder);
boolean finished = process.waitFor(waitTimeInMinutes, TimeUnit.MINUTES);
if (!finished) {
log.error("The build hasn't managed to finish in [{}] minutes", waitTimeInMinutes);
log.error("The command hasn't managed to finish in [{}] minutes", waitTimeInMinutes);
process.destroyForcibly();
throw new IllegalStateException("Process waiting time of [" + waitTimeInMinutes + "] minutes exceeded");
}