diff --git a/README.adoc b/README.adoc index 476cd75c..ea57c8ef 100644 --- a/README.adoc +++ b/README.adoc @@ -63,7 +63,9 @@ After project release ** for `spring-cloud-sleuth`'s `2.1.0.RELEASE` version will resolve `2.1.x` branch - Performs the release tasks per each project - Performs the post release tasks at the end of the release -- Will update and run samples (for Spring Cloud it will be `https://github.com/spring-cloud/spring-cloud-core-tests`) +- Will update and run smoke test samples (for Spring Cloud it will be `https://github.com/spring-cloud/spring-cloud-core-tests`) +- Will clone provided test samples and will update all versions to the latest ones +- Will clone the release train wiki and update it with the latest release versions (for Spring Cloud it will be `https://github.com/spring-projects/spring-cloud.wiki.git`) IMPORTANT: For the meta-releaser to work we assume that the path to the custom configuration file for each project is always `config/releaser.yml`. @@ -288,10 +290,17 @@ The following properties are used for both meta release and a release of an indi - `releaser.git.update-documentation-repo` - If `true` then will update documentation repository with the `current` URL. Defaults to `true`. - `releaser.git.spring-project-url` - URL to the documentation Git repository. Defaults to `https://github.com/spring-projects/spring-cloud`. - `releaser.git.spring-project-branch` - Branch to check out for the documentation project. Defaults to `gh-pages`. -- `releaser.git.update-spring-project` - If `true` then will update Spring Project page with the current release train values. Defaults to `true`. +- `releaser.sagan.update-sagan` - Branch to check out for the documentation project. Defaults to `gh-pages`. +- `releaser.git.update-spring-project` - If `true` then will update Project Sagan with the current release train values. Defaults to `true`. - `releaser.git.test-samples-project-url` - URL to the test samples to be checked against the given release train. Defaults to `https://github.com/spring-cloud/spring-cloud-core-tests`. - `releaser.git.test-samples-project-branch` - Branch to check out for test samples. Defaults to `master`. +- `releaser.git.release-train-wiki-url` - URL to the project's release train wiki page. Defaults to `https://github.com/spring-projects/spring-cloud.wiki.git`. +- `releaser.git.update-release-train-wiki` - If `true` then will update the release train wiki page with the current release train values. Defaults to `true`. - `releaser.git.run-updated-samples` - If `true` then will update samples and run the the build. Defaults to `true`. +- `releaser.git.all-test-samples-urls` - URLs to the test samples to be cloned and updated with proper snapshot versions. +E.g. `"--releaser.git.all-test-samples-urls[spring-cloud-sleuth]=https://github.com/spring-cloud-samples/sleuth-issues/,https://github.com/spring-cloud-samples/sleuth-documentation-apps/"`. +Defaults to Sleuth and Contract samples. +- `releaser.git.update-all-test-samples` - If `true` then will update samples and run the the build. Defaults to `true`. - `releaser.git.release-train-docs-url` - URL to the release train documentation. Defaults to `https://github.com/spring-cloud-sample/scripts`. - `releaser.git.release-train-docs-branch` - Branch to check out for release train documentation. Defaults to `master`. - `releaser.git.update-release-train-docs` - If `true` then will update the release train documentation project and run the generation. Defaults to `true`. diff --git a/docs/src/main/asciidoc/spring-cloud-release-tools.adoc b/docs/src/main/asciidoc/spring-cloud-release-tools.adoc index 2dd805fe..11103c42 100644 --- a/docs/src/main/asciidoc/spring-cloud-release-tools.adoc +++ b/docs/src/main/asciidoc/spring-cloud-release-tools.adoc @@ -55,6 +55,7 @@ After project release - Performs the post release tasks at the end of the release - Will update and run smoke test samples (for Spring Cloud it will be `https://github.com/spring-cloud/spring-cloud-core-tests`) - Will clone provided test samples and will update all versions to the latest ones +- Will clone the release train wiki and update it with the latest release versions (for Spring Cloud it will be `https://github.com/spring-projects/spring-cloud.wiki.git`) IMPORTANT: For the meta-releaser to work we assume that the path to the custom configuration file for each project is always `config/releaser.yml`. @@ -279,9 +280,12 @@ The following properties are used for both meta release and a release of an indi - `releaser.git.update-documentation-repo` - If `true` then will update documentation repository with the `current` URL. Defaults to `true`. - `releaser.git.spring-project-url` - URL to the documentation Git repository. Defaults to `https://github.com/spring-projects/spring-cloud`. - `releaser.git.spring-project-branch` - Branch to check out for the documentation project. Defaults to `gh-pages`. -- `releaser.git.update-spring-project` - If `true` then will update Spring Project page with the current release train values. Defaults to `true`. +- `releaser.sagan.update-sagan` - Branch to check out for the documentation project. Defaults to `gh-pages`. +- `releaser.git.update-spring-project` - If `true` then will update Project Sagan with the current release train values. Defaults to `true`. - `releaser.git.test-samples-project-url` - URL to the test samples to be checked against the given release train. Defaults to `https://github.com/spring-cloud/spring-cloud-core-tests`. - `releaser.git.test-samples-project-branch` - Branch to check out for test samples. Defaults to `master`. +- `releaser.git.release-train-wiki-url` - URL to the project's release train wiki page. Defaults to `https://github.com/spring-projects/spring-cloud.wiki.git`. +- `releaser.git.update-release-train-wiki` - If `true` then will update the release train wiki page with the current release train values. Defaults to `true`. - `releaser.git.run-updated-samples` - If `true` then will update samples and run the the build. Defaults to `true`. - `releaser.git.all-test-samples-urls` - URLs to the test samples to be cloned and updated with proper snapshot versions. E.g. `"--releaser.git.all-test-samples-urls[spring-cloud-sleuth]=https://github.com/spring-cloud-samples/sleuth-issues/,https://github.com/spring-cloud-samples/sleuth-documentation-apps/"`. diff --git a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/ReleaserProperties.java b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/ReleaserProperties.java index 121920ad..f0affc4f 100644 --- a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/ReleaserProperties.java +++ b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/ReleaserProperties.java @@ -734,6 +734,12 @@ public class ReleaserProperties implements Serializable { } public static class Sagan implements Serializable { + + /** + * If set to {@code false} will not update Sagan + */ + private boolean updateSagan = true; + /** * URL to the Sagan API */ @@ -747,6 +753,14 @@ public class ReleaserProperties implements Serializable { this.baseUrl = baseUrl; } + public boolean isUpdateSagan() { + return this.updateSagan; + } + + public void setUpdateSagan(boolean updateSagan) { + this.updateSagan = updateSagan; + } + @Override public String toString() { return "Sagan{" + "baseUrl='" + this.baseUrl + '\'' + '}'; } diff --git a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/sagan/SaganUpdater.java b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/sagan/SaganUpdater.java index 1735c363..076a0592 100644 --- a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/sagan/SaganUpdater.java +++ b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/sagan/SaganUpdater.java @@ -4,6 +4,8 @@ import java.util.stream.Collectors; import org.slf4j.Logger; import org.slf4j.LoggerFactory; + +import org.springframework.cloud.release.internal.ReleaserProperties; import org.springframework.cloud.release.internal.pom.ProjectVersion; import edu.emory.mathcs.backport.java.util.Collections; @@ -16,12 +18,19 @@ public class SaganUpdater { private static final Logger log = LoggerFactory.getLogger(SaganUpdater.class); private final SaganClient saganClient; + private final ReleaserProperties releaserProperties; - public SaganUpdater(SaganClient saganClient) { + public SaganUpdater(SaganClient saganClient, ReleaserProperties releaserProperties) { this.saganClient = saganClient; + this.releaserProperties = releaserProperties; } public void updateSagan(String branch, ProjectVersion originalVersion, ProjectVersion version) { + if (!releaserProperties.getSagan().isUpdateSagan()) { + log.info("Will not update sagan, since the switch to do so " + + "is off. Set [releaser.sagan.update-sagan] to [true] to change that"); + return; + } ReleaseUpdate update = releaseUpdate(branch, originalVersion, version); updateSaganForNonSnapshot(branch, originalVersion, version); log.info("Updating Sagan with \n\n{}", update); diff --git a/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/sagan/SaganUpdaterTest.java b/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/sagan/SaganUpdaterTest.java index 6b0f1bac..bbdc8467 100644 --- a/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/sagan/SaganUpdaterTest.java +++ b/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/sagan/SaganUpdaterTest.java @@ -3,16 +3,13 @@ package org.springframework.cloud.release.internal.sagan; import java.util.Arrays; import java.util.List; -import org.hamcrest.Description; -import org.hamcrest.TypeSafeMatcher; import org.junit.Before; import org.junit.Test; -import org.junit.runner.RunWith; import org.mockito.ArgumentMatcher; import org.mockito.BDDMockito; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.Mockito; + +import org.springframework.cloud.release.internal.ReleaserProperties; import org.springframework.cloud.release.internal.pom.ProjectVersion; import static org.mockito.BDDMockito.then; @@ -22,11 +19,11 @@ import static org.mockito.Mockito.never; /** * @author Marcin Grzejszczak */ -@RunWith(MockitoJUnitRunner.class) public class SaganUpdaterTest { - @Mock SaganClient saganClient; - @InjectMocks SaganUpdater saganUpdater; + SaganClient saganClient = Mockito.mock(SaganClient.class); + ReleaserProperties properties = new ReleaserProperties(); + SaganUpdater saganUpdater = new SaganUpdater(this.saganClient, this.properties); @Before public void setup() { @@ -47,6 +44,14 @@ public class SaganUpdaterTest { return release; } + @Test public void should_not_update_sagan_when_switch_is_off() throws Exception { + this.properties.getSagan().setUpdateSagan(false); + + this.saganUpdater.updateSagan("master", version("1.0.0.M1"), version("1.0.0.M1")); + + then(this.saganClient).shouldHaveZeroInteractions(); + } + @Test public void should_update_sagan_for_milestone() throws Exception { this.saganUpdater.updateSagan("master", version("1.0.0.M1"), version("1.0.0.M1")); diff --git a/spring-cloud-release-tools-spring/src/main/java/org/springframework/cloud/release/internal/spring/ReleaserConfiguration.java b/spring-cloud-release-tools-spring/src/main/java/org/springframework/cloud/release/internal/spring/ReleaserConfiguration.java index 6d5c6c10..707f48c0 100644 --- a/spring-cloud-release-tools-spring/src/main/java/org/springframework/cloud/release/internal/spring/ReleaserConfiguration.java +++ b/spring-cloud-release-tools-spring/src/main/java/org/springframework/cloud/release/internal/spring/ReleaserConfiguration.java @@ -72,8 +72,8 @@ class ReleaserConfiguration { } @Bean - SaganUpdater saganUpdater(SaganClient saganClient) { - return new SaganUpdater(saganClient); + SaganUpdater saganUpdater(SaganClient saganClient, ReleaserProperties releaserProperties) { + return new SaganUpdater(saganClient, releaserProperties); } @Bean diff --git a/spring-cloud-release-tools-spring/src/test/java/org/springframework/cloud/release/internal/spring/AcceptanceTests.java b/spring-cloud-release-tools-spring/src/test/java/org/springframework/cloud/release/internal/spring/AcceptanceTests.java index c0798655..622cc031 100644 --- a/spring-cloud-release-tools-spring/src/test/java/org/springframework/cloud/release/internal/spring/AcceptanceTests.java +++ b/spring-cloud-release-tools-spring/src/test/java/org/springframework/cloud/release/internal/spring/AcceptanceTests.java @@ -628,7 +628,7 @@ public class AcceptanceTests { expectedVersion, projectName); TemplateGenerator templateGenerator = new TemplateGenerator(properties, handler); GradleUpdater gradleUpdater = new GradleUpdater(properties); - SaganUpdater saganUpdater = new SaganUpdater(this.saganClient); + SaganUpdater saganUpdater = new SaganUpdater(this.saganClient, releaserProperties); DocumentationUpdater documentationUpdater = new TestDocumentationUpdater(properties, new TestDocumentationUpdater.TestProjectDocumentationUpdater(properties, handler, "Brixton.SR1"), new TestDocumentationUpdater.TestReleaseContentsUpdater(properties, handler, templateGenerator)) { @@ -651,7 +651,7 @@ public class AcceptanceTests { NonAssertingTestProjectGitHandler handler = new NonAssertingTestProjectGitHandler(properties); TemplateGenerator templateGenerator = Mockito.spy(new TemplateGenerator(properties, handler)); GradleUpdater gradleUpdater = new GradleUpdater(properties); - SaganUpdater saganUpdater = Mockito.spy(new SaganUpdater(this.saganClient)); + SaganUpdater saganUpdater = Mockito.spy(new SaganUpdater(this.saganClient, releaserProperties)); DocumentationUpdater documentationUpdater = Mockito.spy(new TestDocumentationUpdater(properties, new TestDocumentationUpdater.TestProjectDocumentationUpdater(properties, handler, "Brixton.SR1"), new TestDocumentationUpdater.TestReleaseContentsUpdater(properties, handler, templateGenerator) {