Abstracted GitHub actions
- Spring Cloud guides and start.spring.io is now treated as a Spring Cloud custom action - improved start.spring.io integration fixes gh-158 fixes gh-159
This commit is contained in:
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.release.cloud.github;
|
||||
|
||||
import com.jcabi.github.Github;
|
||||
|
||||
import org.springframework.cloud.release.internal.ReleaserProperties;
|
||||
import org.springframework.cloud.release.internal.github.CustomGithubIssues;
|
||||
import org.springframework.cloud.release.internal.github.GithubIssueFiler;
|
||||
import org.springframework.cloud.release.internal.project.ProjectVersion;
|
||||
import org.springframework.cloud.release.internal.project.Projects;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
class SpringCloudGithubIssues implements CustomGithubIssues {
|
||||
|
||||
private static final String GITHUB_ISSUE_TITLE = "Upgrade to Spring Cloud %s";
|
||||
|
||||
private final GithubIssueFiler githubIssueFiler;
|
||||
|
||||
private final ReleaserProperties properties;
|
||||
|
||||
SpringCloudGithubIssues(ReleaserProperties properties) {
|
||||
this.githubIssueFiler = new GithubIssueFiler(properties);
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
SpringCloudGithubIssues(Github github, ReleaserProperties properties) {
|
||||
this.githubIssueFiler = new GithubIssueFiler(github, properties);
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isApplicable(ReleaserProperties properties, Projects projects,
|
||||
ProjectVersion version) {
|
||||
return version.projectName.startsWith("spring-cloud") || projects.stream()
|
||||
.anyMatch(project -> project.projectName.startsWith("spring-cloud"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fileIssueInSpringGuides(Projects projects, ProjectVersion version) {
|
||||
String user = "spring-guides";
|
||||
String repo = "getting-started-guides";
|
||||
this.githubIssueFiler.fileAGitHubIssue(user, repo, version, issueTitle(),
|
||||
guidesIssueText(projects));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fileIssueInStartSpringIo(Projects projects, ProjectVersion version) {
|
||||
String user = "spring-io";
|
||||
String repo = "start.spring.io";
|
||||
this.githubIssueFiler.fileAGitHubIssue(user, repo, version, issueTitle(),
|
||||
startSpringIoIssueText(projects));
|
||||
}
|
||||
|
||||
private String issueTitle() {
|
||||
return String.format(GITHUB_ISSUE_TITLE, StringUtils.capitalize(parsedVersion()));
|
||||
}
|
||||
|
||||
private String parsedVersion() {
|
||||
String version = this.properties.getPom().getBranch();
|
||||
if (version.startsWith("v")) {
|
||||
return version.substring(1);
|
||||
}
|
||||
return version;
|
||||
}
|
||||
|
||||
private String startSpringIoIssueText(Projects projects) {
|
||||
String springBootVersion = projects.containsProject("spring-boot")
|
||||
? projects.forName("spring-boot").version : "";
|
||||
return "Release train ["
|
||||
+ this.properties.getMetaRelease().getReleaseTrainProjectName()
|
||||
+ "] in version [" + parsedVersion()
|
||||
+ "] released with the Spring Boot version [`" + springBootVersion + "`]";
|
||||
}
|
||||
|
||||
private String guidesIssueText(Projects projects) {
|
||||
StringBuilder builder = new StringBuilder().append("Release train [")
|
||||
.append(this.properties.getMetaRelease().getReleaseTrainProjectName())
|
||||
.append("] in version [").append(parsedVersion())
|
||||
.append("] released with the following projects:").append("\n\n");
|
||||
projects.forEach(project -> builder.append(project.projectName).append(" : ")
|
||||
.append("`").append(project.version).append("`").append("\n"));
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.release.internal.github;
|
||||
|
||||
import org.springframework.cloud.release.internal.ReleaserProperties;
|
||||
import org.springframework.cloud.release.internal.project.ProjectVersion;
|
||||
import org.springframework.cloud.release.internal.project.Projects;
|
||||
|
||||
public interface CustomGithubIssues {
|
||||
|
||||
/**
|
||||
* Default no op implementation.
|
||||
*/
|
||||
CustomGithubIssues NO_OP = new CustomGithubIssues() {
|
||||
|
||||
@Override
|
||||
public boolean isApplicable(ReleaserProperties properties, Projects projects,
|
||||
ProjectVersion version) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fileIssueInSpringGuides(Projects projects, ProjectVersion version) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fileIssueInStartSpringIo(Projects projects, ProjectVersion version) {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
boolean isApplicable(ReleaserProperties properties, Projects projects,
|
||||
ProjectVersion version);
|
||||
|
||||
void fileIssueInSpringGuides(Projects projects, ProjectVersion version);
|
||||
|
||||
void fileIssueInStartSpringIo(Projects projects, ProjectVersion version);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.release.internal.github;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.jcabi.github.Coordinates;
|
||||
import com.jcabi.github.Github;
|
||||
import com.jcabi.github.Issue;
|
||||
import com.jcabi.github.Repo;
|
||||
import com.jcabi.github.RtGithub;
|
||||
import com.jcabi.http.wire.RetryWire;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.springframework.cloud.release.internal.ReleaserProperties;
|
||||
import org.springframework.cloud.release.internal.project.ProjectVersion;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* Infrastructure component for filing Github issues.
|
||||
*
|
||||
* @author Marcin Grzejszczak
|
||||
*/
|
||||
public class GithubIssueFiler {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(GithubIssues.class);
|
||||
|
||||
private final Github github;
|
||||
|
||||
private final ReleaserProperties properties;
|
||||
|
||||
public GithubIssueFiler(ReleaserProperties properties) {
|
||||
this(new RtGithub(new RtGithub(properties.getGit().getOauthToken()).entry()
|
||||
.through(RetryWire.class)), properties);
|
||||
}
|
||||
|
||||
public GithubIssueFiler(Github github, ReleaserProperties properties) {
|
||||
this.github = new CachingGithub(github);
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
public void fileAGitHubIssue(String user, String repo, ProjectVersion version,
|
||||
String issueTitle, String issueText) {
|
||||
Assert.hasText(this.properties.getGit().getOauthToken(),
|
||||
"You have to pass Github OAuth token for milestone closing to be operational");
|
||||
// do this only for RELEASE & SR
|
||||
if (version.isSnapshot()) {
|
||||
log.info(
|
||||
"Github issue creation will occur only for non snapshot versions. Your version is [{}]",
|
||||
parsedVersion());
|
||||
return;
|
||||
}
|
||||
fileAGithubIssue(user, repo, issueTitle, issueText);
|
||||
}
|
||||
|
||||
private void fileAGithubIssue(String user, String repo, String issueTitle,
|
||||
String issueText) {
|
||||
Repo ghRepo = this.github.repos().get(new Coordinates.Simple(user, repo));
|
||||
// check if the issue is not already there
|
||||
boolean issueAlreadyFiled = issueAlreadyFiled(ghRepo, issueTitle);
|
||||
if (issueAlreadyFiled) {
|
||||
log.info("Issue already filed, will not do that again");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
int number = ghRepo.issues().create(issueTitle, issueText).number();
|
||||
log.info(
|
||||
"Successfully created an issue with "
|
||||
+ "title [{}] for the [{}/{}] GitHub repository" + number,
|
||||
issueTitle, user, repo);
|
||||
}
|
||||
catch (IOException e) {
|
||||
log.error("Exception occurred while trying to create the issue in guides", e);
|
||||
}
|
||||
}
|
||||
|
||||
private String parsedVersion() {
|
||||
String version = this.properties.getPom().getBranch();
|
||||
if (version.startsWith("v")) {
|
||||
return version.substring(1);
|
||||
}
|
||||
return version;
|
||||
}
|
||||
|
||||
private boolean issueAlreadyFiled(Repo springGuides, String issueTitle) {
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("state", "open");
|
||||
int counter = 0;
|
||||
int maxIssues = 10;
|
||||
for (Issue issue : springGuides.issues().iterate(map)) {
|
||||
if (counter >= maxIssues) {
|
||||
return false;
|
||||
}
|
||||
Issue.Smart smartIssue = new Issue.Smart(issue);
|
||||
try {
|
||||
if (issueTitle.equals(smartIssue.title())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch (IOException e) {
|
||||
return false;
|
||||
}
|
||||
counter = counter + 1;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -16,149 +16,41 @@
|
||||
|
||||
package org.springframework.cloud.release.internal.github;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.jcabi.github.Coordinates;
|
||||
import com.jcabi.github.Github;
|
||||
import com.jcabi.github.Issue;
|
||||
import com.jcabi.github.Repo;
|
||||
import com.jcabi.github.RtGithub;
|
||||
import com.jcabi.http.wire.RetryWire;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.cloud.release.internal.ReleaserProperties;
|
||||
import org.springframework.cloud.release.internal.project.ProjectVersion;
|
||||
import org.springframework.cloud.release.internal.project.Projects;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* @author Marcin Grzejszczak
|
||||
*/
|
||||
class GithubIssues {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(GithubIssues.class);
|
||||
private final ReleaserProperties releaserProperties;
|
||||
|
||||
private static final String GITHUB_ISSUE_TITLE = "release of the [%s] release train took place";
|
||||
private final List<CustomGithubIssues> customGithubIssues;
|
||||
|
||||
private final Github github;
|
||||
|
||||
private final ReleaserProperties properties;
|
||||
|
||||
GithubIssues(ReleaserProperties properties) {
|
||||
this(new RtGithub(new RtGithub(properties.getGit().getOauthToken()).entry()
|
||||
.through(RetryWire.class)), properties);
|
||||
GithubIssues(ReleaserProperties releaserProperties,
|
||||
List<CustomGithubIssues> customGithubIssues) {
|
||||
this.releaserProperties = releaserProperties;
|
||||
this.customGithubIssues = customGithubIssues;
|
||||
}
|
||||
|
||||
GithubIssues(Github github, ReleaserProperties properties) {
|
||||
this.github = new CachingGithub(github);
|
||||
this.properties = properties;
|
||||
private CustomGithubIssues customGithubIssues(Projects projects,
|
||||
ProjectVersion version) {
|
||||
return this.customGithubIssues
|
||||
.stream().filter(githubIssues -> githubIssues
|
||||
.isApplicable(this.releaserProperties, projects, version))
|
||||
.findFirst().orElse(CustomGithubIssues.NO_OP);
|
||||
}
|
||||
|
||||
void fileIssueInSpringGuides(Projects projects, ProjectVersion version) {
|
||||
if (!this.properties.getGit().isUpdateSpringGuides()) {
|
||||
log.info("Will not file an issue to Spring Guides, since the switch to do so "
|
||||
+ "is off. Set [releaser.git.update-spring-guides] to [true] to change that");
|
||||
return;
|
||||
}
|
||||
fileAGitHubIssue("spring-guides", "getting-started-guides", projects, version);
|
||||
// iterate over projects, checkout the tag, build the guides project
|
||||
// only with -Pintegration,guides profile
|
||||
customGithubIssues(projects, version).fileIssueInSpringGuides(projects, version);
|
||||
}
|
||||
|
||||
void fileIssueInStartSpringIo(Projects projects, ProjectVersion version) {
|
||||
if (!this.properties.getGit().isUpdateStartSpringIo()) {
|
||||
log.info(
|
||||
"Will not file an issue to Start Spring Io, since the switch to do so "
|
||||
+ "is off. Set [releaser.git.update-start-spring-io] to [true] to change that");
|
||||
return;
|
||||
}
|
||||
fileAGitHubIssue("spring-io", "start.spring.io", projects, version);
|
||||
// iterate over projects, checkout the tag, build the guides project
|
||||
// only with -Pintegration,guides profile
|
||||
}
|
||||
|
||||
private void fileAGitHubIssue(String user, String repo, Projects projects,
|
||||
ProjectVersion version) {
|
||||
Assert.hasText(this.properties.getGit().getOauthToken(),
|
||||
"You have to pass Github OAuth token for milestone closing to be operational");
|
||||
// do this only for RELEASE & SR
|
||||
String releaseVersion = parsedVersion();
|
||||
if (version.isSnapshot()) {
|
||||
log.info(
|
||||
"Github issue creation will occur only for non snapshot versions. Your version is [{}]",
|
||||
releaseVersion);
|
||||
return;
|
||||
}
|
||||
fileAGithubIssue(user, repo, projects, releaseVersion);
|
||||
}
|
||||
|
||||
private void fileAGithubIssue(String user, String repo, Projects projects,
|
||||
String releaseVersion) {
|
||||
Repo ghRepo = this.github.repos().get(new Coordinates.Simple(user, repo));
|
||||
String issueTitle = "[" + StringUtils.capitalize(releaseVersion) + "] "
|
||||
+ String.format(GITHUB_ISSUE_TITLE,
|
||||
this.properties.getMetaRelease().getReleaseTrainProjectName());
|
||||
// check if the issue is not already there
|
||||
boolean issueAlreadyFiled = issueAlreadyFiled(ghRepo, issueTitle);
|
||||
if (issueAlreadyFiled) {
|
||||
log.info("Issue already filed, will not do that again");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
int number = ghRepo.issues().create(issueTitle, issueText(projects)).number();
|
||||
log.info(
|
||||
"Successfully created an issue with "
|
||||
+ "title [{}] for the [{}/{}] GitHub repository" + number,
|
||||
issueTitle, user, repo);
|
||||
}
|
||||
catch (IOException e) {
|
||||
log.error("Exception occurred while trying to create the issue in guides", e);
|
||||
}
|
||||
}
|
||||
|
||||
private String parsedVersion() {
|
||||
String version = this.properties.getPom().getBranch();
|
||||
if (version.startsWith("v")) {
|
||||
return version.substring(1);
|
||||
}
|
||||
return version;
|
||||
}
|
||||
|
||||
private String issueText(Projects projects) {
|
||||
StringBuilder builder = new StringBuilder().append("Release train [")
|
||||
.append(this.properties.getMetaRelease().getReleaseTrainProjectName())
|
||||
.append("] in version [").append(parsedVersion())
|
||||
.append("] released with the following projects:").append("\n\n");
|
||||
projects.forEach(project -> builder.append(project.projectName).append(" : ")
|
||||
.append("`").append(project.version).append("`").append("\n"));
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
private boolean issueAlreadyFiled(Repo springGuides, String issueTitle) {
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("state", "open");
|
||||
int counter = 0;
|
||||
int maxIssues = 10;
|
||||
for (Issue issue : springGuides.issues().iterate(map)) {
|
||||
if (counter >= maxIssues) {
|
||||
return false;
|
||||
}
|
||||
Issue.Smart smartIssue = new Issue.Smart(issue);
|
||||
try {
|
||||
if (issueTitle.equals(smartIssue.title())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch (IOException e) {
|
||||
return false;
|
||||
}
|
||||
counter = counter + 1;
|
||||
}
|
||||
return false;
|
||||
customGithubIssues(projects, version).fileIssueInStartSpringIo(projects, version);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package org.springframework.cloud.release.internal.github;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -40,10 +42,11 @@ public class ProjectGitHubHandler implements ReleaserPropertiesAware {
|
||||
|
||||
private ReleaserProperties properties;
|
||||
|
||||
public ProjectGitHubHandler(ReleaserProperties properties) {
|
||||
public ProjectGitHubHandler(ReleaserProperties properties,
|
||||
List<CustomGithubIssues> customGithubIssues) {
|
||||
this.properties = properties;
|
||||
this.githubMilestones = new GithubMilestones(properties);
|
||||
this.githubIssues = new GithubIssues(properties);
|
||||
this.githubIssues = new GithubIssues(properties, customGithubIssues);
|
||||
registerShutdownHook();
|
||||
}
|
||||
|
||||
|
||||
@@ -20,10 +20,10 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URISyntaxException;
|
||||
import java.nio.file.Files;
|
||||
import java.util.Collections;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import edu.emory.mathcs.backport.java.util.Collections;
|
||||
import org.assertj.core.api.BDDAssertions;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
@@ -31,6 +31,7 @@ import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
import org.mockito.BDDMockito;
|
||||
|
||||
import org.springframework.cloud.release.cloud.github.SpringCloudGithubIssuesAccessor;
|
||||
import org.springframework.cloud.release.internal.ReleaserProperties;
|
||||
import org.springframework.cloud.release.internal.buildsystem.TestUtils;
|
||||
import org.springframework.cloud.release.internal.docs.DocumentationUpdater;
|
||||
@@ -73,7 +74,9 @@ public class SpringCloudCustomProjectDocumentationUpdaterTests {
|
||||
file("/projects/spring-cloud-static/").toURI().toString());
|
||||
this.handler = new ProjectGitHandler(this.properties);
|
||||
this.clonedDocProject = this.handler.cloneDocumentationProject();
|
||||
this.gitHubHandler = new ProjectGitHubHandler(this.properties);
|
||||
this.gitHubHandler = new ProjectGitHubHandler(this.properties,
|
||||
Collections.singletonList(
|
||||
SpringCloudGithubIssuesAccessor.springCloud(this.properties)));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.release.cloud.github;
|
||||
|
||||
import com.jcabi.github.Github;
|
||||
|
||||
import org.springframework.cloud.release.internal.ReleaserProperties;
|
||||
import org.springframework.cloud.release.internal.github.CustomGithubIssues;
|
||||
|
||||
public class SpringCloudGithubIssuesAccessor {
|
||||
|
||||
public static CustomGithubIssues springCloud(Github github,
|
||||
ReleaserProperties releaserProperties) {
|
||||
return new SpringCloudGithubIssues(github, releaserProperties);
|
||||
}
|
||||
|
||||
public static CustomGithubIssues springCloud(ReleaserProperties releaserProperties) {
|
||||
return new SpringCloudGithubIssues(releaserProperties);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -20,6 +20,7 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URISyntaxException;
|
||||
import java.nio.file.Files;
|
||||
import java.util.Collections;
|
||||
|
||||
import org.assertj.core.api.BDDAssertions;
|
||||
import org.eclipse.jgit.api.errors.GitAPIException;
|
||||
@@ -28,6 +29,7 @@ import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
|
||||
import org.springframework.cloud.release.cloud.github.SpringCloudGithubIssuesAccessor;
|
||||
import org.springframework.cloud.release.internal.ReleaserProperties;
|
||||
import org.springframework.cloud.release.internal.buildsystem.TestUtils;
|
||||
import org.springframework.cloud.release.internal.git.GitTestUtils;
|
||||
@@ -48,8 +50,9 @@ public class ReleaseTrainContentsUpdaterTests {
|
||||
|
||||
ReleaserProperties properties = new ReleaserProperties();
|
||||
|
||||
ProjectGitHubHandler projectGitHubHandler = new ProjectGitHubHandler(
|
||||
this.properties) {
|
||||
ProjectGitHubHandler projectGitHubHandler = new ProjectGitHubHandler(this.properties,
|
||||
Collections.singletonList(
|
||||
SpringCloudGithubIssuesAccessor.springCloud(this.properties))) {
|
||||
@Override
|
||||
public String milestoneUrl(ProjectVersion releaseVersion) {
|
||||
return "http://www.foo.com/";
|
||||
|
||||
@@ -32,6 +32,7 @@ import org.junit.rules.TemporaryFolder;
|
||||
import org.mockito.BDDMockito;
|
||||
|
||||
import org.springframework.boot.test.rule.OutputCapture;
|
||||
import org.springframework.cloud.release.cloud.github.SpringCloudGithubIssuesAccessor;
|
||||
import org.springframework.cloud.release.internal.ReleaserProperties;
|
||||
import org.springframework.cloud.release.internal.project.ProjectVersion;
|
||||
import org.springframework.cloud.release.internal.project.Projects;
|
||||
@@ -72,7 +73,8 @@ public class GithubIssuesTests {
|
||||
@Test
|
||||
public void should_not_do_anything_for_non_release_train_version() {
|
||||
Github github = BDDMockito.mock(Github.class);
|
||||
GithubIssues issues = new GithubIssues(github, withToken());
|
||||
GithubIssues issues = new GithubIssues(withToken(), Collections.singletonList(
|
||||
SpringCloudGithubIssuesAccessor.springCloud(github, withToken())));
|
||||
|
||||
issues.fileIssueInSpringGuides(
|
||||
new Projects(new ProjectVersion("foo", "1.0.0.BUILD-SNAPSHOT")),
|
||||
@@ -86,7 +88,8 @@ public class GithubIssuesTests {
|
||||
Github github = BDDMockito.mock(Github.class);
|
||||
ReleaserProperties properties = withToken();
|
||||
properties.getGit().setUpdateSpringGuides(false);
|
||||
GithubIssues issues = new GithubIssues(github, properties);
|
||||
GithubIssues issues = new GithubIssues(properties, Collections.singletonList(
|
||||
SpringCloudGithubIssuesAccessor.springCloud(github, properties)));
|
||||
|
||||
issues.fileIssueInSpringGuides(
|
||||
new Projects(new ProjectVersion("foo", "1.0.0.RELEASE"),
|
||||
@@ -99,10 +102,11 @@ public class GithubIssuesTests {
|
||||
|
||||
@Test
|
||||
public void should_file_an_issue_for_release_version() throws IOException {
|
||||
GithubIssues issues = new GithubIssues(this.github, withToken());
|
||||
GithubIssues issues = new GithubIssues(withToken(), Collections.singletonList(
|
||||
SpringCloudGithubIssuesAccessor.springCloud(github, withToken())));
|
||||
|
||||
issues.fileIssueInSpringGuides(
|
||||
new Projects(new ProjectVersion("foo", "1.0.0.RELEASE"),
|
||||
new Projects(new ProjectVersion("spring-cloud-foo", "1.0.0.RELEASE"),
|
||||
new ProjectVersion("bar", "2.0.0.RELEASE"),
|
||||
new ProjectVersion("baz", "3.0.0.RELEASE")),
|
||||
new ProjectVersion("sc-release", "Edgware.RELEASE"));
|
||||
@@ -114,17 +118,18 @@ public class GithubIssuesTests {
|
||||
.issues().get(1);
|
||||
then(issue.exists()).isTrue();
|
||||
Issue.Smart smartIssue = new Issue.Smart(issue);
|
||||
then(smartIssue.title()).isEqualTo(
|
||||
"[Edgware.RELEASE] release of the [spring-cloud-release] release train took place");
|
||||
then(smartIssue.title()).isEqualTo("Upgrade to Spring Cloud Edgware.RELEASE");
|
||||
then(smartIssue.body()).contains(
|
||||
"Release train [spring-cloud-release] in version [Edgware.RELEASE] released with the following projects")
|
||||
.contains("foo : `1.0.0.RELEASE`").contains("bar : `2.0.0.RELEASE`")
|
||||
.contains("baz : `3.0.0.RELEASE`");
|
||||
.contains("spring-cloud-foo : `1.0.0.RELEASE`")
|
||||
.contains("bar : `2.0.0.RELEASE`").contains("baz : `3.0.0.RELEASE`");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_throw_exception_when_no_token_was_passed() {
|
||||
GithubIssues issues = new GithubIssues(new ReleaserProperties());
|
||||
GithubIssues issues = new GithubIssues(new ReleaserProperties(),
|
||||
Collections.singletonList(SpringCloudGithubIssuesAccessor
|
||||
.springCloud(new ReleaserProperties())));
|
||||
|
||||
thenThrownBy(() -> issues.fileIssueInSpringGuides(
|
||||
new Projects(Collections.emptySet()), nonGaSleuthProject()))
|
||||
@@ -138,7 +143,8 @@ public class GithubIssuesTests {
|
||||
throws IOException {
|
||||
setupStartSpringIo();
|
||||
Github github = BDDMockito.mock(Github.class);
|
||||
GithubIssues issues = new GithubIssues(github, withToken());
|
||||
GithubIssues issues = new GithubIssues(withToken(), Collections.singletonList(
|
||||
SpringCloudGithubIssuesAccessor.springCloud(github, withToken())));
|
||||
|
||||
issues.fileIssueInStartSpringIo(
|
||||
new Projects(new ProjectVersion("foo", "1.0.0.BUILD-SNAPSHOT")),
|
||||
@@ -154,7 +160,8 @@ public class GithubIssuesTests {
|
||||
Github github = BDDMockito.mock(Github.class);
|
||||
ReleaserProperties properties = withToken();
|
||||
properties.getGit().setUpdateStartSpringIo(false);
|
||||
GithubIssues issues = new GithubIssues(github, properties);
|
||||
GithubIssues issues = new GithubIssues(properties, Collections.singletonList(
|
||||
SpringCloudGithubIssuesAccessor.springCloud(github, properties)));
|
||||
|
||||
issues.fileIssueInStartSpringIo(
|
||||
new Projects(new ProjectVersion("foo", "1.0.0.RELEASE"),
|
||||
@@ -169,12 +176,14 @@ public class GithubIssuesTests {
|
||||
public void should_file_an_issue_for_release_version_when_updating_startspringio()
|
||||
throws IOException {
|
||||
setupStartSpringIo();
|
||||
GithubIssues issues = new GithubIssues(this.github, withToken());
|
||||
GithubIssues issues = new GithubIssues(withToken(), Collections.singletonList(
|
||||
SpringCloudGithubIssuesAccessor.springCloud(github, withToken())));
|
||||
|
||||
issues.fileIssueInStartSpringIo(
|
||||
new Projects(new ProjectVersion("foo", "1.0.0.RELEASE"),
|
||||
new Projects(new ProjectVersion("spring-cloud-foo", "1.0.0.RELEASE"),
|
||||
new ProjectVersion("bar", "2.0.0.RELEASE"),
|
||||
new ProjectVersion("baz", "3.0.0.RELEASE")),
|
||||
new ProjectVersion("baz", "3.0.0.RELEASE"),
|
||||
new ProjectVersion("spring-boot", "1.2.3.RELEASE")),
|
||||
new ProjectVersion("sc-release", "Edgware.RELEASE"));
|
||||
|
||||
then(this.capture.toString()).doesNotContain("will occur only");
|
||||
@@ -183,19 +192,18 @@ public class GithubIssuesTests {
|
||||
.get(1);
|
||||
then(issue.exists()).isTrue();
|
||||
Issue.Smart smartIssue = new Issue.Smart(issue);
|
||||
then(smartIssue.title()).isEqualTo(
|
||||
"[Edgware.RELEASE] release of the [spring-cloud-release] release train took place");
|
||||
then(smartIssue.title()).isEqualTo("Upgrade to Spring Cloud Edgware.RELEASE");
|
||||
then(smartIssue.body()).contains(
|
||||
"Release train [spring-cloud-release] in version [Edgware.RELEASE] released with the following projects")
|
||||
.contains("foo : `1.0.0.RELEASE`").contains("bar : `2.0.0.RELEASE`")
|
||||
.contains("baz : `3.0.0.RELEASE`");
|
||||
"Release train [spring-cloud-release] in version [Edgware.RELEASE] released with the Spring Boot version [`1.2.3.RELEASE`]");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_throw_exception_when_no_token_was_passed_when_updating_startspringio()
|
||||
throws IOException {
|
||||
setupStartSpringIo();
|
||||
GithubIssues issues = new GithubIssues(new ReleaserProperties());
|
||||
GithubIssues issues = new GithubIssues(new ReleaserProperties(),
|
||||
Collections.singletonList(SpringCloudGithubIssuesAccessor
|
||||
.springCloud(new ReleaserProperties())));
|
||||
|
||||
thenThrownBy(() -> issues.fileIssueInStartSpringIo(
|
||||
new Projects(Collections.emptySet()), nonGaSleuthProject()))
|
||||
|
||||
@@ -19,10 +19,12 @@ package org.springframework.cloud.release.internal.template;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.cloud.release.cloud.github.SpringCloudGithubIssuesAccessor;
|
||||
import org.springframework.cloud.release.internal.ReleaserProperties;
|
||||
import org.springframework.cloud.release.internal.github.ProjectGitHubHandler;
|
||||
import org.springframework.cloud.release.internal.project.ProjectVersion;
|
||||
@@ -37,7 +39,8 @@ public class TemplateGeneratorTests {
|
||||
|
||||
ReleaserProperties props = new ReleaserProperties();
|
||||
|
||||
ProjectGitHubHandler handler = new ProjectGitHubHandler(this.props) {
|
||||
ProjectGitHubHandler handler = new ProjectGitHubHandler(this.props, Collections
|
||||
.singletonList(SpringCloudGithubIssuesAccessor.springCloud(this.props))) {
|
||||
@Override
|
||||
public String milestoneUrl(ProjectVersion releaseVersion) {
|
||||
if (releaseVersion.projectName.equals("spring-cloud-foo")) {
|
||||
@@ -303,7 +306,8 @@ public class TemplateGeneratorTests {
|
||||
@Test
|
||||
public void should_generate_release_notes_template_when_url_exists()
|
||||
throws IOException {
|
||||
ProjectGitHubHandler handler = new ProjectGitHubHandler(this.props) {
|
||||
ProjectGitHubHandler handler = new ProjectGitHubHandler(this.props, Collections
|
||||
.singletonList(SpringCloudGithubIssuesAccessor.springCloud(this.props))) {
|
||||
@Override
|
||||
public String milestoneUrl(ProjectVersion releaseVersion) {
|
||||
return "https://foo.bar.com?closed=1";
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.release.cloud.github;
|
||||
|
||||
import org.springframework.cloud.release.internal.ReleaserProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
class SpringCloudGithubConfiguration {
|
||||
|
||||
@Bean
|
||||
SpringCloudGithubIssues springCloudGithubIssues(
|
||||
ReleaserProperties releaserProperties) {
|
||||
return new SpringCloudGithubIssues(releaserProperties);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -28,6 +28,7 @@ import org.springframework.cloud.release.internal.buildsystem.ProjectPomUpdater;
|
||||
import org.springframework.cloud.release.internal.docs.CustomProjectDocumentationUpdater;
|
||||
import org.springframework.cloud.release.internal.docs.DocumentationUpdater;
|
||||
import org.springframework.cloud.release.internal.git.ProjectGitHandler;
|
||||
import org.springframework.cloud.release.internal.github.CustomGithubIssues;
|
||||
import org.springframework.cloud.release.internal.github.ProjectGitHubHandler;
|
||||
import org.springframework.cloud.release.internal.options.Parser;
|
||||
import org.springframework.cloud.release.internal.postrelease.PostReleaseActions;
|
||||
@@ -75,9 +76,12 @@ class ReleaserConfiguration {
|
||||
return new ProjectGitHandler(this.properties);
|
||||
}
|
||||
|
||||
@Autowired(required = false)
|
||||
List<CustomGithubIssues> customGithubIssues = new ArrayList<>();
|
||||
|
||||
@Bean
|
||||
ProjectGitHubHandler projectGitHubHandler() {
|
||||
return new ProjectGitHubHandler(this.properties);
|
||||
return new ProjectGitHubHandler(this.properties, this.customGithubIssues);
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.release.cloud.github;
|
||||
|
||||
import com.jcabi.github.Github;
|
||||
|
||||
import org.springframework.cloud.release.internal.ReleaserProperties;
|
||||
import org.springframework.cloud.release.internal.github.CustomGithubIssues;
|
||||
|
||||
public class SpringCloudGithubIssuesAccessor {
|
||||
|
||||
public static CustomGithubIssues springCloud(Github github,
|
||||
ReleaserProperties releaserProperties) {
|
||||
return new SpringCloudGithubIssues(github, releaserProperties);
|
||||
}
|
||||
|
||||
public static CustomGithubIssues springCloud(ReleaserProperties releaserProperties) {
|
||||
return new SpringCloudGithubIssues(releaserProperties);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -46,6 +46,7 @@ import org.mockito.Mockito;
|
||||
|
||||
import org.springframework.boot.test.rule.OutputCapture;
|
||||
import org.springframework.cloud.release.cloud.docs.SpringCloudDocsAccessor;
|
||||
import org.springframework.cloud.release.cloud.github.SpringCloudGithubIssuesAccessor;
|
||||
import org.springframework.cloud.release.internal.Releaser;
|
||||
import org.springframework.cloud.release.internal.ReleaserProperties;
|
||||
import org.springframework.cloud.release.internal.buildsystem.BomParser;
|
||||
@@ -961,7 +962,8 @@ public class AcceptanceTests {
|
||||
|
||||
TestProjectGitHubHandler(ReleaserProperties properties, String expectedVersion,
|
||||
String projectName) {
|
||||
super(properties);
|
||||
super(properties, Collections.singletonList(
|
||||
SpringCloudGithubIssuesAccessor.springCloud(properties)));
|
||||
this.expectedVersion = expectedVersion;
|
||||
this.projectName = projectName;
|
||||
}
|
||||
@@ -1000,7 +1002,8 @@ public class AcceptanceTests {
|
||||
boolean issueCreatedInStartSpringIo = false;
|
||||
|
||||
NonAssertingTestProjectGitHubHandler(ReleaserProperties properties) {
|
||||
super(properties);
|
||||
super(properties, Collections.singletonList(
|
||||
SpringCloudGithubIssuesAccessor.springCloud(properties)));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user