Updates for new sagain api, s-c-build 3.1 and boot 2.6 (#243)
Updates releaser to use spring cloud build 3.1.0 Transitively uses boot 2.6 Updates releaser to use new Sagan API Fixes gh-196 Fixes gh-194
This commit is contained in:
@@ -27,8 +27,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
@SpringBootApplication
|
||||
public class ReleaserApplication extends ReleaserCommandLineRunner {
|
||||
|
||||
public ReleaserApplication(SpringReleaser releaser,
|
||||
ExecutionResultHandler executionResultHandler, Parser parser) {
|
||||
public ReleaserApplication(SpringReleaser releaser, ExecutionResultHandler executionResultHandler, Parser parser) {
|
||||
super(releaser, executionResultHandler, parser);
|
||||
}
|
||||
|
||||
|
||||
@@ -48,39 +48,31 @@ class CfConfiguration {
|
||||
@Bean
|
||||
PasswordGrantTokenProvider tokenProvider(@Value("${cf.username}") String username,
|
||||
@Value("${cf.password}") String password) {
|
||||
return PasswordGrantTokenProvider.builder().password(password).username(username)
|
||||
return PasswordGrantTokenProvider.builder().password(password).username(username).build();
|
||||
}
|
||||
|
||||
@Bean
|
||||
ReactorCloudFoundryClient cloudFoundryClient(ConnectionContext connectionContext, TokenProvider tokenProvider) {
|
||||
return ReactorCloudFoundryClient.builder().connectionContext(connectionContext).tokenProvider(tokenProvider)
|
||||
.build();
|
||||
}
|
||||
|
||||
@Bean
|
||||
ReactorCloudFoundryClient cloudFoundryClient(ConnectionContext connectionContext,
|
||||
TokenProvider tokenProvider) {
|
||||
return ReactorCloudFoundryClient.builder().connectionContext(connectionContext)
|
||||
.tokenProvider(tokenProvider).build();
|
||||
ReactorDopplerClient dopplerClient(ConnectionContext connectionContext, TokenProvider tokenProvider) {
|
||||
return ReactorDopplerClient.builder().connectionContext(connectionContext).tokenProvider(tokenProvider).build();
|
||||
}
|
||||
|
||||
@Bean
|
||||
ReactorDopplerClient dopplerClient(ConnectionContext connectionContext,
|
||||
TokenProvider tokenProvider) {
|
||||
return ReactorDopplerClient.builder().connectionContext(connectionContext)
|
||||
.tokenProvider(tokenProvider).build();
|
||||
ReactorUaaClient uaaClient(ConnectionContext connectionContext, TokenProvider tokenProvider) {
|
||||
return ReactorUaaClient.builder().connectionContext(connectionContext).tokenProvider(tokenProvider).build();
|
||||
}
|
||||
|
||||
@Bean
|
||||
ReactorUaaClient uaaClient(ConnectionContext connectionContext,
|
||||
TokenProvider tokenProvider) {
|
||||
return ReactorUaaClient.builder().connectionContext(connectionContext)
|
||||
.tokenProvider(tokenProvider).build();
|
||||
}
|
||||
|
||||
@Bean
|
||||
DefaultCloudFoundryOperations defaultCloudFoundryOperations(
|
||||
CloudFoundryClient cloudFoundryClient, DopplerClient dopplerClient,
|
||||
UaaClient uaaClient, @Value("${cf.organization}") String organizationId,
|
||||
DefaultCloudFoundryOperations defaultCloudFoundryOperations(CloudFoundryClient cloudFoundryClient,
|
||||
DopplerClient dopplerClient, UaaClient uaaClient, @Value("${cf.organization}") String organizationId,
|
||||
@Value("${cf.space}") String spaceId) {
|
||||
return DefaultCloudFoundryOperations.builder()
|
||||
.cloudFoundryClient(cloudFoundryClient).dopplerClient(dopplerClient)
|
||||
.uaaClient(uaaClient).organization(organizationId).space(spaceId).build();
|
||||
return DefaultCloudFoundryOperations.builder().cloudFoundryClient(cloudFoundryClient)
|
||||
.dopplerClient(dopplerClient).uaaClient(uaaClient).organization(organizationId).space(spaceId).build();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -61,11 +61,9 @@ import releaser.internal.tech.ExecutionResult;
|
||||
/**
|
||||
* @author Simon Baslé
|
||||
*/
|
||||
public class GenerateReleaseNotesTask
|
||||
implements ProjectPostReleaseReleaserTask, DryRunReleaseReleaserTask {
|
||||
public class GenerateReleaseNotesTask implements ProjectPostReleaseReleaserTask, DryRunReleaseReleaserTask {
|
||||
|
||||
private static final Logger log = LoggerFactory
|
||||
.getLogger(GenerateReleaseNotesTask.class);
|
||||
private static final Logger log = LoggerFactory.getLogger(GenerateReleaseNotesTask.class);
|
||||
|
||||
private static final String NAME = "releaseNotes";
|
||||
|
||||
@@ -106,20 +104,18 @@ public class GenerateReleaseNotesTask
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExecutionResult runTask(Arguments args)
|
||||
throws BuildUnstableException, RuntimeException {
|
||||
public ExecutionResult runTask(Arguments args) throws BuildUnstableException, RuntimeException {
|
||||
if (args.versionFromBom.isSnapshot()) {
|
||||
log.info("\nWon't generate notes for a snapshot version");
|
||||
return ExecutionResult.success();
|
||||
}
|
||||
|
||||
Repo repo = github.repos().get(new Coordinates.Simple(
|
||||
args.properties.getGit().getOrgName(), args.projectToRun.name()));
|
||||
Repo repo = github.repos()
|
||||
.get(new Coordinates.Simple(args.properties.getGit().getOrgName(), args.projectToRun.name()));
|
||||
|
||||
String releaseTag = "v" + args.versionFromBom.version;
|
||||
if (args.options.dryRun != Boolean.TRUE) {
|
||||
Optional<String> maybeTagSha1 = gitHandler.findTagSha1(args.project,
|
||||
releaseTag);
|
||||
Optional<String> maybeTagSha1 = gitHandler.findTagSha1(args.project, releaseTag);
|
||||
if (maybeTagSha1.isPresent()) {
|
||||
String tagSha1 = maybeTagSha1.get();
|
||||
try {
|
||||
@@ -127,16 +123,13 @@ public class GenerateReleaseNotesTask
|
||||
repo.git().references().get("tags/" + tagSha1).json();
|
||||
}
|
||||
catch (IOException e) {
|
||||
return ExecutionResult.failure(new IllegalStateException(
|
||||
"Shouldn't create a release if tag " + releaseTag + " (sha1="
|
||||
+ tagSha1 + ") not visible in Github",
|
||||
e));
|
||||
return ExecutionResult.failure(new IllegalStateException("Shouldn't create a release if tag "
|
||||
+ releaseTag + " (sha1=" + tagSha1 + ") not visible in Github", e));
|
||||
}
|
||||
}
|
||||
else {
|
||||
return ExecutionResult.failure(new IllegalStateException(
|
||||
"Attempting to draft release note but tag not found in repository: "
|
||||
+ releaseTag));
|
||||
"Attempting to draft release note but tag not found in repository: " + releaseTag));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,34 +137,26 @@ public class GenerateReleaseNotesTask
|
||||
EnumMap<Type, List<ChangelogEntry>> entries = new EnumMap<>(Type.class);
|
||||
|
||||
String toVersionTag = "v" + args.versionFromBom.version;
|
||||
if (args.options.dryRun == Boolean.TRUE
|
||||
&& !gitHandler.findTagSha1(args.project, toVersionTag).isPresent()) {
|
||||
if (args.options.dryRun == Boolean.TRUE && !gitHandler.findTagSha1(args.project, toVersionTag).isPresent()) {
|
||||
toVersionTag = "HEAD";
|
||||
}
|
||||
|
||||
// eg. 3.2.1 for current 3.2.2
|
||||
String fromVersionTag = args.versionFromBom
|
||||
.computePreviousPatchTag("v", "RELEASE").orElseGet(() -> {
|
||||
Pattern pattern = args.versionFromBom
|
||||
.computePreviousMinorTagPattern("v", "RELEASE")
|
||||
.orElseGet(() -> args.versionFromBom
|
||||
.computePreviousMajorTagPattern("v", "RELEASE"));
|
||||
// eg. v3.2.*.RELEASE or v3.*.*.RELEASE
|
||||
log.info(
|
||||
"Couldn't simply compute previous version of {}, looking through tag list with pattern {}",
|
||||
args.versionFromBom.version, pattern.pattern());
|
||||
String fromVersionTag = args.versionFromBom.computePreviousPatchTag("v", "RELEASE").orElseGet(() -> {
|
||||
Pattern pattern = args.versionFromBom.computePreviousMinorTagPattern("v", "RELEASE")
|
||||
.orElseGet(() -> args.versionFromBom.computePreviousMajorTagPattern("v", "RELEASE"));
|
||||
// eg. v3.2.*.RELEASE or v3.*.*.RELEASE
|
||||
log.info("Couldn't simply compute previous version of {}, looking through tag list with pattern {}",
|
||||
args.versionFromBom.version, pattern.pattern());
|
||||
|
||||
List<String> sortedTags = gitHandler
|
||||
.findTagNamesMatching(args.project, pattern)
|
||||
.collect(Collectors.toList());
|
||||
if (sortedTags.isEmpty()) {
|
||||
throw new IllegalStateException(
|
||||
"Couldn't find a tag that matches pattern "
|
||||
+ pattern.pattern());
|
||||
}
|
||||
sortedTags.forEach(System.out::println);
|
||||
return sortedTags.get(0);
|
||||
});
|
||||
List<String> sortedTags = gitHandler.findTagNamesMatching(args.project, pattern)
|
||||
.collect(Collectors.toList());
|
||||
if (sortedTags.isEmpty()) {
|
||||
throw new IllegalStateException("Couldn't find a tag that matches pattern " + pattern.pattern());
|
||||
}
|
||||
sortedTags.forEach(System.out::println);
|
||||
return sortedTags.get(0);
|
||||
});
|
||||
|
||||
if (Boolean.TRUE == args.options.interactive) {
|
||||
log.info("\nComputed log range is {}..{}", fromVersionTag, toVersionTag);
|
||||
@@ -189,8 +174,7 @@ public class GenerateReleaseNotesTask
|
||||
log.info("Will fetch the log for range {}..{}", fromVersionTag, toVersionTag);
|
||||
|
||||
// gather commits. we use tags in the format `vVERSION`
|
||||
final List<SimpleCommit> revCommits = gitHandler.commitsBetween(args.project,
|
||||
fromVersionTag, toVersionTag);
|
||||
final List<SimpleCommit> revCommits = gitHandler.commitsBetween(args.project, fromVersionTag, toVersionTag);
|
||||
|
||||
// parse and link to issues if possible, determining type
|
||||
for (SimpleCommit revCommit : revCommits) {
|
||||
@@ -202,8 +186,7 @@ public class GenerateReleaseNotesTask
|
||||
}
|
||||
|
||||
// generate the notes
|
||||
String notes = generateNotes(args, entries,
|
||||
extractContributorMentions(repo, revCommits));
|
||||
String notes = generateNotes(args, entries, extractContributorMentions(repo, revCommits));
|
||||
|
||||
if (args.options.dryRun != null && args.options.dryRun) {
|
||||
// print out
|
||||
@@ -220,8 +203,7 @@ public class GenerateReleaseNotesTask
|
||||
JsonObject draftReleaseJson = null;
|
||||
try {
|
||||
// attempt to find gh release with this tag. stop at 2 month old releases
|
||||
Instant oldestReleaseToConsider = ZonedDateTime.now().minusMonths(2)
|
||||
.toInstant();
|
||||
Instant oldestReleaseToConsider = ZonedDateTime.now().minusMonths(2).toInstant();
|
||||
for (Release release : repo.releases().iterate()) {
|
||||
JsonObject releaseJson = release.json();
|
||||
// seems the created release has a wrong tag "untagged-xxxxx", we also
|
||||
@@ -229,8 +211,8 @@ public class GenerateReleaseNotesTask
|
||||
if (releaseJson.getString("tag_name").equals(releaseTag)
|
||||
|| releaseJson.getString("name").equals(releaseTag)) {
|
||||
if (!releaseJson.getBoolean("draft")) {
|
||||
return ExecutionResult.failure(new IllegalStateException(
|
||||
"Release already exists for tag " + releaseTag));
|
||||
return ExecutionResult
|
||||
.failure(new IllegalStateException("Release already exists for tag " + releaseTag));
|
||||
}
|
||||
else {
|
||||
draftRelease = new Release.Smart(release);
|
||||
@@ -252,16 +234,14 @@ public class GenerateReleaseNotesTask
|
||||
}
|
||||
}
|
||||
catch (Throwable e) {
|
||||
return ExecutionResult.failure(new IllegalStateException(
|
||||
"Unable to try to match github releases with tag " + releaseTag,
|
||||
e));
|
||||
return ExecutionResult.failure(
|
||||
new IllegalStateException("Unable to try to match github releases with tag " + releaseTag, e));
|
||||
}
|
||||
|
||||
if (draftReleaseJson == null) {
|
||||
// create a draft release for the tag
|
||||
try {
|
||||
Release.Smart release = new Release.Smart(
|
||||
repo.releases().create(releaseTag));
|
||||
Release.Smart release = new Release.Smart(repo.releases().create(releaseTag));
|
||||
release.draft(true);
|
||||
release.tag(releaseTag);
|
||||
release.name(releaseTag);
|
||||
@@ -279,8 +259,7 @@ public class GenerateReleaseNotesTask
|
||||
// update the existing draft
|
||||
try {
|
||||
// edit the release
|
||||
String oldAndNewNotes = draftReleaseJson.getString("body")
|
||||
+ "\n\n----\nNew draft added "
|
||||
String oldAndNewNotes = draftReleaseJson.getString("body") + "\n\n----\nNew draft added "
|
||||
+ LocalDateTime.now().toString() + "\n----\n" + notes;
|
||||
draftRelease.body(oldAndNewNotes);
|
||||
return ExecutionResult.success();
|
||||
@@ -295,18 +274,15 @@ public class GenerateReleaseNotesTask
|
||||
/**
|
||||
* Generate the release notes.
|
||||
*/
|
||||
protected String generateNotes(Arguments args,
|
||||
EnumMap<Type, List<ChangelogEntry>> entries,
|
||||
protected String generateNotes(Arguments args, EnumMap<Type, List<ChangelogEntry>> entries,
|
||||
List<String> contributorGithubMentions) {
|
||||
// TODO use a template? handlebars !
|
||||
StringBuilder notes = new StringBuilder().append(args.projectToRun.name())
|
||||
.append(" `").append(args.versionFromBom.version)
|
||||
.append("` is part of **`").append(args.releaseTrain().version)
|
||||
StringBuilder notes = new StringBuilder().append(args.projectToRun.name()).append(" `")
|
||||
.append(args.versionFromBom.version).append("` is part of **`").append(args.releaseTrain().version)
|
||||
.append("` Release Train**.");
|
||||
|
||||
notes.append("\n\n## :warning: Update considerations and deprecations");
|
||||
for (ChangelogEntry noteworthy : entries.getOrDefault(Type.NOTEWORTHY,
|
||||
Collections.emptyList())) {
|
||||
for (ChangelogEntry noteworthy : entries.getOrDefault(Type.NOTEWORTHY, Collections.emptyList())) {
|
||||
notes.append("\n - ").append(noteworthy.description);
|
||||
for (String issueTitle : noteworthy.associatedIssueLinksAndTitles.values()) {
|
||||
notes.append("\n\t - ").append(cleanupShortMessage(issueTitle));
|
||||
@@ -314,8 +290,7 @@ public class GenerateReleaseNotesTask
|
||||
}
|
||||
|
||||
notes.append("\n\n## :sparkles: New features and improvements");
|
||||
for (ChangelogEntry feature : entries.getOrDefault(Type.FEATURE,
|
||||
Collections.emptyList())) {
|
||||
for (ChangelogEntry feature : entries.getOrDefault(Type.FEATURE, Collections.emptyList())) {
|
||||
notes.append("\n - ").append(feature.description);
|
||||
for (String issueTitle : feature.associatedIssueLinksAndTitles.values()) {
|
||||
notes.append("\n\t - ").append(cleanupShortMessage(issueTitle));
|
||||
@@ -323,8 +298,7 @@ public class GenerateReleaseNotesTask
|
||||
}
|
||||
|
||||
notes.append("\n\n## :beetle: Bug fixes");
|
||||
for (ChangelogEntry bug : entries.getOrDefault(Type.BUG,
|
||||
Collections.emptyList())) {
|
||||
for (ChangelogEntry bug : entries.getOrDefault(Type.BUG, Collections.emptyList())) {
|
||||
notes.append("\n - ").append(bug.description);
|
||||
for (String issueTitle : bug.associatedIssueLinksAndTitles.values()) {
|
||||
notes.append("\n\t - ").append(cleanupShortMessage(issueTitle));
|
||||
@@ -332,8 +306,7 @@ public class GenerateReleaseNotesTask
|
||||
}
|
||||
|
||||
notes.append("\n\n## :book: Documentation, Tests and Build");
|
||||
for (ChangelogEntry misc : entries.getOrDefault(Type.DOC_MISC,
|
||||
Collections.emptyList())) {
|
||||
for (ChangelogEntry misc : entries.getOrDefault(Type.DOC_MISC, Collections.emptyList())) {
|
||||
notes.append("\n - ").append(misc.description);
|
||||
for (String issueTitle : misc.associatedIssueLinksAndTitles.values()) {
|
||||
notes.append("\n\t - ").append(cleanupShortMessage(issueTitle));
|
||||
@@ -341,18 +314,15 @@ public class GenerateReleaseNotesTask
|
||||
}
|
||||
|
||||
notes.append("\n\n## **TODO DISPATCH THESE**");
|
||||
for (ChangelogEntry unclassified : entries.getOrDefault(Type.UNCLASSIFIED,
|
||||
Collections.emptyList())) {
|
||||
for (ChangelogEntry unclassified : entries.getOrDefault(Type.UNCLASSIFIED, Collections.emptyList())) {
|
||||
notes.append("\n - ").append(unclassified.description);
|
||||
for (String issueTitle : unclassified.associatedIssueLinksAndTitles
|
||||
.values()) {
|
||||
for (String issueTitle : unclassified.associatedIssueLinksAndTitles.values()) {
|
||||
notes.append("\n\t - ").append(cleanupShortMessage(issueTitle));
|
||||
}
|
||||
}
|
||||
|
||||
// contributors
|
||||
notes.append(
|
||||
"\n\n## :+1: Thanks to the following contributors that also participated to this release\n");
|
||||
notes.append("\n\n## :+1: Thanks to the following contributors that also participated to this release\n");
|
||||
notes.append(String.join(", ", contributorGithubMentions));
|
||||
|
||||
return notes.toString();
|
||||
@@ -400,8 +370,7 @@ public class GenerateReleaseNotesTask
|
||||
return EnumSet.copyOf(types);
|
||||
}
|
||||
|
||||
protected String commitToGithubMention(RepoCommits commitsClient,
|
||||
SimpleCommit revCommit) {
|
||||
protected String commitToGithubMention(RepoCommits commitsClient, SimpleCommit revCommit) {
|
||||
RepoCommit dumbCommit = commitsClient.get(revCommit.fullSha1);
|
||||
RepoCommit.Smart smartCommit = new RepoCommit.Smart(dumbCommit);
|
||||
try {
|
||||
@@ -412,17 +381,14 @@ public class GenerateReleaseNotesTask
|
||||
}
|
||||
else if (authorType == JsonValue.ValueType.NULL) {
|
||||
// assume author+committer, look under commit.author.name
|
||||
if (commitJson.containsKey("commit")
|
||||
&& commitJson.getJsonObject("commit").containsKey("author")) {
|
||||
return "@" + commitJson.getJsonObject("commit")
|
||||
.getJsonObject("author").getString("name");
|
||||
if (commitJson.containsKey("commit") && commitJson.getJsonObject("commit").containsKey("author")) {
|
||||
return "@" + commitJson.getJsonObject("commit").getJsonObject("author").getString("name");
|
||||
}
|
||||
}
|
||||
// in case unexpected json, output the "sha", "commit", "author" and
|
||||
// "committer"
|
||||
return "@RAW{\"sha\", " + commitJson.get("sha") + ", \"author\", \""
|
||||
+ commitJson.get("author") + ", \"committer\", \""
|
||||
+ commitJson.get("committer") + ", \"commit\", \""
|
||||
return "@RAW{\"sha\", " + commitJson.get("sha") + ", \"author\", \"" + commitJson.get("author")
|
||||
+ ", \"committer\", \"" + commitJson.get("committer") + ", \"commit\", \""
|
||||
+ commitJson.get("commit") + "}";
|
||||
}
|
||||
catch (IOException e) {
|
||||
@@ -437,9 +403,8 @@ public class GenerateReleaseNotesTask
|
||||
*/
|
||||
List<String> extractContributorMentions(Repo repo, List<SimpleCommit> revCommits) {
|
||||
RepoCommits commitsClient = repo.commits();
|
||||
return revCommits.stream().map(c -> commitToGithubMention(commitsClient, c))
|
||||
.filter(Objects::nonNull).distinct().sorted(String.CASE_INSENSITIVE_ORDER)
|
||||
.collect(Collectors.toList());
|
||||
return revCommits.stream().map(c -> commitToGithubMention(commitsClient, c)).filter(Objects::nonNull).distinct()
|
||||
.sorted(String.CASE_INSENSITIVE_ORDER).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -487,8 +452,7 @@ public class GenerateReleaseNotesTask
|
||||
* The labels and titles are injected in a {@link Set} of labels and {@link Map} of
|
||||
* hashtag issue links to issue titles.
|
||||
*/
|
||||
protected void fetchIssueLabelsAndTitles(Issues issueClient,
|
||||
Set<Integer> issueNumbers, Set<String> labelsTarget,
|
||||
protected void fetchIssueLabelsAndTitles(Issues issueClient, Set<Integer> issueNumbers, Set<String> labelsTarget,
|
||||
Map<String, String> referencedIssuesTarget) {
|
||||
issueNumbers.forEach(i -> {
|
||||
try {
|
||||
@@ -496,10 +460,9 @@ public class GenerateReleaseNotesTask
|
||||
// we have everything handy in the JSON
|
||||
Issue issue = issueClient.get(i);
|
||||
JsonObject issueJson = issue.json();
|
||||
issueJson.getJsonArray("labels").forEach(label -> labelsTarget
|
||||
.add(((JsonObject) label).getString("name")));
|
||||
referencedIssuesTarget.put("#" + issueJson.getInt("number"),
|
||||
issueJson.getString("title"));
|
||||
issueJson.getJsonArray("labels")
|
||||
.forEach(label -> labelsTarget.add(((JsonObject) label).getString("name")));
|
||||
referencedIssuesTarget.put("#" + issueJson.getInt("number"), issueJson.getString("title"));
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.warn("Could not fetch issue information for #" + i, e);
|
||||
@@ -510,20 +473,17 @@ public class GenerateReleaseNotesTask
|
||||
/**
|
||||
* Extract issue information from the commit and generate the {@link ChangelogEntry}.
|
||||
*/
|
||||
protected ChangelogEntry parseChangeLogEntry(Issues issueClient,
|
||||
SimpleCommit commit) {
|
||||
protected ChangelogEntry parseChangeLogEntry(Issues issueClient, SimpleCommit commit) {
|
||||
String cleanShortMessage = cleanupShortMessage(commit);
|
||||
Set<Integer> issueNumbers = extractIssueNumbers(commit);
|
||||
|
||||
Set<String> labelsTarget = new HashSet<>();
|
||||
Map<String, String> referencedIssuesTarget = new LinkedHashMap<>();
|
||||
fetchIssueLabelsAndTitles(issueClient, issueNumbers, labelsTarget,
|
||||
referencedIssuesTarget);
|
||||
fetchIssueLabelsAndTitles(issueClient, issueNumbers, labelsTarget, referencedIssuesTarget);
|
||||
|
||||
EnumSet<Type> types = extractTypes(labelsTarget, commit.title);
|
||||
|
||||
return new ChangelogEntry(types, commit.abbreviatedSha1, cleanShortMessage,
|
||||
referencedIssuesTarget);
|
||||
return new ChangelogEntry(types, commit.abbreviatedSha1, cleanShortMessage, referencedIssuesTarget);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -534,8 +494,7 @@ public class GenerateReleaseNotesTask
|
||||
* reflecting the PR number in case there has been extensive review/discussion in that
|
||||
* PR. Both references would be caught by ISSUE_REF pattern below.
|
||||
*/
|
||||
static Pattern SHORT_MESSAGE = Pattern
|
||||
.compile("(?:[a-zA-Z]+ #[0-9]+)?([^\\(]+)(?:\\(#[0-9]+\\))?");
|
||||
static Pattern SHORT_MESSAGE = Pattern.compile("(?:[a-zA-Z]+ #[0-9]+)?([^\\(]+)(?:\\(#[0-9]+\\))?");
|
||||
|
||||
/**
|
||||
* A {@link Pattern} to find issue/pr numbers in a commit message, by detecting
|
||||
@@ -607,8 +566,7 @@ public class GenerateReleaseNotesTask
|
||||
}
|
||||
else {
|
||||
this.description = cleanShortMessage + " ("
|
||||
+ String.join(", ", this.associatedIssueLinksAndTitles.keySet())
|
||||
+ ")";
|
||||
+ String.join(", ", this.associatedIssueLinksAndTitles.keySet()) + ")";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -41,27 +41,24 @@ class ReactorConfiguration {
|
||||
}
|
||||
|
||||
@Bean
|
||||
RestartSiteProjectPostReleaseTask restartSiteProjectPostReleaseTask(Releaser releaser,
|
||||
CfClient cfClient, @Value("${cf.reactorAppName}") String reactorAppName) {
|
||||
RestartSiteProjectPostReleaseTask restartSiteProjectPostReleaseTask(Releaser releaser, CfClient cfClient,
|
||||
@Value("${cf.reactorAppName}") String reactorAppName) {
|
||||
return new RestartSiteProjectPostReleaseTask(releaser, cfClient, reactorAppName);
|
||||
}
|
||||
|
||||
@Bean
|
||||
Github githubClient(ReleaserProperties properties) {
|
||||
if (!StringUtils.hasText(properties.getGit().getOauthToken())) {
|
||||
throw new BeanInitializationException(
|
||||
"You must set the value of the OAuth token. You can do it "
|
||||
+ "either via the command line [--releaser.git.oauth-token=...] "
|
||||
+ "or put it as an env variable in [~/.bashrc] or "
|
||||
+ "[~/.zshrc] e.g. [export RELEASER_GIT_OAUTH_TOKEN=...]");
|
||||
throw new BeanInitializationException("You must set the value of the OAuth token. You can do it "
|
||||
+ "either via the command line [--releaser.git.oauth-token=...] "
|
||||
+ "or put it as an env variable in [~/.bashrc] or "
|
||||
+ "[~/.zshrc] e.g. [export RELEASER_GIT_OAUTH_TOKEN=...]");
|
||||
}
|
||||
return new RtGithub(new RtGithub(properties.getGit().getOauthToken()).entry()
|
||||
.through(RetryWire.class));
|
||||
return new RtGithub(new RtGithub(properties.getGit().getOauthToken()).entry().through(RetryWire.class));
|
||||
}
|
||||
|
||||
@Bean
|
||||
GenerateReleaseNotesTask releaseNotesTask(Github github,
|
||||
ProjectGitHandler gitHandler) {
|
||||
GenerateReleaseNotesTask releaseNotesTask(Github github, ProjectGitHandler gitHandler) {
|
||||
return new GenerateReleaseNotesTask(github, gitHandler);
|
||||
}
|
||||
|
||||
|
||||
@@ -31,8 +31,7 @@ public class RestartSiteProjectPostReleaseTask extends PublishDocsReleaseTask {
|
||||
|
||||
private final String reactorAppName;
|
||||
|
||||
public RestartSiteProjectPostReleaseTask(Releaser releaser, CfClient cfClient,
|
||||
String reactorAppName) {
|
||||
public RestartSiteProjectPostReleaseTask(Releaser releaser, CfClient cfClient, String reactorAppName) {
|
||||
super(releaser);
|
||||
this.cfClient = cfClient;
|
||||
this.reactorAppName = reactorAppName;
|
||||
@@ -58,8 +57,7 @@ class CfClient {
|
||||
}
|
||||
|
||||
void restartApp(String name) {
|
||||
this.cloudFoundryOperations.applications()
|
||||
.restart(RestartApplicationRequest.builder().name(name).build());
|
||||
this.cloudFoundryOperations.applications().restart(RestartApplicationRequest.builder().name(name).build());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -49,13 +49,11 @@ class ReleaserApplicationTests {
|
||||
|
||||
@Test
|
||||
void should_load_generate_release_notes_in_dry_run() {
|
||||
Map<String, DryRunReleaseReleaserTask> beans = context
|
||||
.getBeansOfType(DryRunReleaseReleaserTask.class);
|
||||
Map<String, DryRunReleaseReleaserTask> beans = context.getBeansOfType(DryRunReleaseReleaserTask.class);
|
||||
List<ReleaserTask> inOrder = new LinkedList<>(beans.values());
|
||||
inOrder.sort(AnnotationAwareOrderComparator.INSTANCE);
|
||||
|
||||
assertThat(inOrder).anySatisfy(
|
||||
task -> assertThat(task).isInstanceOf(GenerateReleaseNotesTask.class));
|
||||
assertThat(inOrder).anySatisfy(task -> assertThat(task).isInstanceOf(GenerateReleaseNotesTask.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -64,11 +62,9 @@ class ReleaserApplicationTests {
|
||||
List<ReleaserTask> inOrder = new LinkedList<>(beans.values());
|
||||
inOrder.sort(AnnotationAwareOrderComparator.INSTANCE);
|
||||
|
||||
assertThat(inOrder).anySatisfy(task -> assertThat(task)
|
||||
.isInstanceOf(RestartSiteProjectPostReleaseTask.class));
|
||||
assertThat(inOrder).noneSatisfy(
|
||||
task -> assertThat(task).isInstanceOf(PublishDocsReleaseTask.class)
|
||||
.isNotInstanceOf(RestartSiteProjectPostReleaseTask.class));
|
||||
assertThat(inOrder).anySatisfy(task -> assertThat(task).isInstanceOf(RestartSiteProjectPostReleaseTask.class));
|
||||
assertThat(inOrder).noneSatisfy(task -> assertThat(task).isInstanceOf(PublishDocsReleaseTask.class)
|
||||
.isNotInstanceOf(RestartSiteProjectPostReleaseTask.class));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -60,23 +60,22 @@ class GenerateReleaseNotesTaskTest {
|
||||
|
||||
@Test
|
||||
void extractTypeFromLabel() {
|
||||
assertThat(task.extractTypes(Collections.singleton("type/bug"), ""))
|
||||
.as("type/bug").containsOnly(Type.BUG);
|
||||
assertThat(task.extractTypes(Collections.singleton("type/bug"), "")).as("type/bug").containsOnly(Type.BUG);
|
||||
|
||||
assertThat(task.extractTypes(Collections.singleton("type/enhancement"), ""))
|
||||
.as("type/enhancement").containsOnly(Type.FEATURE);
|
||||
assertThat(task.extractTypes(Collections.singleton("type/enhancement"), "")).as("type/enhancement")
|
||||
.containsOnly(Type.FEATURE);
|
||||
|
||||
assertThat(task.extractTypes(Collections.singleton("type/documentation"), ""))
|
||||
.as("type/documentation").containsOnly(Type.DOC_MISC);
|
||||
assertThat(task.extractTypes(Collections.singleton("type/documentation"), "")).as("type/documentation")
|
||||
.containsOnly(Type.DOC_MISC);
|
||||
|
||||
assertThat(task.extractTypes(Collections.singleton("type/chores"), ""))
|
||||
.as("type/chores").containsOnly(Type.DOC_MISC);
|
||||
assertThat(task.extractTypes(Collections.singleton("type/chores"), "")).as("type/chores")
|
||||
.containsOnly(Type.DOC_MISC);
|
||||
|
||||
assertThat(task.extractTypes(Collections.singleton("warn/something"), ""))
|
||||
.as("warn/*").containsOnly(Type.NOTEWORTHY);
|
||||
assertThat(task.extractTypes(Collections.singleton("warn/something"), "")).as("warn/*")
|
||||
.containsOnly(Type.NOTEWORTHY);
|
||||
|
||||
assertThat(task.extractTypes(Collections.singleton("type/whatever"), ""))
|
||||
.as("type/whatever").containsOnly(Type.UNCLASSIFIED);
|
||||
assertThat(task.extractTypes(Collections.singleton("type/whatever"), "")).as("type/whatever")
|
||||
.containsOnly(Type.UNCLASSIFIED);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -87,179 +86,158 @@ class GenerateReleaseNotesTaskTest {
|
||||
labels.add("type/documentation");
|
||||
labels.add("whatever");
|
||||
|
||||
assertThat(task.extractTypes(labels, "")).as("multiple labels")
|
||||
.containsOnly(Type.BUG, Type.FEATURE, Type.DOC_MISC);
|
||||
assertThat(task.extractTypes(labels, "")).as("multiple labels").containsOnly(Type.BUG, Type.FEATURE,
|
||||
Type.DOC_MISC);
|
||||
}
|
||||
|
||||
@Test
|
||||
void extractMiscTypeFromBuildMessagePrefix() {
|
||||
String message = "[build] Foo";
|
||||
|
||||
assertThat(task.extractTypes(Collections.emptySet(), message))
|
||||
.containsOnly(Type.DOC_MISC);
|
||||
assertThat(task.extractTypes(Collections.emptySet(), message)).containsOnly(Type.DOC_MISC);
|
||||
}
|
||||
|
||||
@Test
|
||||
void extractMiscTypeFromPolishMessagePrefix() {
|
||||
String message = "[polish] Foo";
|
||||
|
||||
assertThat(task.extractTypes(Collections.emptySet(), message))
|
||||
.containsOnly(Type.DOC_MISC);
|
||||
assertThat(task.extractTypes(Collections.emptySet(), message)).containsOnly(Type.DOC_MISC);
|
||||
}
|
||||
|
||||
@Test
|
||||
void extractMiscTypeFromDocMessagePrefix() {
|
||||
String message = "[doc] Foo";
|
||||
|
||||
assertThat(task.extractTypes(Collections.emptySet(), message))
|
||||
.containsOnly(Type.DOC_MISC);
|
||||
assertThat(task.extractTypes(Collections.emptySet(), message)).containsOnly(Type.DOC_MISC);
|
||||
}
|
||||
|
||||
@Test
|
||||
void extractUnclassifiedTypeFromRandomMessagePrefix() {
|
||||
String message = "fix #123 There was a [bug], needed to [polish] the [doc]";
|
||||
|
||||
assertThat(task.extractTypes(Collections.emptySet(), message))
|
||||
.containsOnly(Type.UNCLASSIFIED);
|
||||
assertThat(task.extractTypes(Collections.emptySet(), message)).containsOnly(Type.UNCLASSIFIED);
|
||||
}
|
||||
|
||||
@Test
|
||||
void noTitleCleanupFromMergeCommit() {
|
||||
SimpleCommit mergeCommit = new SimpleCommit("sha1", "fullsha1",
|
||||
"merge #123 into 3.3 (#123)", "merge #123 into 3.3", "Simon Baslé",
|
||||
"sbasle@pivotal.io", "Simon Baslé", "sbasle@pivotal.io", true);
|
||||
SimpleCommit mergeCommit = new SimpleCommit("sha1", "fullsha1", "merge #123 into 3.3 (#123)",
|
||||
"merge #123 into 3.3", "Simon Baslé", "sbasle@pivotal.io", "Simon Baslé", "sbasle@pivotal.io", true);
|
||||
|
||||
assertThat(task.cleanupShortMessage(mergeCommit))
|
||||
.isEqualTo("merge #123 into 3.3 (#123)");
|
||||
assertThat(task.cleanupShortMessage(mergeCommit)).isEqualTo("merge #123 into 3.3 (#123)");
|
||||
}
|
||||
|
||||
@Test
|
||||
void titleCleanupFixPrefix() {
|
||||
SimpleCommit commit = new SimpleCommit("sha1", "fullsha1",
|
||||
"fix #123 Text from title", "fix #123 Some more text", "Simon Baslé",
|
||||
"sbasle@pivotal.io", "Simon Baslé", "sbasle@pivotal.io", false);
|
||||
SimpleCommit commit = new SimpleCommit("sha1", "fullsha1", "fix #123 Text from title",
|
||||
"fix #123 Some more text", "Simon Baslé", "sbasle@pivotal.io", "Simon Baslé", "sbasle@pivotal.io",
|
||||
false);
|
||||
|
||||
assertThat(task.cleanupShortMessage(commit)).isEqualTo("Text from title");
|
||||
}
|
||||
|
||||
@Test
|
||||
void titleCleanupSeePrefix() {
|
||||
SimpleCommit commit = new SimpleCommit("sha1", "fullsha1",
|
||||
"see #123 Text from title", "see #123 Some more text", "Simon Baslé",
|
||||
"sbasle@pivotal.io", "Simon Baslé", "sbasle@pivotal.io", false);
|
||||
SimpleCommit commit = new SimpleCommit("sha1", "fullsha1", "see #123 Text from title",
|
||||
"see #123 Some more text", "Simon Baslé", "sbasle@pivotal.io", "Simon Baslé", "sbasle@pivotal.io",
|
||||
false);
|
||||
|
||||
assertThat(task.cleanupShortMessage(commit)).isEqualTo("Text from title");
|
||||
}
|
||||
|
||||
@Test
|
||||
void titleCleanupPrStyleSuffix() {
|
||||
SimpleCommit commit = new SimpleCommit("sha1", "fullsha1",
|
||||
"Commit without issue (#123)", "fullMessage", "Simon Baslé",
|
||||
"sbasle@pivotal.io", "Simon Baslé", "sbasle@pivotal.io", false);
|
||||
SimpleCommit commit = new SimpleCommit("sha1", "fullsha1", "Commit without issue (#123)", "fullMessage",
|
||||
"Simon Baslé", "sbasle@pivotal.io", "Simon Baslé", "sbasle@pivotal.io", false);
|
||||
|
||||
assertThat(task.cleanupShortMessage(commit)).isEqualTo("Commit without issue");
|
||||
}
|
||||
|
||||
@Test
|
||||
void titleCleanupPrStyleSuffixNoSpace() {
|
||||
SimpleCommit commit = new SimpleCommit("sha1", "fullsha1",
|
||||
"Commit without issue(#123)", "fullMessage", "Simon Baslé",
|
||||
"sbasle@pivotal.io", "Simon Baslé", "sbasle@pivotal.io", false);
|
||||
SimpleCommit commit = new SimpleCommit("sha1", "fullsha1", "Commit without issue(#123)", "fullMessage",
|
||||
"Simon Baslé", "sbasle@pivotal.io", "Simon Baslé", "sbasle@pivotal.io", false);
|
||||
|
||||
assertThat(task.cleanupShortMessage(commit)).isEqualTo("Commit without issue");
|
||||
}
|
||||
|
||||
@Test
|
||||
void titleCleanupBothPrefixAndSuffix() {
|
||||
SimpleCommit commit = new SimpleCommit("sha1", "fullsha1",
|
||||
"prefix #123 Commit title (#123)", "fullMessage", "Simon Baslé",
|
||||
"sbasle@pivotal.io", "Simon Baslé", "sbasle@pivotal.io", false);
|
||||
SimpleCommit commit = new SimpleCommit("sha1", "fullsha1", "prefix #123 Commit title (#123)", "fullMessage",
|
||||
"Simon Baslé", "sbasle@pivotal.io", "Simon Baslé", "sbasle@pivotal.io", false);
|
||||
|
||||
assertThat(task.cleanupShortMessage(commit)).isEqualTo("Commit title");
|
||||
}
|
||||
|
||||
@Test
|
||||
void issueNumberTitlePrefix() {
|
||||
SimpleCommit commit = new SimpleCommit("sha1", "fullsha1",
|
||||
"prefix #123 Commit title", "fullMessage", "Simon Baslé",
|
||||
"sbasle@pivotal.io", "Simon Baslé", "sbasle@pivotal.io", false);
|
||||
SimpleCommit commit = new SimpleCommit("sha1", "fullsha1", "prefix #123 Commit title", "fullMessage",
|
||||
"Simon Baslé", "sbasle@pivotal.io", "Simon Baslé", "sbasle@pivotal.io", false);
|
||||
|
||||
assertThat(task.extractIssueNumbers(commit)).containsOnly(123);
|
||||
}
|
||||
|
||||
@Test
|
||||
void issueNumberTitlePrStyleSuffix() {
|
||||
SimpleCommit commit = new SimpleCommit("sha1", "fullsha1", "Commit title (#123)",
|
||||
"fullMessage", "Simon Baslé", "sbasle@pivotal.io", "Simon Baslé",
|
||||
"sbasle@pivotal.io", false);
|
||||
SimpleCommit commit = new SimpleCommit("sha1", "fullsha1", "Commit title (#123)", "fullMessage", "Simon Baslé",
|
||||
"sbasle@pivotal.io", "Simon Baslé", "sbasle@pivotal.io", false);
|
||||
|
||||
assertThat(task.extractIssueNumbers(commit)).containsOnly(123);
|
||||
}
|
||||
|
||||
@Test
|
||||
void issueNumberTitlePrefixAndSuffix() {
|
||||
SimpleCommit commit = new SimpleCommit("sha1", "fullsha1",
|
||||
"prefix #123 Commit title (#456)", "fullMessage", "Simon Baslé",
|
||||
"sbasle@pivotal.io", "Simon Baslé", "sbasle@pivotal.io", false);
|
||||
SimpleCommit commit = new SimpleCommit("sha1", "fullsha1", "prefix #123 Commit title (#456)", "fullMessage",
|
||||
"Simon Baslé", "sbasle@pivotal.io", "Simon Baslé", "sbasle@pivotal.io", false);
|
||||
|
||||
assertThat(task.extractIssueNumbers(commit)).containsOnly(123, 456);
|
||||
}
|
||||
|
||||
@Test
|
||||
void issueNumberTitleNotSeparatedBySpace() {
|
||||
SimpleCommit commit = new SimpleCommit("sha1", "fullsha1",
|
||||
"prefix#123Commit title(#456)", "fullMessage", "Simon Baslé",
|
||||
"sbasle@pivotal.io", "Simon Baslé", "sbasle@pivotal.io", false);
|
||||
SimpleCommit commit = new SimpleCommit("sha1", "fullsha1", "prefix#123Commit title(#456)", "fullMessage",
|
||||
"Simon Baslé", "sbasle@pivotal.io", "Simon Baslé", "sbasle@pivotal.io", false);
|
||||
|
||||
assertThat(task.extractIssueNumbers(commit)).containsOnly(123, 456);
|
||||
}
|
||||
|
||||
static final VoidAnswer4<Issues, Set<Integer>, Set<String>, Map<String, String>> MOCK_FETCH_ISSUES = (
|
||||
ignore1, issues, ignore2, resolved) -> issues
|
||||
.forEach(i -> resolved.put("#" + i, "alternative title for " + i));
|
||||
static final VoidAnswer4<Issues, Set<Integer>, Set<String>, Map<String, String>> MOCK_FETCH_ISSUES = (ignore1,
|
||||
issues, ignore2, resolved) -> issues.forEach(i -> resolved.put("#" + i, "alternative title for " + i));
|
||||
|
||||
static final Issues MOCK_ISSUES = Mockito.mock(Issues.class);
|
||||
|
||||
@Test
|
||||
void generateChangelogDescriptionSingleIssueTwice() throws IOException {
|
||||
final GenerateReleaseNotesTask spy = Mockito.spy(task);
|
||||
doAnswer(answerVoid(MOCK_FETCH_ISSUES)).when(spy).fetchIssueLabelsAndTitles(any(),
|
||||
any(), any(), any());
|
||||
doAnswer(answerVoid(MOCK_FETCH_ISSUES)).when(spy).fetchIssueLabelsAndTitles(any(), any(), any(), any());
|
||||
|
||||
SimpleCommit commit = new SimpleCommit("sha1", "fullsha1",
|
||||
"prefix #123 Commit title (#123)", "fullMessage", "Simon Baslé",
|
||||
"sbasle@pivotal.io", "Simon Baslé", "sbasle@pivotal.io", false);
|
||||
SimpleCommit commit = new SimpleCommit("sha1", "fullsha1", "prefix #123 Commit title (#123)", "fullMessage",
|
||||
"Simon Baslé", "sbasle@pivotal.io", "Simon Baslé", "sbasle@pivotal.io", false);
|
||||
|
||||
assertThat(spy.parseChangeLogEntry(githubClient.randomRepo().issues(),
|
||||
commit).description).isEqualTo("Commit title (#123)");
|
||||
assertThat(spy.parseChangeLogEntry(githubClient.randomRepo().issues(), commit).description)
|
||||
.isEqualTo("Commit title (#123)");
|
||||
}
|
||||
|
||||
@Test
|
||||
void generateChangelogDescriptionTwoIssues() throws IOException {
|
||||
final GenerateReleaseNotesTask spy = Mockito.spy(task);
|
||||
doAnswer(answerVoid(MOCK_FETCH_ISSUES)).when(spy).fetchIssueLabelsAndTitles(any(),
|
||||
any(), any(), any());
|
||||
doAnswer(answerVoid(MOCK_FETCH_ISSUES)).when(spy).fetchIssueLabelsAndTitles(any(), any(), any(), any());
|
||||
|
||||
SimpleCommit commit = new SimpleCommit("sha1", "fullsha1",
|
||||
"prefix #123 Commit title (#456)", "fullMessage", "Simon Baslé",
|
||||
"sbasle@pivotal.io", "Simon Baslé", "sbasle@pivotal.io", false);
|
||||
SimpleCommit commit = new SimpleCommit("sha1", "fullsha1", "prefix #123 Commit title (#456)", "fullMessage",
|
||||
"Simon Baslé", "sbasle@pivotal.io", "Simon Baslé", "sbasle@pivotal.io", false);
|
||||
|
||||
assertThat(spy.parseChangeLogEntry(MOCK_ISSUES, commit).description)
|
||||
.isEqualTo("Commit title (#123, #456)");
|
||||
assertThat(spy.parseChangeLogEntry(MOCK_ISSUES, commit).description).isEqualTo("Commit title (#123, #456)");
|
||||
}
|
||||
|
||||
@Test
|
||||
void generateChangelogDescriptionTwoIssuesNoSpace() throws IOException {
|
||||
final GenerateReleaseNotesTask spy = Mockito.spy(task);
|
||||
doAnswer(answerVoid(MOCK_FETCH_ISSUES)).when(spy).fetchIssueLabelsAndTitles(any(),
|
||||
any(), any(), any());
|
||||
doAnswer(answerVoid(MOCK_FETCH_ISSUES)).when(spy).fetchIssueLabelsAndTitles(any(), any(), any(), any());
|
||||
|
||||
SimpleCommit commit = new SimpleCommit("sha1", "fullsha1",
|
||||
"prefix #123Commit title no space(#456)", "fullMessage", "Simon Baslé",
|
||||
"sbasle@pivotal.io", "Simon Baslé", "sbasle@pivotal.io", false);
|
||||
SimpleCommit commit = new SimpleCommit("sha1", "fullsha1", "prefix #123Commit title no space(#456)",
|
||||
"fullMessage", "Simon Baslé", "sbasle@pivotal.io", "Simon Baslé", "sbasle@pivotal.io", false);
|
||||
|
||||
assertThat(spy.parseChangeLogEntry(githubClient.randomRepo().issues(),
|
||||
commit).description).isEqualTo("Commit title no space (#123, #456)");
|
||||
assertThat(spy.parseChangeLogEntry(githubClient.randomRepo().issues(), commit).description)
|
||||
.isEqualTo("Commit title no space (#123, #456)");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -267,12 +245,11 @@ class GenerateReleaseNotesTaskTest {
|
||||
final GenerateReleaseNotesTask spy = Mockito.spy(task);
|
||||
doNothing().when(spy).fetchIssueLabelsAndTitles(any(), any(), any(), any());
|
||||
|
||||
SimpleCommit commit = new SimpleCommit("sha1", "fullsha1",
|
||||
"prefix #123 Commit title no space(#456)", "fullMessage", "Simon Baslé",
|
||||
"sbasle@pivotal.io", "Simon Baslé", "sbasle@pivotal.io", false);
|
||||
SimpleCommit commit = new SimpleCommit("sha1", "fullsha1", "prefix #123 Commit title no space(#456)",
|
||||
"fullMessage", "Simon Baslé", "sbasle@pivotal.io", "Simon Baslé", "sbasle@pivotal.io", false);
|
||||
|
||||
assertThat(spy.parseChangeLogEntry(githubClient.randomRepo().issues(),
|
||||
commit).description).isEqualTo("Commit title no space (sha1)");
|
||||
assertThat(spy.parseChangeLogEntry(githubClient.randomRepo().issues(), commit).description)
|
||||
.isEqualTo("Commit title no space (sha1)");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -284,9 +261,8 @@ class GenerateReleaseNotesTaskTest {
|
||||
assertThatExceptionOfType(Exception.class).as("github client fails")
|
||||
.isThrownBy(() -> new Issue.Smart(issuesClient.get(123)).title());
|
||||
|
||||
assertThatCode(() -> task.fetchIssueLabelsAndTitles(issuesClient,
|
||||
Collections.singleton(123), labels, associatedIssues))
|
||||
.as("fetching just does nothing").doesNotThrowAnyException();
|
||||
assertThatCode(() -> task.fetchIssueLabelsAndTitles(issuesClient, Collections.singleton(123), labels,
|
||||
associatedIssues)).as("fetching just does nothing").doesNotThrowAnyException();
|
||||
|
||||
assertThat(labels).as("labels").isEmpty();
|
||||
assertThat(associatedIssues).as("associated issues").isEmpty();
|
||||
|
||||
@@ -46,14 +46,13 @@ import org.springframework.context.annotation.Profile;
|
||||
public class ReactorTestConfiguration {
|
||||
|
||||
@Bean
|
||||
RestartSiteProjectPostReleaseTask restartSiteProjectPostReleaseTask(Releaser releaser,
|
||||
CfClient cfClient, @Value("${cf.reactorAppName}") String reactorAppName) {
|
||||
RestartSiteProjectPostReleaseTask restartSiteProjectPostReleaseTask(Releaser releaser, CfClient cfClient,
|
||||
@Value("${cf.reactorAppName}") String reactorAppName) {
|
||||
return new RestartSiteProjectPostReleaseTask(releaser, cfClient, reactorAppName);
|
||||
}
|
||||
|
||||
@Bean
|
||||
GenerateReleaseNotesTask releaseNotesTask(Github github,
|
||||
ProjectGitHandler gitHandler) {
|
||||
GenerateReleaseNotesTask releaseNotesTask(Github github, ProjectGitHandler gitHandler) {
|
||||
return new GenerateReleaseNotesTask(github, gitHandler);
|
||||
}
|
||||
|
||||
|
||||
@@ -16,8 +16,6 @@
|
||||
|
||||
package releaser.reactor;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
import org.assertj.core.api.BDDAssertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.BDDMockito;
|
||||
@@ -34,6 +32,8 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
@SpringBootTest
|
||||
@ActiveProfiles("test")
|
||||
class RestartSiteProjectPostReleaseTaskTests {
|
||||
@@ -51,16 +51,13 @@ class RestartSiteProjectPostReleaseTaskTests {
|
||||
ExecutionResult result = task.runTask(arguments);
|
||||
|
||||
BDDAssertions.then(result.isSuccess()).isTrue();
|
||||
BDDMockito.then(this.cfClient).should()
|
||||
.restartApp(BDDMockito.eq("projectreactor"));
|
||||
BDDMockito.then(this.cfClient).should().restartApp(BDDMockito.eq("projectreactor"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void should_fail_if_original_version_is_null() {
|
||||
ProjectToRun p = new ProjectToRun(null,
|
||||
new ProjectsFromBom(new Projects(), new ProjectVersion("foo", "1.0.0")),
|
||||
null, new ReleaserProperties(),
|
||||
BDDMockito.mock(Options.class)) {
|
||||
ProjectToRun p = new ProjectToRun(null, new ProjectsFromBom(new Projects(), new ProjectVersion("foo", "1.0.0")),
|
||||
null, new ReleaserProperties(), BDDMockito.mock(Options.class)) {
|
||||
@Override
|
||||
public String name() {
|
||||
return "reactor-core";
|
||||
@@ -86,10 +83,8 @@ class RestartSiteProjectPostReleaseTaskTests {
|
||||
}
|
||||
|
||||
private ProjectToRun reactorCoreProject() {
|
||||
return new ProjectToRun(null,
|
||||
new ProjectsFromBom(new Projects(), new ProjectVersion("foo", "1.0.0")),
|
||||
new ProjectVersion("foo", "1.0.0"), new ReleaserProperties(),
|
||||
BDDMockito.mock(Options.class)) {
|
||||
return new ProjectToRun(null, new ProjectsFromBom(new Projects(), new ProjectVersion("foo", "1.0.0")),
|
||||
new ProjectVersion("foo", "1.0.0"), new ReleaserProperties(), BDDMockito.mock(Options.class)) {
|
||||
@Override
|
||||
public String name() {
|
||||
return "reactor-core";
|
||||
@@ -98,10 +93,8 @@ class RestartSiteProjectPostReleaseTaskTests {
|
||||
}
|
||||
|
||||
private ProjectToRun nonReactorCoreProject() {
|
||||
return new ProjectToRun(null,
|
||||
new ProjectsFromBom(new Projects(), new ProjectVersion("foo", "1.0.0")),
|
||||
new ProjectVersion("foo", "1.0.0"), new ReleaserProperties(),
|
||||
BDDMockito.mock(Options.class)) {
|
||||
return new ProjectToRun(null, new ProjectsFromBom(new Projects(), new ProjectVersion("foo", "1.0.0")),
|
||||
new ProjectVersion("foo", "1.0.0"), new ReleaserProperties(), BDDMockito.mock(Options.class)) {
|
||||
@Override
|
||||
public String name() {
|
||||
return "whatever";
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
cf:
|
||||
username: foo
|
||||
password: bar
|
||||
spring:
|
||||
profiles:
|
||||
active: test
|
||||
password: bar
|
||||
@@ -27,8 +27,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
@SpringBootApplication
|
||||
public class ReleaserApplication extends ReleaserCommandLineRunner {
|
||||
|
||||
public ReleaserApplication(SpringReleaser releaser,
|
||||
ExecutionResultHandler executionResultHandler, Parser parser) {
|
||||
public ReleaserApplication(SpringReleaser releaser, ExecutionResultHandler executionResultHandler, Parser parser) {
|
||||
super(releaser, executionResultHandler, parser);
|
||||
}
|
||||
|
||||
|
||||
@@ -24,8 +24,7 @@ final class SpringCloudBomConstants {
|
||||
// boot
|
||||
static final String SPRING_BOOT = "spring-boot";
|
||||
static final String BOOT_STARTER_ARTIFACT_ID = "spring-boot-starter";
|
||||
static final String BOOT_STARTER_PARENT_ARTIFACT_ID = BOOT_STARTER_ARTIFACT_ID
|
||||
+ "-parent";
|
||||
static final String BOOT_STARTER_PARENT_ARTIFACT_ID = BOOT_STARTER_ARTIFACT_ID + "-parent";
|
||||
static final String BOOT_DEPENDENCIES_ARTIFACT_ID = "spring-boot-dependencies";
|
||||
|
||||
// sc-build
|
||||
|
||||
@@ -51,17 +51,15 @@ import static releaser.cloud.buildsystem.SpringCloudBomConstants.STREAM_STARTER_
|
||||
|
||||
class SpringCloudStreamMavenBomParser implements CustomBomParser {
|
||||
|
||||
private static final Logger log = LoggerFactory
|
||||
.getLogger(SpringCloudStreamMavenBomParser.class);
|
||||
private static final Logger log = LoggerFactory.getLogger(SpringCloudStreamMavenBomParser.class);
|
||||
|
||||
@Override
|
||||
public VersionsFromBom parseBom(File root, ReleaserProperties properties) {
|
||||
VersionsFromBom springCloudBuild = springCloudBuild(root, properties);
|
||||
VersionsFromBom boot = bootVersion(root, properties);
|
||||
log.debug("Added Spring Cloud Build [{}] and boot versions [{}]",
|
||||
springCloudBuild, boot);
|
||||
return new VersionsFromBomBuilder().thisProjectRoot(root)
|
||||
.releaserProperties(properties).projects(springCloudBuild, boot).merged();
|
||||
log.debug("Added Spring Cloud Build [{}] and boot versions [{}]", springCloudBuild, boot);
|
||||
return new VersionsFromBomBuilder().thisProjectRoot(root).releaserProperties(properties)
|
||||
.projects(springCloudBuild, boot).merged();
|
||||
}
|
||||
|
||||
private VersionsFromBom springCloudBuild(File root, ReleaserProperties properties) {
|
||||
@@ -69,8 +67,8 @@ class SpringCloudStreamMavenBomParser implements CustomBomParser {
|
||||
if (StringUtils.isEmpty(buildVersion)) {
|
||||
return VersionsFromBom.EMPTY_VERSION;
|
||||
}
|
||||
VersionsFromBom scBuild = new VersionsFromBomBuilder().thisProjectRoot(root)
|
||||
.releaserProperties(properties).merged();
|
||||
VersionsFromBom scBuild = new VersionsFromBomBuilder().thisProjectRoot(root).releaserProperties(properties)
|
||||
.merged();
|
||||
scBuild.add(BUILD_ARTIFACT_ID, buildVersion);
|
||||
scBuild.add(CLOUD_DEPENDENCIES_PARENT_ARTIFACT_ID, buildVersion);
|
||||
return scBuild;
|
||||
@@ -87,11 +85,9 @@ class SpringCloudStreamMavenBomParser implements CustomBomParser {
|
||||
}
|
||||
Model model = PomReader.pom(root, properties.getPom().getThisTrainBom());
|
||||
String buildArtifact = model.getParent().getArtifactId();
|
||||
log.debug("[{}] artifact id is equal to [{}]",
|
||||
CLOUD_DEPENDENCIES_PARENT_ARTIFACT_ID, buildArtifact);
|
||||
log.debug("[{}] artifact id is equal to [{}]", CLOUD_DEPENDENCIES_PARENT_ARTIFACT_ID, buildArtifact);
|
||||
if (!CLOUD_DEPENDENCIES_PARENT_ARTIFACT_ID.equals(buildArtifact)) {
|
||||
throw new IllegalStateException(
|
||||
"The pom doesn't have a [spring-cloud-dependencies-parent] artifact id");
|
||||
throw new IllegalStateException("The pom doesn't have a [spring-cloud-dependencies-parent] artifact id");
|
||||
}
|
||||
buildVersion = model.getParent().getVersion();
|
||||
log.debug("Spring Cloud Build version is equal to [{}]", buildVersion);
|
||||
@@ -103,8 +99,7 @@ class SpringCloudStreamMavenBomParser implements CustomBomParser {
|
||||
if (StringUtils.hasText(bootVersion)) {
|
||||
return bootVersion;
|
||||
}
|
||||
String pomWithBootStarterParent = properties.getPom()
|
||||
.getPomWithBootStarterParent();
|
||||
String pomWithBootStarterParent = properties.getPom().getPomWithBootStarterParent();
|
||||
File pom = new File(root, pomWithBootStarterParent);
|
||||
if (!pom.exists()) {
|
||||
return "";
|
||||
@@ -117,8 +112,8 @@ class SpringCloudStreamMavenBomParser implements CustomBomParser {
|
||||
log.debug("Boot artifact id is equal to [{}]", bootArtifactId);
|
||||
if (!BOOT_STARTER_PARENT_ARTIFACT_ID.equals(bootArtifactId)) {
|
||||
if (log.isDebugEnabled()) {
|
||||
throw new IllegalStateException("The pom doesn't have a ["
|
||||
+ BOOT_STARTER_PARENT_ARTIFACT_ID + "] artifact id");
|
||||
throw new IllegalStateException(
|
||||
"The pom doesn't have a [" + BOOT_STARTER_PARENT_ARTIFACT_ID + "] artifact id");
|
||||
}
|
||||
return "";
|
||||
}
|
||||
@@ -131,8 +126,8 @@ class SpringCloudStreamMavenBomParser implements CustomBomParser {
|
||||
return VersionsFromBom.EMPTY_VERSION;
|
||||
}
|
||||
log.debug("Boot version is equal to [{}]", bootVersion);
|
||||
VersionsFromBom versionsFromBom = new VersionsFromBomBuilder()
|
||||
.thisProjectRoot(root).releaserProperties(properties).merged();
|
||||
VersionsFromBom versionsFromBom = new VersionsFromBomBuilder().thisProjectRoot(root)
|
||||
.releaserProperties(properties).merged();
|
||||
versionsFromBom.add(SPRING_BOOT, bootVersion);
|
||||
versionsFromBom.add(BOOT_STARTER_PARENT_ARTIFACT_ID, bootVersion);
|
||||
versionsFromBom.add(BOOT_DEPENDENCIES_ARTIFACT_ID, bootVersion);
|
||||
@@ -140,8 +135,7 @@ class SpringCloudStreamMavenBomParser implements CustomBomParser {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Project> setVersion(Set<Project> projects, String projectName,
|
||||
String version) {
|
||||
public Set<Project> setVersion(Set<Project> projects, String projectName, String version) {
|
||||
Set<Project> newProjects = new LinkedHashSet<>(projects);
|
||||
switch (projectName) {
|
||||
case SPRING_BOOT:
|
||||
|
||||
@@ -27,8 +27,7 @@ import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@SpringBootTest(
|
||||
classes = { ReleaserApplicationTests.Config.class, ReleaserApplication.class },
|
||||
@SpringBootTest(classes = { ReleaserApplicationTests.Config.class, ReleaserApplication.class },
|
||||
properties = { "releaser.sagan.update-sagan=false" })
|
||||
class ReleaserApplicationTests {
|
||||
|
||||
|
||||
@@ -27,8 +27,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
@SpringBootApplication
|
||||
public class ReleaserApplication extends ReleaserCommandLineRunner {
|
||||
|
||||
public ReleaserApplication(SpringReleaser releaser,
|
||||
ExecutionResultHandler executionResultHandler, Parser parser) {
|
||||
public ReleaserApplication(SpringReleaser releaser, ExecutionResultHandler executionResultHandler, Parser parser) {
|
||||
super(releaser, executionResultHandler, parser);
|
||||
}
|
||||
|
||||
|
||||
@@ -24,8 +24,7 @@ final class SpringCloudBomConstants {
|
||||
// boot
|
||||
static final String SPRING_BOOT = "spring-boot";
|
||||
static final String BOOT_STARTER_ARTIFACT_ID = "spring-boot-starter";
|
||||
static final String BOOT_STARTER_PARENT_ARTIFACT_ID = BOOT_STARTER_ARTIFACT_ID
|
||||
+ "-parent";
|
||||
static final String BOOT_STARTER_PARENT_ARTIFACT_ID = BOOT_STARTER_ARTIFACT_ID + "-parent";
|
||||
static final String BOOT_DEPENDENCIES_ARTIFACT_ID = "spring-boot-dependencies";
|
||||
|
||||
// sc-build
|
||||
|
||||
@@ -52,17 +52,15 @@ import static releaser.cloud.buildsystem.SpringCloudBomConstants.STREAM_STARTER_
|
||||
|
||||
class SpringCloudMavenBomParser implements CustomBomParser {
|
||||
|
||||
private static final Logger log = LoggerFactory
|
||||
.getLogger(SpringCloudMavenBomParser.class);
|
||||
private static final Logger log = LoggerFactory.getLogger(SpringCloudMavenBomParser.class);
|
||||
|
||||
@Override
|
||||
public VersionsFromBom parseBom(File root, ReleaserProperties properties) {
|
||||
VersionsFromBom springCloudBuild = springCloudBuild(root, properties);
|
||||
VersionsFromBom boot = bootVersion(root, properties);
|
||||
log.debug("Added Spring Cloud Build [{}] and boot versions [{}]",
|
||||
springCloudBuild, boot);
|
||||
return new VersionsFromBomBuilder().thisProjectRoot(root)
|
||||
.releaserProperties(properties).projects(springCloudBuild, boot).merged();
|
||||
log.debug("Added Spring Cloud Build [{}] and boot versions [{}]", springCloudBuild, boot);
|
||||
return new VersionsFromBomBuilder().thisProjectRoot(root).releaserProperties(properties)
|
||||
.projects(springCloudBuild, boot).merged();
|
||||
}
|
||||
|
||||
private VersionsFromBom springCloudBuild(File root, ReleaserProperties properties) {
|
||||
@@ -70,8 +68,8 @@ class SpringCloudMavenBomParser implements CustomBomParser {
|
||||
if (StringUtils.isEmpty(buildVersion)) {
|
||||
return VersionsFromBom.EMPTY_VERSION;
|
||||
}
|
||||
VersionsFromBom scBuild = new VersionsFromBomBuilder().thisProjectRoot(root)
|
||||
.releaserProperties(properties).merged();
|
||||
VersionsFromBom scBuild = new VersionsFromBomBuilder().thisProjectRoot(root).releaserProperties(properties)
|
||||
.merged();
|
||||
scBuild.add(BUILD_ARTIFACT_ID, buildVersion);
|
||||
scBuild.add(CLOUD_DEPENDENCIES_PARENT_ARTIFACT_ID, buildVersion);
|
||||
return scBuild;
|
||||
@@ -88,11 +86,9 @@ class SpringCloudMavenBomParser implements CustomBomParser {
|
||||
}
|
||||
Model model = PomReader.pom(root, properties.getPom().getThisTrainBom());
|
||||
String buildArtifact = model.getParent().getArtifactId();
|
||||
log.debug("[{}] artifact id is equal to [{}]",
|
||||
CLOUD_DEPENDENCIES_PARENT_ARTIFACT_ID, buildArtifact);
|
||||
log.debug("[{}] artifact id is equal to [{}]", CLOUD_DEPENDENCIES_PARENT_ARTIFACT_ID, buildArtifact);
|
||||
if (!CLOUD_DEPENDENCIES_PARENT_ARTIFACT_ID.equals(buildArtifact)) {
|
||||
throw new IllegalStateException(
|
||||
"The pom doesn't have a [spring-cloud-dependencies-parent] artifact id");
|
||||
throw new IllegalStateException("The pom doesn't have a [spring-cloud-dependencies-parent] artifact id");
|
||||
}
|
||||
buildVersion = model.getParent().getVersion();
|
||||
log.debug("Spring Cloud Build version is equal to [{}]", buildVersion);
|
||||
@@ -104,8 +100,7 @@ class SpringCloudMavenBomParser implements CustomBomParser {
|
||||
if (StringUtils.hasText(bootVersion)) {
|
||||
return bootVersion;
|
||||
}
|
||||
String pomWithBootStarterParent = properties.getPom()
|
||||
.getPomWithBootStarterParent();
|
||||
String pomWithBootStarterParent = properties.getPom().getPomWithBootStarterParent();
|
||||
File pom = new File(root, pomWithBootStarterParent);
|
||||
if (!pom.exists()) {
|
||||
return "";
|
||||
@@ -118,8 +113,8 @@ class SpringCloudMavenBomParser implements CustomBomParser {
|
||||
log.debug("Boot artifact id is equal to [{}]", bootArtifactId);
|
||||
if (!BOOT_STARTER_PARENT_ARTIFACT_ID.equals(bootArtifactId)) {
|
||||
if (log.isDebugEnabled()) {
|
||||
throw new IllegalStateException("The pom doesn't have a ["
|
||||
+ BOOT_STARTER_PARENT_ARTIFACT_ID + "] artifact id");
|
||||
throw new IllegalStateException(
|
||||
"The pom doesn't have a [" + BOOT_STARTER_PARENT_ARTIFACT_ID + "] artifact id");
|
||||
}
|
||||
return "";
|
||||
}
|
||||
@@ -132,8 +127,8 @@ class SpringCloudMavenBomParser implements CustomBomParser {
|
||||
return VersionsFromBom.EMPTY_VERSION;
|
||||
}
|
||||
log.debug("Boot version is equal to [{}]", bootVersion);
|
||||
VersionsFromBom versionsFromBom = new VersionsFromBomBuilder()
|
||||
.thisProjectRoot(root).releaserProperties(properties).merged();
|
||||
VersionsFromBom versionsFromBom = new VersionsFromBomBuilder().thisProjectRoot(root)
|
||||
.releaserProperties(properties).merged();
|
||||
versionsFromBom.add(SPRING_BOOT, bootVersion);
|
||||
versionsFromBom.add(BOOT_STARTER_PARENT_ARTIFACT_ID, bootVersion);
|
||||
versionsFromBom.add(BOOT_DEPENDENCIES_ARTIFACT_ID, bootVersion);
|
||||
@@ -141,8 +136,7 @@ class SpringCloudMavenBomParser implements CustomBomParser {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Project> setVersion(Set<Project> projects, String projectName,
|
||||
String version) {
|
||||
public Set<Project> setVersion(Set<Project> projects, String projectName, String version) {
|
||||
Set<Project> newProjects = new LinkedHashSet<>(projects);
|
||||
switch (projectName) {
|
||||
case SPRING_BOOT:
|
||||
|
||||
@@ -35,18 +35,15 @@ import org.springframework.util.StringUtils;
|
||||
/**
|
||||
* @author Marcin Grzejszczak
|
||||
*/
|
||||
class SpringCloudCustomProjectDocumentationUpdater
|
||||
implements CustomProjectDocumentationUpdater {
|
||||
class SpringCloudCustomProjectDocumentationUpdater implements CustomProjectDocumentationUpdater {
|
||||
|
||||
private static final Logger log = LoggerFactory
|
||||
.getLogger(SpringCloudCustomProjectDocumentationUpdater.class);
|
||||
private static final Logger log = LoggerFactory.getLogger(SpringCloudCustomProjectDocumentationUpdater.class);
|
||||
|
||||
private final ProjectGitHandler gitHandler;
|
||||
|
||||
private final ReleaserProperties releaserProperties;
|
||||
|
||||
SpringCloudCustomProjectDocumentationUpdater(ProjectGitHandler gitHandler,
|
||||
ReleaserProperties releaserProperties) {
|
||||
SpringCloudCustomProjectDocumentationUpdater(ProjectGitHandler gitHandler, ReleaserProperties releaserProperties) {
|
||||
this.gitHandler = gitHandler;
|
||||
this.releaserProperties = releaserProperties;
|
||||
}
|
||||
@@ -60,11 +57,10 @@ class SpringCloudCustomProjectDocumentationUpdater
|
||||
* used
|
||||
*/
|
||||
@Override
|
||||
public File updateDocsRepoForReleaseTrain(File clonedDocumentationProject,
|
||||
ProjectVersion currentProject, Projects projects, String bomBranch) {
|
||||
public File updateDocsRepoForReleaseTrain(File clonedDocumentationProject, ProjectVersion currentProject,
|
||||
Projects projects, String bomBranch) {
|
||||
if (!currentProject.projectName.startsWith("spring-cloud")) {
|
||||
log.info(
|
||||
"Skipping updating docs for project [{}] that does not start with spring-cloud prefix",
|
||||
log.info("Skipping updating docs for project [{}] that does not start with spring-cloud prefix",
|
||||
currentProject.projectName);
|
||||
return clonedDocumentationProject;
|
||||
}
|
||||
@@ -72,12 +68,10 @@ class SpringCloudCustomProjectDocumentationUpdater
|
||||
ProjectVersion releaseTrainProject = new ProjectVersion(
|
||||
this.releaserProperties.getMetaRelease().getReleaseTrainProjectName(),
|
||||
branchToReleaseVersion(bomBranch));
|
||||
File currentReleaseFolder = new File(clonedDocumentationProject,
|
||||
currentFolder(releaseTrainProject));
|
||||
File currentReleaseFolder = new File(clonedDocumentationProject, currentFolder(releaseTrainProject));
|
||||
// remove the old way
|
||||
removeAFolderWithRedirection(currentReleaseFolder);
|
||||
File docsRepo = updateTheDocsRepo(releaseTrainProject, clonedDocumentationProject,
|
||||
currentReleaseFolder);
|
||||
File docsRepo = updateTheDocsRepo(releaseTrainProject, clonedDocumentationProject, currentReleaseFolder);
|
||||
return pushChanges(docsRepo);
|
||||
}
|
||||
|
||||
@@ -89,8 +83,8 @@ class SpringCloudCustomProjectDocumentationUpdater
|
||||
* used
|
||||
*/
|
||||
@Override
|
||||
public File updateDocsRepoForSingleProject(File clonedDocumentationProject,
|
||||
ProjectVersion currentProject, Projects projects) {
|
||||
public File updateDocsRepoForSingleProject(File clonedDocumentationProject, ProjectVersion currentProject,
|
||||
Projects projects) {
|
||||
if (!projects.containsProject(currentProject.projectName)) {
|
||||
log.warn(
|
||||
"Can't update the documentation repo for project [{}] cause it's not present on the projects list {}",
|
||||
@@ -98,23 +92,18 @@ class SpringCloudCustomProjectDocumentationUpdater
|
||||
return clonedDocumentationProject;
|
||||
}
|
||||
if (!currentProject.projectName.startsWith("spring-cloud")) {
|
||||
log.info(
|
||||
"Skipping updating docs for project [{}] that does not start with spring-cloud prefix",
|
||||
log.info("Skipping updating docs for project [{}] that does not start with spring-cloud prefix",
|
||||
currentProject.projectName);
|
||||
return clonedDocumentationProject;
|
||||
}
|
||||
log.info("Updating link to documentation for project [{}]",
|
||||
currentProject.projectName);
|
||||
ProjectVersion currentProjectVersion = projects
|
||||
.forName(currentProject.projectName);
|
||||
File currentProjectReleaseFolder = new File(clonedDocumentationProject,
|
||||
currentFolder(currentProjectVersion));
|
||||
log.info("Updating link to documentation for project [{}]", currentProject.projectName);
|
||||
ProjectVersion currentProjectVersion = projects.forName(currentProject.projectName);
|
||||
File currentProjectReleaseFolder = new File(clonedDocumentationProject, currentFolder(currentProjectVersion));
|
||||
removeAFolderWithRedirection(currentProjectReleaseFolder);
|
||||
try {
|
||||
updateTheDocsRepo(currentProjectVersion, clonedDocumentationProject,
|
||||
currentProjectReleaseFolder);
|
||||
log.info("Processed [{}] for project with name [{}]",
|
||||
currentProjectReleaseFolder, currentProjectVersion.projectName);
|
||||
updateTheDocsRepo(currentProjectVersion, clonedDocumentationProject, currentProjectReleaseFolder);
|
||||
log.info("Processed [{}] for project with name [{}]", currentProjectReleaseFolder,
|
||||
currentProjectVersion.projectName);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
log.warn("Exception occurred while trying o update the symlink of a project ["
|
||||
@@ -140,14 +129,13 @@ class SpringCloudCustomProjectDocumentationUpdater
|
||||
releaseTrain = currentProjectVersion.isReleaseTrain();
|
||||
}
|
||||
catch (IllegalStateException ex) {
|
||||
log.warn("Exception occurred while trying to resolve if version ["
|
||||
+ currentProjectVersion + "] is a release train", ex);
|
||||
log.warn("Exception occurred while trying to resolve if version [" + currentProjectVersion
|
||||
+ "] is a release train", ex);
|
||||
releaseTrain = false;
|
||||
}
|
||||
// release train -> static/current
|
||||
// project -> static/spring-cloud-sleuth/current
|
||||
return releaseTrain ? "current"
|
||||
: (StringUtils.hasText(projectName) ? projectName : "") + "/current";
|
||||
return releaseTrain ? "current" : (StringUtils.hasText(projectName) ? projectName : "") + "/current";
|
||||
}
|
||||
|
||||
String linkToVersion(File file) {
|
||||
@@ -176,33 +164,28 @@ class SpringCloudCustomProjectDocumentationUpdater
|
||||
return docsRepo;
|
||||
}
|
||||
|
||||
private File updateTheDocsRepo(ProjectVersion projectVersion,
|
||||
File documentationProject, File currentVersionFolder) {
|
||||
private File updateTheDocsRepo(ProjectVersion projectVersion, File documentationProject,
|
||||
File currentVersionFolder) {
|
||||
try {
|
||||
String storedVersion = linkToVersion(currentVersionFolder);
|
||||
String currentVersion = projectVersion.version;
|
||||
boolean newerVersion = StringUtils.isEmpty(storedVersion)
|
||||
|| isMoreMature(storedVersion, currentVersion);
|
||||
boolean newerVersion = StringUtils.isEmpty(storedVersion) || isMoreMature(storedVersion, currentVersion);
|
||||
if (!newerVersion) {
|
||||
log.info("Current version [{}] is not newer than the stored one [{}]",
|
||||
currentVersion, storedVersion);
|
||||
log.info("Current version [{}] is not newer than the stored one [{}]", currentVersion, storedVersion);
|
||||
return documentationProject;
|
||||
}
|
||||
boolean deleted = Files.deleteIfExists(currentVersionFolder.toPath())
|
||||
|| FileSystemUtils.deleteRecursively(currentVersionFolder.toPath());
|
||||
if (deleted) {
|
||||
log.info("Deleted current version folder link at [{}]",
|
||||
currentVersionFolder);
|
||||
log.info("Deleted current version folder link at [{}]", currentVersionFolder);
|
||||
}
|
||||
boolean creatingParentDirs = currentVersionFolder.getParentFile().mkdirs();
|
||||
if (!creatingParentDirs) {
|
||||
log.warn("Failed to create parent directory of [{}]",
|
||||
currentVersionFolder);
|
||||
log.warn("Failed to create parent directory of [{}]", currentVersionFolder);
|
||||
}
|
||||
File newTarget = new File(projectVersion.version);
|
||||
Files.createSymbolicLink(currentVersionFolder.toPath(), newTarget.toPath());
|
||||
log.info("Updated the link [{}] to point to [{}]",
|
||||
currentVersionFolder.toPath(),
|
||||
log.info("Updated the link [{}] to point to [{}]", currentVersionFolder.toPath(),
|
||||
Files.readSymbolicLink(currentVersionFolder.toPath()));
|
||||
return commitChanges(currentVersion, documentationProject);
|
||||
}
|
||||
@@ -212,8 +195,7 @@ class SpringCloudCustomProjectDocumentationUpdater
|
||||
}
|
||||
|
||||
private boolean isMoreMature(String storedVersion, String currentVersion) {
|
||||
return new ProjectVersion("project", currentVersion)
|
||||
.isMoreMature(new ProjectVersion("project", storedVersion));
|
||||
return new ProjectVersion("project", currentVersion).isMoreMature(new ProjectVersion("project", storedVersion));
|
||||
}
|
||||
|
||||
private String branchToReleaseVersion(String branch) {
|
||||
@@ -223,8 +205,7 @@ class SpringCloudCustomProjectDocumentationUpdater
|
||||
return branch;
|
||||
}
|
||||
|
||||
private File commitChanges(String currentVersion, File documentationProject)
|
||||
throws IOException {
|
||||
private File commitChanges(String currentVersion, File documentationProject) throws IOException {
|
||||
log.info("Updated the symbolic links");
|
||||
this.gitHandler.commit(documentationProject,
|
||||
"Updating the link to the current version to [" + currentVersion + "]");
|
||||
|
||||
@@ -26,10 +26,9 @@ import org.springframework.context.annotation.Configuration;
|
||||
class SpringCloudDocsConfiguration {
|
||||
|
||||
@Bean
|
||||
SpringCloudCustomProjectDocumentationUpdater springCloudCustomProjectDocumentationUpdater(
|
||||
ProjectGitHandler handler, ReleaserProperties releaserProperties) {
|
||||
return new SpringCloudCustomProjectDocumentationUpdater(handler,
|
||||
releaserProperties);
|
||||
SpringCloudCustomProjectDocumentationUpdater springCloudCustomProjectDocumentationUpdater(ProjectGitHandler handler,
|
||||
ReleaserProperties releaserProperties) {
|
||||
return new SpringCloudCustomProjectDocumentationUpdater(handler, releaserProperties);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -25,8 +25,7 @@ import org.springframework.context.annotation.Configuration;
|
||||
class SpringCloudGithubConfiguration {
|
||||
|
||||
@Bean
|
||||
SpringCloudGithubIssues springCloudGithubIssues(
|
||||
ReleaserProperties releaserProperties) {
|
||||
SpringCloudGithubIssues springCloudGithubIssues(ReleaserProperties releaserProperties) {
|
||||
return new SpringCloudGithubIssues(releaserProperties);
|
||||
}
|
||||
|
||||
|
||||
@@ -47,16 +47,14 @@ class SpringCloudGithubIssues implements CustomGithubIssues {
|
||||
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));
|
||||
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));
|
||||
this.githubIssueFiler.fileAGitHubIssue(user, repo, version, issueTitle(), startSpringIoIssueText(projects));
|
||||
}
|
||||
|
||||
private String issueTitle() {
|
||||
@@ -72,21 +70,18 @@ class SpringCloudGithubIssues implements CustomGithubIssues {
|
||||
}
|
||||
|
||||
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 + "`]";
|
||||
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"));
|
||||
.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();
|
||||
}
|
||||
|
||||
|
||||
@@ -27,8 +27,7 @@ import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@SpringBootTest(
|
||||
classes = { ReleaserApplicationTests.Config.class, ReleaserApplication.class },
|
||||
@SpringBootTest(classes = { ReleaserApplicationTests.Config.class, ReleaserApplication.class },
|
||||
properties = { "releaser.sagan.update-sagan=false" })
|
||||
class ReleaserApplicationTests {
|
||||
|
||||
|
||||
@@ -32,17 +32,13 @@ public class SpringCloudReleaserProperties {
|
||||
|
||||
public static ReleaserProperties get() {
|
||||
try {
|
||||
File releaserConfig = new File(SpringCloudReleaserProperties.class
|
||||
.getResource("/application.yml").toURI());
|
||||
File releaserConfig = new File(SpringCloudReleaserProperties.class.getResource("/application.yml").toURI());
|
||||
YamlPropertiesFactoryBean yamlProcessor = new YamlPropertiesFactoryBean();
|
||||
yamlProcessor.setResources(new FileSystemResource(releaserConfig));
|
||||
Properties properties = yamlProcessor.getObject();
|
||||
ReleaserProperties releaserProperties = new Binder(
|
||||
new MapConfigurationPropertySource(properties.entrySet().stream()
|
||||
.collect(Collectors.toMap(e -> e.getKey().toString(),
|
||||
e -> e.getValue().toString()))))
|
||||
.bind("releaser", ReleaserProperties.class)
|
||||
.get();
|
||||
ReleaserProperties releaserProperties = new Binder(new MapConfigurationPropertySource(properties.entrySet()
|
||||
.stream().collect(Collectors.toMap(e -> e.getKey().toString(), e -> e.getValue().toString()))))
|
||||
.bind("releaser", ReleaserProperties.class).get();
|
||||
return releaserProperties;
|
||||
}
|
||||
catch (URISyntaxException e) {
|
||||
|
||||
@@ -37,80 +37,59 @@ public class SpringCloudCustomMavenBomTests {
|
||||
|
||||
@Test
|
||||
public void should_add_boot_to_versions_when_version_is_created() {
|
||||
List<CustomBomParser> bomParsers = Collections
|
||||
.singletonList(new SpringCloudMavenBomParser());
|
||||
List<CustomBomParser> bomParsers = Collections.singletonList(new SpringCloudMavenBomParser());
|
||||
VersionsFromBom customVersionsFromBom = new VersionsFromBomBuilder()
|
||||
.releaserProperties(SpringCloudReleaserProperties.get())
|
||||
.parsers(bomParsers).projects(springCloudBuildProjects())
|
||||
.retrieveFromBom();
|
||||
.releaserProperties(SpringCloudReleaserProperties.get()).parsers(bomParsers)
|
||||
.projects(springCloudBuildProjects()).retrieveFromBom();
|
||||
customVersionsFromBom.setVersion("spring-boot", "1.2.3.RELEASE");
|
||||
|
||||
then(customVersionsFromBom.versionForProject("spring-boot"))
|
||||
.isEqualTo("1.2.3.RELEASE");
|
||||
then(customVersionsFromBom.versionForProject("spring-boot-starter-parent"))
|
||||
.isEqualTo("1.2.3.RELEASE");
|
||||
then(customVersionsFromBom.versionForProject("spring-boot-dependencies"))
|
||||
.isEqualTo("1.2.3.RELEASE");
|
||||
then(customVersionsFromBom.versionForProject("spring-boot")).isEqualTo("1.2.3.RELEASE");
|
||||
then(customVersionsFromBom.versionForProject("spring-boot-starter-parent")).isEqualTo("1.2.3.RELEASE");
|
||||
then(customVersionsFromBom.versionForProject("spring-boot-dependencies")).isEqualTo("1.2.3.RELEASE");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_update_projects_for_boot() {
|
||||
VersionsFromBom versionsFromBom = mixedVersions().setVersion("spring-boot",
|
||||
"3.0.0");
|
||||
VersionsFromBom versionsFromBom = mixedVersions().setVersion("spring-boot", "3.0.0");
|
||||
|
||||
then(versionsFromBom.versionForProject("spring-boot")).isEqualTo("3.0.0");
|
||||
then(versionsFromBom.versionForProject("spring-boot-starter-parent"))
|
||||
.isEqualTo("3.0.0");
|
||||
then(versionsFromBom.versionForProject("spring-boot-dependencies"))
|
||||
.isEqualTo("3.0.0");
|
||||
then(versionsFromBom.versionForProject("spring-boot-starter-parent")).isEqualTo("3.0.0");
|
||||
then(versionsFromBom.versionForProject("spring-boot-dependencies")).isEqualTo("3.0.0");
|
||||
|
||||
versionsFromBom = mixedVersions().setVersion("spring-boot-starter-parent",
|
||||
"3.0.0");
|
||||
versionsFromBom = mixedVersions().setVersion("spring-boot-starter-parent", "3.0.0");
|
||||
|
||||
then(versionsFromBom.versionForProject("spring-boot")).isEqualTo("3.0.0");
|
||||
then(versionsFromBom.versionForProject("spring-boot-starter-parent"))
|
||||
.isEqualTo("3.0.0");
|
||||
then(versionsFromBom.versionForProject("spring-boot-dependencies"))
|
||||
.isEqualTo("3.0.0");
|
||||
then(versionsFromBom.versionForProject("spring-boot-starter-parent")).isEqualTo("3.0.0");
|
||||
then(versionsFromBom.versionForProject("spring-boot-dependencies")).isEqualTo("3.0.0");
|
||||
|
||||
versionsFromBom = mixedVersions().setVersion("spring-boot-dependencies", "3.0.0");
|
||||
|
||||
then(versionsFromBom.versionForProject("spring-boot")).isEqualTo("3.0.0");
|
||||
then(versionsFromBom.versionForProject("spring-boot-starter-parent"))
|
||||
.isEqualTo("3.0.0");
|
||||
then(versionsFromBom.versionForProject("spring-boot-dependencies"))
|
||||
.isEqualTo("3.0.0");
|
||||
then(versionsFromBom.versionForProject("spring-boot-starter-parent")).isEqualTo("3.0.0");
|
||||
then(versionsFromBom.versionForProject("spring-boot-dependencies")).isEqualTo("3.0.0");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_update_projects_for_build() {
|
||||
VersionsFromBom versionsFromBom = mixedVersions().setVersion("spring-cloud-build",
|
||||
"3.0.0");
|
||||
VersionsFromBom versionsFromBom = mixedVersions().setVersion("spring-cloud-build", "3.0.0");
|
||||
|
||||
then(versionsFromBom.versionForProject("spring-cloud-build")).isEqualTo("3.0.0");
|
||||
|
||||
versionsFromBom = mixedVersions().setVersion("spring-cloud-build", "3.0.0");
|
||||
|
||||
then(versionsFromBom.versionForProject("spring-cloud-dependencies-parent"))
|
||||
.isEqualTo("3.0.0");
|
||||
then(versionsFromBom.versionForProject("spring-cloud-dependencies"))
|
||||
.isEqualTo("Greenwich.RELEASE");
|
||||
then(versionsFromBom.versionForProject("spring-cloud-dependencies-parent")).isEqualTo("3.0.0");
|
||||
then(versionsFromBom.versionForProject("spring-cloud-dependencies")).isEqualTo("Greenwich.RELEASE");
|
||||
|
||||
versionsFromBom = mixedVersions().setVersion("spring-cloud-dependencies-parent",
|
||||
"3.0.0");
|
||||
versionsFromBom = mixedVersions().setVersion("spring-cloud-dependencies-parent", "3.0.0");
|
||||
|
||||
then(versionsFromBom.versionForProject("spring-cloud-build")).isEqualTo("3.0.0");
|
||||
then(versionsFromBom.versionForProject("spring-cloud-dependencies-parent"))
|
||||
.isEqualTo("3.0.0");
|
||||
then(versionsFromBom.versionForProject("spring-cloud-dependencies"))
|
||||
.isEqualTo("Greenwich.RELEASE");
|
||||
then(versionsFromBom.versionForProject("spring-cloud-dependencies-parent")).isEqualTo("3.0.0");
|
||||
then(versionsFromBom.versionForProject("spring-cloud-dependencies")).isEqualTo("Greenwich.RELEASE");
|
||||
}
|
||||
|
||||
private VersionsFromBom mixedVersions() {
|
||||
return new VersionsFromBomBuilder()
|
||||
.releaserProperties(SpringCloudReleaserProperties.get())
|
||||
.parsers(Collections.singletonList(new SpringCloudMavenBomParser()))
|
||||
.projects(mixedProjects()).merged();
|
||||
return new VersionsFromBomBuilder().releaserProperties(SpringCloudReleaserProperties.get())
|
||||
.parsers(Collections.singletonList(new SpringCloudMavenBomParser())).projects(mixedProjects()).merged();
|
||||
}
|
||||
|
||||
Set<Project> springCloudBuildProjects() {
|
||||
|
||||
@@ -57,31 +57,26 @@ public class SpringCloudMavenBomParserTests {
|
||||
this.tmpFolder = this.tmp.newFolder();
|
||||
TestUtils.prepareLocalRepo();
|
||||
FileSystemUtils.copyRecursively(file("/projects"), this.tmpFolder);
|
||||
this.springCloudReleaseProject = new File(this.tmpFolder,
|
||||
"/spring-cloud-release");
|
||||
this.springCloudReleaseProject = new File(this.tmpFolder, "/spring-cloud-release");
|
||||
}
|
||||
|
||||
private File file(String relativePath) throws URISyntaxException {
|
||||
return new File(
|
||||
SpringCloudMavenBomParserTests.class.getResource(relativePath).toURI());
|
||||
return new File(SpringCloudMavenBomParserTests.class.getResource(relativePath).toURI());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_throw_exception_when_null_is_passed_to_boot() {
|
||||
this.properties.getPom().setPomWithBootStarterParent(null);
|
||||
this.properties.getPom().setThisTrainBom(null);
|
||||
BomParser parser = MavenBomParserAccessor.bomParser(this.properties,
|
||||
new SpringCloudMavenBomParser());
|
||||
BomParser parser = MavenBomParserAccessor.bomParser(this.properties, new SpringCloudMavenBomParser());
|
||||
|
||||
thenThrownBy(() -> parser.versionsFromBom(this.springCloudReleaseProject))
|
||||
.isInstanceOf(IllegalStateException.class)
|
||||
.hasMessageContaining("Pom is not present");
|
||||
.isInstanceOf(IllegalStateException.class).hasMessageContaining("Pom is not present");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_populate_sc_release_version() {
|
||||
BomParser parser = MavenBomParserAccessor.bomParser(this.properties,
|
||||
new SpringCloudMavenBomParser());
|
||||
BomParser parser = MavenBomParserAccessor.bomParser(this.properties, new SpringCloudMavenBomParser());
|
||||
|
||||
String scReleaseVersion = parser.versionsFromBom(this.springCloudReleaseProject)
|
||||
.versionForProject("spring-cloud-release");
|
||||
@@ -91,22 +86,18 @@ public class SpringCloudMavenBomParserTests {
|
||||
|
||||
@Test
|
||||
public void should_populate_boot_version() {
|
||||
BomParser parser = MavenBomParserAccessor.bomParser(this.properties,
|
||||
new SpringCloudMavenBomParser());
|
||||
BomParser parser = MavenBomParserAccessor.bomParser(this.properties, new SpringCloudMavenBomParser());
|
||||
|
||||
String bootVersion = parser.versionsFromBom(this.springCloudReleaseProject)
|
||||
.versionForProject("spring-boot");
|
||||
String bootVersion = parser.versionsFromBom(this.springCloudReleaseProject).versionForProject("spring-boot");
|
||||
|
||||
then(bootVersion).isNotBlank();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_throw_exception_when_cloud_pom_is_missing() {
|
||||
BomParser parser = MavenBomParserAccessor.bomParser(this.properties,
|
||||
new SpringCloudMavenBomParser());
|
||||
BomParser parser = MavenBomParserAccessor.bomParser(this.properties, new SpringCloudMavenBomParser());
|
||||
|
||||
thenThrownBy(() -> parser.versionsFromBom(new File(".")))
|
||||
.isInstanceOf(IllegalStateException.class)
|
||||
thenThrownBy(() -> parser.versionsFromBom(new File("."))).isInstanceOf(IllegalStateException.class)
|
||||
.hasMessageContaining("Pom is not present");
|
||||
}
|
||||
|
||||
@@ -114,54 +105,44 @@ public class SpringCloudMavenBomParserTests {
|
||||
public void should_throw_exception_when_null_is_passed_to_cloud() {
|
||||
this.properties.getPom().setPomWithBootStarterParent(null);
|
||||
this.properties.getPom().setThisTrainBom(null);
|
||||
BomParser parser = MavenBomParserAccessor.bomParser(this.properties,
|
||||
new SpringCloudMavenBomParser());
|
||||
BomParser parser = MavenBomParserAccessor.bomParser(this.properties, new SpringCloudMavenBomParser());
|
||||
|
||||
thenThrownBy(() -> parser.versionsFromBom(this.springCloudReleaseProject))
|
||||
.isInstanceOf(IllegalStateException.class)
|
||||
.hasMessageContaining("Pom is not present");
|
||||
.isInstanceOf(IllegalStateException.class).hasMessageContaining("Pom is not present");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_throw_exception_when_cloud_version_is_missing_in_pom() {
|
||||
this.properties.getPom().setPomWithBootStarterParent("pom.xml");
|
||||
this.properties.getPom().setThisTrainBom("pom.xml");
|
||||
BomParser parser = MavenBomParserAccessor.bomParser(this.properties,
|
||||
new SpringCloudMavenBomParser());
|
||||
BomParser parser = MavenBomParserAccessor.bomParser(this.properties, new SpringCloudMavenBomParser());
|
||||
|
||||
thenThrownBy(() -> parser.versionsFromBom(this.springCloudReleaseProject))
|
||||
.isInstanceOf(IllegalStateException.class).hasMessageContaining(
|
||||
"The pom doesn't have a [spring-cloud-dependencies-parent] artifact id");
|
||||
.isInstanceOf(IllegalStateException.class)
|
||||
.hasMessageContaining("The pom doesn't have a [spring-cloud-dependencies-parent] artifact id");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_populate_cloud_version() {
|
||||
BomParser parser = MavenBomParserAccessor.bomParser(this.properties,
|
||||
new SpringCloudMavenBomParser());
|
||||
BomParser parser = MavenBomParserAccessor.bomParser(this.properties, new SpringCloudMavenBomParser());
|
||||
|
||||
VersionsFromBom cloudVersionsFromBom = parser
|
||||
.versionsFromBom(this.springCloudReleaseProject);
|
||||
VersionsFromBom cloudVersionsFromBom = parser.versionsFromBom(this.springCloudReleaseProject);
|
||||
|
||||
thenAllCloudVersionsSet(cloudVersionsFromBom);
|
||||
}
|
||||
|
||||
private void thenAllCloudVersionsSet(VersionsFromBom cloudVersionsFromBom) {
|
||||
Arrays.asList("spring-cloud-bus", "spring-cloud-contract",
|
||||
"spring-cloud-cloudfoundry", "spring-cloud-commons",
|
||||
"spring-cloud-config", "spring-cloud-netflix", "spring-cloud-security",
|
||||
"spring-cloud-consul", "spring-cloud-sleuth", "spring-cloud-stream",
|
||||
"spring-cloud-task", "spring-cloud-vault", "spring-cloud-zookeeper")
|
||||
.forEach(s -> then(cloudVersionsFromBom.versionForProject(s))
|
||||
.isNotBlank());
|
||||
Arrays.asList("spring-cloud-bus", "spring-cloud-contract", "spring-cloud-cloudfoundry", "spring-cloud-commons",
|
||||
"spring-cloud-config", "spring-cloud-netflix", "spring-cloud-security", "spring-cloud-consul",
|
||||
"spring-cloud-sleuth", "spring-cloud-stream", "spring-cloud-task", "spring-cloud-vault",
|
||||
"spring-cloud-zookeeper").forEach(s -> then(cloudVersionsFromBom.versionForProject(s)).isNotBlank());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_populate_boot_and_cloud_version() {
|
||||
BomParser parser = MavenBomParserAccessor.bomParser(this.properties,
|
||||
new SpringCloudMavenBomParser());
|
||||
BomParser parser = MavenBomParserAccessor.bomParser(this.properties, new SpringCloudMavenBomParser());
|
||||
|
||||
VersionsFromBom cloudVersionsFromBom = parser
|
||||
.versionsFromBom(this.springCloudReleaseProject);
|
||||
VersionsFromBom cloudVersionsFromBom = parser.versionsFromBom(this.springCloudReleaseProject);
|
||||
|
||||
then(cloudVersionsFromBom.versionForProject("spring-boot")).isNotBlank();
|
||||
then(cloudVersionsFromBom.versionForProject("spring-cloud-build")).isNotBlank();
|
||||
|
||||
@@ -36,41 +36,31 @@ public class SpringCloudProjectPomUpdaterTests {
|
||||
public void should_convert_fixed_versions_to_updated_fixed_versions() {
|
||||
ReleaserProperties properties = SpringCloudReleaserProperties.get();
|
||||
properties.getFixedVersions().put("spring-cloud-task", "2.0.0.RELEASE");
|
||||
properties.getFixedVersions().put("spring-cloud-openfeign",
|
||||
"2.0.1.BUILD-SNAPSHOT");
|
||||
properties.getFixedVersions().put("spring-cloud-openfeign", "2.0.1.BUILD-SNAPSHOT");
|
||||
properties.getFixedVersions().put("spring-cloud-consul", "2.0.1.BUILD-SNAPSHOT");
|
||||
properties.getFixedVersions().put("spring-cloud-zookeeper",
|
||||
"2.0.1.BUILD-SNAPSHOT");
|
||||
properties.getFixedVersions().put("spring-cloud-zookeeper", "2.0.1.BUILD-SNAPSHOT");
|
||||
properties.getFixedVersions().put("spring-cloud-stream", "Elmhurst.RELEASE");
|
||||
properties.getFixedVersions().put("spring-cloud-config", "2.0.1.BUILD-SNAPSHOT");
|
||||
properties.getFixedVersions().put("spring-cloud-cloudfoundry",
|
||||
"2.0.1.BUILD-SNAPSHOT");
|
||||
properties.getFixedVersions().put("spring-cloud-cloudfoundry", "2.0.1.BUILD-SNAPSHOT");
|
||||
properties.getFixedVersions().put("spring-cloud-netflix", "2.0.1.BUILD-SNAPSHOT");
|
||||
properties.getFixedVersions().put("spring-cloud-vault", "2.0.1.BUILD-SNAPSHOT");
|
||||
properties.getFixedVersions().put("spring-cloud-security",
|
||||
"2.0.1.BUILD-SNAPSHOT");
|
||||
properties.getFixedVersions().put("spring-cloud-security", "2.0.1.BUILD-SNAPSHOT");
|
||||
properties.getFixedVersions().put("spring-cloud-commons", "2.0.1.BUILD-SNAPSHOT");
|
||||
properties.getFixedVersions().put("spring-cloud-sleuth", "2.0.1.BUILD-SNAPSHOT");
|
||||
properties.getFixedVersions().put("spring-cloud-aws", "2.0.1.BUILD-SNAPSHOT");
|
||||
properties.getFixedVersions().put("spring-cloud-contract",
|
||||
"2.0.1.BUILD-SNAPSHOT");
|
||||
properties.getFixedVersions().put("spring-cloud-release",
|
||||
"Finchley.BUILD-SNAPSHOT");
|
||||
properties.getFixedVersions().put("spring-cloud-contract", "2.0.1.BUILD-SNAPSHOT");
|
||||
properties.getFixedVersions().put("spring-cloud-release", "Finchley.BUILD-SNAPSHOT");
|
||||
properties.getFixedVersions().put("spring-cloud-build", "2.0.3.BUILD-SNAPSHOT");
|
||||
properties.getFixedVersions().put("spring-cloud-bus", "2.0.1.BUILD-SNAPSHOT");
|
||||
properties.getFixedVersions().put("spring-cloud-function",
|
||||
"1.0.0.BUILD-SNAPSHOT");
|
||||
properties.getFixedVersions().put("spring-cloud-starter-build",
|
||||
"Finchley.BUILD-SNAPSHOT");
|
||||
properties.getFixedVersions().put("spring-cloud-function", "1.0.0.BUILD-SNAPSHOT");
|
||||
properties.getFixedVersions().put("spring-cloud-starter-build", "Finchley.BUILD-SNAPSHOT");
|
||||
properties.getFixedVersions().put("spring-boot", "2.0.3.RELEASE");
|
||||
properties.getFixedVersions().put("spring-cloud-gateway", "2.0.1.BUILD-SNAPSHOT");
|
||||
ProjectPomUpdater updater = new ProjectPomUpdater(properties,
|
||||
Collections.singletonList(MavenBomParserAccessor.bomParser(properties,
|
||||
new SpringCloudMavenBomParser())));
|
||||
ProjectPomUpdater updater = new ProjectPomUpdater(properties, Collections
|
||||
.singletonList(MavenBomParserAccessor.bomParser(properties, new SpringCloudMavenBomParser())));
|
||||
|
||||
Map<String, String> fixedVersions = updater.fixedVersions().stream()
|
||||
.collect(Collectors.toMap(projectVersion -> projectVersion.projectName,
|
||||
projectVersion -> projectVersion.version));
|
||||
Map<String, String> fixedVersions = updater.fixedVersions().stream().collect(Collectors
|
||||
.toMap(projectVersion -> projectVersion.projectName, projectVersion -> projectVersion.version));
|
||||
|
||||
BDDAssertions.then(fixedVersions).containsEntry("spring-boot", "2.0.3.RELEASE")
|
||||
.containsEntry("spring-boot-dependencies", "2.0.3.RELEASE")
|
||||
|
||||
@@ -70,23 +70,17 @@ public class SpringCloudCustomProjectDocumentationUpdaterTests {
|
||||
.getResource("/projects/spring-cloud-static").toURI());
|
||||
TestUtils.prepareLocalRepo();
|
||||
FileSystemUtils.copyRecursively(file("/projects"), this.tmpFolder);
|
||||
this.properties.getGit().setDocumentationUrl(
|
||||
file("/projects/spring-cloud-static/").toURI().toString());
|
||||
this.properties.getGit().setDocumentationUrl(file("/projects/spring-cloud-static/").toURI().toString());
|
||||
this.handler = new ProjectGitHandler(this.properties);
|
||||
this.clonedDocProject = this.handler.cloneDocumentationProject();
|
||||
this.gitHubHandler = new ProjectGitHubHandler(this.properties,
|
||||
Collections.singletonList(
|
||||
SpringCloudGithubIssuesAccessor.springCloud(this.properties)));
|
||||
Collections.singletonList(SpringCloudGithubIssuesAccessor.springCloud(this.properties)));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private DocumentationUpdater projectDocumentationUpdater(
|
||||
ReleaserProperties properties) {
|
||||
return new DocumentationUpdater(this.handler, properties,
|
||||
templateGenerator(properties),
|
||||
Collections.singletonList(
|
||||
new SpringCloudCustomProjectDocumentationUpdater(this.handler,
|
||||
properties)));
|
||||
private DocumentationUpdater projectDocumentationUpdater(ReleaserProperties properties) {
|
||||
return new DocumentationUpdater(this.handler, properties, templateGenerator(properties),
|
||||
Collections.singletonList(new SpringCloudCustomProjectDocumentationUpdater(this.handler, properties)));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -97,56 +91,43 @@ public class SpringCloudCustomProjectDocumentationUpdaterTests {
|
||||
@Test
|
||||
public void should_not_update_current_version_in_the_docs_if_current_release_starts_with_v_and_then_lower_letter_than_the_stored_release()
|
||||
throws URISyntaxException, IOException {
|
||||
ProjectVersion releaseTrainVersion = new ProjectVersion("spring-cloud-release",
|
||||
"Finchley.SR33");
|
||||
ProjectVersion releaseTrainVersion = new ProjectVersion("spring-cloud-release", "Finchley.SR33");
|
||||
ReleaserProperties properties = new ReleaserProperties();
|
||||
properties.getGit().setDocumentationUrl(
|
||||
file("/projects/spring-cloud-static/").toURI().toString());
|
||||
properties.getGit().setDocumentationUrl(file("/projects/spring-cloud-static/").toURI().toString());
|
||||
|
||||
File updatedDocs = new SpringCloudCustomProjectDocumentationUpdater(
|
||||
new ProjectGitHandler(properties), properties)
|
||||
.updateDocsRepoForReleaseTrain(this.clonedDocProject,
|
||||
releaseTrainVersion, projects(), "vFinchley.SR33");
|
||||
File updatedDocs = new SpringCloudCustomProjectDocumentationUpdater(new ProjectGitHandler(properties),
|
||||
properties).updateDocsRepoForReleaseTrain(this.clonedDocProject, releaseTrainVersion, projects(),
|
||||
"vFinchley.SR33");
|
||||
|
||||
BDDAssertions.then(new File(updatedDocs, "current/index.html").toPath())
|
||||
.doesNotExist();
|
||||
BDDAssertions.then(new File(updatedDocs, "current/index.html").toPath()).doesNotExist();
|
||||
Path current = new File(updatedDocs, "current/").toPath();
|
||||
BDDAssertions.then(current).isSymbolicLink();
|
||||
BDDAssertions.then(Files.readSymbolicLink(current).toString())
|
||||
.isEqualTo("Finchley.SR33");
|
||||
BDDAssertions.then(Files.readSymbolicLink(current).toString()).isEqualTo("Finchley.SR33");
|
||||
|
||||
releaseTrainVersion = new ProjectVersion("spring-cloud-release", "Angel.SR33");
|
||||
properties = new ReleaserProperties();
|
||||
properties.getGit().setDocumentationUrl(
|
||||
file("/projects/spring-cloud-static/").toURI().toString());
|
||||
properties.getGit().setDocumentationUrl(file("/projects/spring-cloud-static/").toURI().toString());
|
||||
|
||||
updatedDocs = new SpringCloudCustomProjectDocumentationUpdater(
|
||||
new ProjectGitHandler(properties), properties)
|
||||
.updateDocsRepoForReleaseTrain(this.clonedDocProject,
|
||||
releaseTrainVersion, projects(), "vAngel.SR33");
|
||||
updatedDocs = new SpringCloudCustomProjectDocumentationUpdater(new ProjectGitHandler(properties), properties)
|
||||
.updateDocsRepoForReleaseTrain(this.clonedDocProject, releaseTrainVersion, projects(), "vAngel.SR33");
|
||||
|
||||
BDDAssertions.then(new File(updatedDocs, "current/index.html").toPath())
|
||||
.doesNotExist();
|
||||
BDDAssertions.then(new File(updatedDocs, "current/index.html").toPath()).doesNotExist();
|
||||
current = new File(updatedDocs, "current/").toPath();
|
||||
BDDAssertions.then(current).isSymbolicLink();
|
||||
BDDAssertions.then(Files.readSymbolicLink(current).toString())
|
||||
.isNotEqualTo("Angel.SR33");
|
||||
BDDAssertions.then(Files.readSymbolicLink(current).toString()).isNotEqualTo("Angel.SR33");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_not_commit_if_the_same_version_is_already_there() {
|
||||
ProjectVersion releaseTrainVersion = new ProjectVersion("spring-cloud-release",
|
||||
"Dalston.SR3");
|
||||
ProjectVersion releaseTrainVersion = new ProjectVersion("spring-cloud-release", "Dalston.SR3");
|
||||
ReleaserProperties properties = new ReleaserProperties();
|
||||
properties.getGit().setDocumentationUrl(this.clonedDocProject.toURI().toString());
|
||||
ProjectGitHandler handler = BDDMockito.spy(new ProjectGitHandler(properties));
|
||||
|
||||
new SpringCloudCustomProjectDocumentationUpdater(handler, properties)
|
||||
.updateDocsRepoForReleaseTrain(this.clonedDocProject, releaseTrainVersion,
|
||||
projects(), "vDalston.SR3");
|
||||
.updateDocsRepoForReleaseTrain(this.clonedDocProject, releaseTrainVersion, projects(), "vDalston.SR3");
|
||||
|
||||
BDDMockito.then(handler).should(BDDMockito.never())
|
||||
.commit(BDDMockito.any(File.class), BDDMockito.anyString());
|
||||
BDDMockito.then(handler).should(BDDMockito.never()).commit(BDDMockito.any(File.class), BDDMockito.anyString());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -157,11 +138,9 @@ public class SpringCloudCustomProjectDocumentationUpdaterTests {
|
||||
ProjectGitHandler handler = BDDMockito.spy(new ProjectGitHandler(properties));
|
||||
|
||||
new SpringCloudCustomProjectDocumentationUpdater(handler, properties)
|
||||
.updateDocsRepoForReleaseTrain(this.clonedDocProject, springBootVersion,
|
||||
bootProject(), "vDalston.SR3");
|
||||
.updateDocsRepoForReleaseTrain(this.clonedDocProject, springBootVersion, bootProject(), "vDalston.SR3");
|
||||
|
||||
BDDMockito.then(handler).should(BDDMockito.never())
|
||||
.commit(BDDMockito.any(File.class), BDDMockito.anyString());
|
||||
BDDMockito.then(handler).should(BDDMockito.never()).commit(BDDMockito.any(File.class), BDDMockito.anyString());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -172,37 +151,30 @@ public class SpringCloudCustomProjectDocumentationUpdaterTests {
|
||||
ProjectGitHandler handler = BDDMockito.spy(new ProjectGitHandler(properties));
|
||||
|
||||
new SpringCloudCustomProjectDocumentationUpdater(handler, properties)
|
||||
.updateDocsRepoForSingleProject(this.clonedDocProject, springBootVersion,
|
||||
bootProject());
|
||||
.updateDocsRepoForSingleProject(this.clonedDocProject, springBootVersion, bootProject());
|
||||
|
||||
BDDMockito.then(handler).should(BDDMockito.never())
|
||||
.commit(BDDMockito.any(File.class), BDDMockito.anyString());
|
||||
BDDMockito.then(handler).should(BDDMockito.never()).commit(BDDMockito.any(File.class), BDDMockito.anyString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_not_update_current_version_in_the_docs_if_current_release_starts_with_lower_letter_than_the_stored_release()
|
||||
throws IOException {
|
||||
ProjectVersion releaseTrainVersion = new ProjectVersion("spring-cloud-release",
|
||||
"Angel.SR33");
|
||||
ProjectVersion releaseTrainVersion = new ProjectVersion("spring-cloud-release", "Angel.SR33");
|
||||
ReleaserProperties properties = new ReleaserProperties();
|
||||
properties.getGit().setDocumentationUrl(this.clonedDocProject.toURI().toString());
|
||||
|
||||
File updatedDocs = new SpringCloudCustomProjectDocumentationUpdater(
|
||||
new ProjectGitHandler(properties), properties)
|
||||
.updateDocsRepoForReleaseTrain(this.clonedDocProject,
|
||||
releaseTrainVersion, projects(), "Angel.SR33");
|
||||
File updatedDocs = new SpringCloudCustomProjectDocumentationUpdater(new ProjectGitHandler(properties),
|
||||
properties).updateDocsRepoForReleaseTrain(this.clonedDocProject, releaseTrainVersion, projects(),
|
||||
"Angel.SR33");
|
||||
|
||||
BDDAssertions.then(new File(updatedDocs, "current/index.html").toPath())
|
||||
.doesNotExist();
|
||||
BDDAssertions.then(new File(updatedDocs, "current/index.html").toPath()).doesNotExist();
|
||||
Path current = new File(updatedDocs, "current/").toPath();
|
||||
BDDAssertions.then(current).isSymbolicLink();
|
||||
BDDAssertions.then(Files.readSymbolicLink(current).toString())
|
||||
.isNotEqualTo("Angel.SR33");
|
||||
BDDAssertions.then(Files.readSymbolicLink(current).toString()).isNotEqualTo("Angel.SR33");
|
||||
}
|
||||
|
||||
private File file(String relativePath) throws URISyntaxException {
|
||||
return new File(SpringCloudCustomProjectDocumentationUpdater.class
|
||||
.getResource(relativePath).toURI());
|
||||
return new File(SpringCloudCustomProjectDocumentationUpdater.class.getResource(relativePath).toURI());
|
||||
}
|
||||
|
||||
private Projects projects() {
|
||||
|
||||
@@ -36,8 +36,7 @@ public final class TestUtils {
|
||||
prepareLocalRepo("target/test-classes/projects/", "spring-cloud-static");
|
||||
}
|
||||
|
||||
private static void prepareLocalRepo(String buildDir, String repoPath)
|
||||
throws IOException {
|
||||
private static void prepareLocalRepo(String buildDir, String repoPath) throws IOException {
|
||||
File dotGit = new File(buildDir + repoPath + "/.git");
|
||||
File git = new File(buildDir + repoPath + "/git");
|
||||
if (git.exists()) {
|
||||
|
||||
@@ -22,8 +22,7 @@ import releaser.internal.github.CustomGithubIssues;
|
||||
|
||||
public class SpringCloudGithubIssuesAccessor {
|
||||
|
||||
public static CustomGithubIssues springCloud(Github github,
|
||||
ReleaserProperties releaserProperties) {
|
||||
public static CustomGithubIssues springCloud(Github github, ReleaserProperties releaserProperties) {
|
||||
return new SpringCloudGithubIssues(github, releaserProperties);
|
||||
}
|
||||
|
||||
|
||||
@@ -74,14 +74,12 @@ public class SpringCloudGithubIssuesTests {
|
||||
Github github = BDDMockito.mock(Github.class);
|
||||
CustomGithubIssues githubIssues = new SpringCloudGithubIssues(github, properties);
|
||||
|
||||
githubIssues
|
||||
.fileIssueInSpringGuides(
|
||||
new Projects(new ProjectVersion("foo", "1.0.0.BUILD-SNAPSHOT"),
|
||||
new ProjectVersion("spring-cloud-build",
|
||||
"2.0.0.BUILD-SNAPSHOT")),
|
||||
new ProjectVersion("sc-release", "Edgware.BUILD-SNAPSHOT"));
|
||||
githubIssues.fileIssueInSpringGuides(
|
||||
new Projects(new ProjectVersion("foo", "1.0.0.BUILD-SNAPSHOT"),
|
||||
new ProjectVersion("spring-cloud-build", "2.0.0.BUILD-SNAPSHOT")),
|
||||
new ProjectVersion("sc-release", "Edgware.BUILD-SNAPSHOT"));
|
||||
|
||||
BDDMockito.then(github).shouldHaveZeroInteractions();
|
||||
BDDMockito.then(github).shouldHaveNoInteractions();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -92,20 +90,18 @@ public class SpringCloudGithubIssuesTests {
|
||||
issues.fileIssueInSpringGuides(
|
||||
new Projects(new ProjectVersion("spring-cloud-foo", "1.0.0.RELEASE"),
|
||||
new ProjectVersion("spring-cloud-build", "2.0.0.RELEASE"),
|
||||
new ProjectVersion("bar", "2.0.0.RELEASE"),
|
||||
new ProjectVersion("baz", "3.0.0.RELEASE")),
|
||||
new ProjectVersion("bar", "2.0.0.RELEASE"), new ProjectVersion("baz", "3.0.0.RELEASE")),
|
||||
new ProjectVersion("sc-release", "Edgware.RELEASE"));
|
||||
|
||||
Issue issue = this.github.repos()
|
||||
.get(new Coordinates.Simple("spring-guides", "getting-started-guides"))
|
||||
Issue issue = this.github.repos().get(new Coordinates.Simple("spring-guides", "getting-started-guides"))
|
||||
.issues().get(1);
|
||||
then(issue.exists()).isTrue();
|
||||
Issue.Smart smartIssue = new Issue.Smart(issue);
|
||||
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("spring-cloud-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
|
||||
@@ -114,16 +110,13 @@ public class SpringCloudGithubIssuesTests {
|
||||
CustomGithubIssues issues = new SpringCloudGithubIssues(github, properties);
|
||||
|
||||
thenThrownBy(() -> issues.fileIssueInSpringGuides(
|
||||
new Projects(Collections.singletonList(
|
||||
new ProjectVersion("spring-cloud-build", "2.0.0.RELEASE"))),
|
||||
nonGaSleuthProject())).isInstanceOf(IllegalArgumentException.class)
|
||||
.hasMessageContaining(
|
||||
"You have to pass Github OAuth token for milestone closing to be operational");
|
||||
new Projects(Collections.singletonList(new ProjectVersion("spring-cloud-build", "2.0.0.RELEASE"))),
|
||||
nonGaSleuthProject())).isInstanceOf(IllegalArgumentException.class).hasMessageContaining(
|
||||
"You have to pass Github OAuth token for milestone closing to be operational");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_not_do_anything_for_non_release_train_version_when_updating_startspringio()
|
||||
throws IOException {
|
||||
public void should_not_do_anything_for_non_release_train_version_when_updating_startspringio() throws IOException {
|
||||
setupStartSpringIo();
|
||||
Github github = BDDMockito.mock(Github.class);
|
||||
CustomGithubIssues issues = new SpringCloudGithubIssues(github, properties);
|
||||
@@ -133,27 +126,21 @@ public class SpringCloudGithubIssuesTests {
|
||||
new ProjectVersion("spring-cloud-build", "2.0.0.RELEASE")),
|
||||
new ProjectVersion("sc-release", "Edgware.BUILD-SNAPSHOT"));
|
||||
|
||||
BDDMockito.then(github).shouldHaveZeroInteractions();
|
||||
BDDMockito.then(github).shouldHaveNoInteractions();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_file_an_issue_for_release_version_when_updating_startspringio()
|
||||
throws IOException {
|
||||
public void should_file_an_issue_for_release_version_when_updating_startspringio() throws IOException {
|
||||
setupStartSpringIo();
|
||||
CustomGithubIssues issues = new SpringCloudGithubIssues(github, properties);
|
||||
properties.getPom().setBranch("vEdgware.RELEASE");
|
||||
|
||||
issues.fileIssueInStartSpringIo(
|
||||
new Projects(new ProjectVersion("spring-cloud-foo", "1.0.0.RELEASE"),
|
||||
new ProjectVersion("spring-cloud-build", "2.0.0.RELEASE"),
|
||||
new ProjectVersion("bar", "2.0.0.RELEASE"),
|
||||
new ProjectVersion("baz", "3.0.0.RELEASE"),
|
||||
new ProjectVersion("spring-boot", "1.2.3.RELEASE")),
|
||||
issues.fileIssueInStartSpringIo(new Projects(new ProjectVersion("spring-cloud-foo", "1.0.0.RELEASE"),
|
||||
new ProjectVersion("spring-cloud-build", "2.0.0.RELEASE"), new ProjectVersion("bar", "2.0.0.RELEASE"),
|
||||
new ProjectVersion("baz", "3.0.0.RELEASE"), new ProjectVersion("spring-boot", "1.2.3.RELEASE")),
|
||||
new ProjectVersion("sc-release", "Edgware.RELEASE"));
|
||||
|
||||
Issue issue = this.github.repos()
|
||||
.get(new Coordinates.Simple("spring-io", "start.spring.io")).issues()
|
||||
.get(1);
|
||||
Issue issue = this.github.repos().get(new Coordinates.Simple("spring-io", "start.spring.io")).issues().get(1);
|
||||
then(issue.exists()).isTrue();
|
||||
Issue.Smart smartIssue = new Issue.Smart(issue);
|
||||
then(smartIssue.title()).isEqualTo("Upgrade to Spring Cloud Edgware.RELEASE");
|
||||
@@ -162,23 +149,19 @@ public class SpringCloudGithubIssuesTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_throw_exception_when_no_token_was_passed_when_updating_startspringio()
|
||||
throws IOException {
|
||||
public void should_throw_exception_when_no_token_was_passed_when_updating_startspringio() throws IOException {
|
||||
setupStartSpringIo();
|
||||
properties.getGit().setOauthToken("");
|
||||
CustomGithubIssues issues = new SpringCloudGithubIssues(github, properties);
|
||||
|
||||
thenThrownBy(() -> issues.fileIssueInStartSpringIo(
|
||||
new Projects(Collections.singletonList(
|
||||
new ProjectVersion("spring-cloud-build", "2.0.0.RELEASE"))),
|
||||
nonGaSleuthProject())).isInstanceOf(IllegalArgumentException.class)
|
||||
.hasMessageContaining(
|
||||
"You have to pass Github OAuth token for milestone closing to be operational");
|
||||
new Projects(Collections.singletonList(new ProjectVersion("spring-cloud-build", "2.0.0.RELEASE"))),
|
||||
nonGaSleuthProject())).isInstanceOf(IllegalArgumentException.class).hasMessageContaining(
|
||||
"You have to pass Github OAuth token for milestone closing to be operational");
|
||||
}
|
||||
|
||||
private Repo createGettingStartedGuides(MkGithub github) throws IOException {
|
||||
return github.repos()
|
||||
.create(new Repos.RepoCreate("getting-started-guides", false));
|
||||
return github.repos().create(new Repos.RepoCreate("getting-started-guides", false));
|
||||
}
|
||||
|
||||
private Repo createStartSpringIo(MkGithub github) throws IOException {
|
||||
|
||||
@@ -36,10 +36,10 @@ public class AbstractSpringCloudAcceptanceTests extends AbstractSpringAcceptance
|
||||
@Before
|
||||
public void setupCloud() throws Exception {
|
||||
this.temporaryFolder = this.tmp.newFolder();
|
||||
this.springCloudConsulProject = new File(AbstractSpringAcceptanceTests.class
|
||||
.getResource("/projects/spring-cloud-consul").toURI());
|
||||
this.springCloudBuildProject = new File(AbstractSpringAcceptanceTests.class
|
||||
.getResource("/projects/spring-cloud-build").toURI());
|
||||
this.springCloudConsulProject = new File(
|
||||
AbstractSpringAcceptanceTests.class.getResource("/projects/spring-cloud-consul").toURI());
|
||||
this.springCloudBuildProject = new File(
|
||||
AbstractSpringAcceptanceTests.class.getResource("/projects/spring-cloud-build").toURI());
|
||||
TestUtils.prepareLocalRepo();
|
||||
FileSystemUtils.copyRecursively(file("/projects/"), this.temporaryFolder);
|
||||
}
|
||||
@@ -51,12 +51,9 @@ public class AbstractSpringCloudAcceptanceTests extends AbstractSpringAcceptance
|
||||
public void thenAllDryRunStepsWereExecutedForEachProject(
|
||||
NonAssertingTestProjectGitHandler nonAssertingTestProjectGitHandler) {
|
||||
nonAssertingTestProjectGitHandler.clonedProjects.stream()
|
||||
.filter(f -> !f.getName().contains("angel")
|
||||
&& !f.getName().equals("spring-cloud"))
|
||||
.forEach(project -> {
|
||||
then(Arrays.asList("spring-cloud-starter-build",
|
||||
"spring-cloud-consul"))
|
||||
.contains(pom(project).getArtifactId());
|
||||
.filter(f -> !f.getName().contains("angel") && !f.getName().equals("spring-cloud")).forEach(project -> {
|
||||
then(Arrays.asList("spring-cloud-starter-build", "spring-cloud-consul"))
|
||||
.contains(pom(project).getArtifactId());
|
||||
then(new File("/tmp/executed_build")).exists();
|
||||
then(new File("/tmp/executed_deploy")).doesNotExist();
|
||||
then(new File("/tmp/executed_docs")).doesNotExist();
|
||||
|
||||
@@ -24,8 +24,7 @@ import releaser.internal.spring.meta.AbstractSpringMetaReleaseAcceptanceTests;
|
||||
|
||||
import static org.assertj.core.api.BDDAssertions.then;
|
||||
|
||||
public class AbstractSpringCloudMetaAcceptanceTests
|
||||
extends AbstractSpringMetaReleaseAcceptanceTests {
|
||||
public class AbstractSpringCloudMetaAcceptanceTests extends AbstractSpringMetaReleaseAcceptanceTests {
|
||||
|
||||
public File springCloudConsulProject;
|
||||
|
||||
@@ -34,11 +33,9 @@ public class AbstractSpringCloudMetaAcceptanceTests
|
||||
@Before
|
||||
public void setupCloud() throws Exception {
|
||||
this.springCloudConsulProject = new File(
|
||||
AbstractSpringCloudMetaAcceptanceTests.class
|
||||
.getResource("/projects/spring-cloud-consul").toURI());
|
||||
AbstractSpringCloudMetaAcceptanceTests.class.getResource("/projects/spring-cloud-consul").toURI());
|
||||
this.springCloudBuildProject = new File(
|
||||
AbstractSpringCloudMetaAcceptanceTests.class
|
||||
.getResource("/projects/spring-cloud-build").toURI());
|
||||
AbstractSpringCloudMetaAcceptanceTests.class.getResource("/projects/spring-cloud-build").toURI());
|
||||
}
|
||||
|
||||
public void consulPomParentVersionIsEqualTo(File project, String expected) {
|
||||
@@ -48,12 +45,9 @@ public class AbstractSpringCloudMetaAcceptanceTests
|
||||
public void thenAllDryRunStepsWereExecutedForEachProject(
|
||||
NonAssertingTestProjectGitHandler nonAssertingTestProjectGitHandler) {
|
||||
nonAssertingTestProjectGitHandler.clonedProjects.stream()
|
||||
.filter(f -> !f.getName().contains("angel")
|
||||
&& !f.getName().equals("spring-cloud"))
|
||||
.forEach(project -> {
|
||||
then(Arrays.asList("spring-cloud-starter-build",
|
||||
"spring-cloud-consul"))
|
||||
.contains(pom(project).getArtifactId());
|
||||
.filter(f -> !f.getName().contains("angel") && !f.getName().equals("spring-cloud")).forEach(project -> {
|
||||
then(Arrays.asList("spring-cloud-starter-build", "spring-cloud-consul"))
|
||||
.contains(pom(project).getArtifactId());
|
||||
then(new File("/tmp/executed_build")).exists();
|
||||
then(new File("/tmp/executed_deploy")).doesNotExist();
|
||||
then(new File("/tmp/executed_docs")).doesNotExist();
|
||||
|
||||
@@ -54,18 +54,18 @@ import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.util.FileSystemUtils;
|
||||
|
||||
import static org.assertj.core.api.BDDAssertions.then;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.ArgumentMatchers.argThat;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
|
||||
/**
|
||||
* @author Marcin Grzejszczak
|
||||
*/
|
||||
public class SpringMetaReleaseAcceptanceTests
|
||||
extends AbstractSpringCloudMetaAcceptanceTests {
|
||||
public class SpringMetaReleaseAcceptanceTests extends AbstractSpringCloudMetaAcceptanceTests {
|
||||
|
||||
@Test
|
||||
public void should_perform_a_meta_release_of_sc_release_and_consul()
|
||||
throws Exception {
|
||||
public void should_perform_a_meta_release_of_sc_release_and_consul() throws Exception {
|
||||
checkoutReleaseTrainBranch("/projects/spring-cloud-release/", "Greenwich");
|
||||
File origin = cloneToTemporaryDirectory(this.springCloudConsulProject);
|
||||
assertThatClonedConsulProjectIsInSnapshots(origin);
|
||||
@@ -73,21 +73,18 @@ public class SpringMetaReleaseAcceptanceTests
|
||||
GitTestUtils.setOriginOnProjectToTmp(origin, project);
|
||||
|
||||
run(defaultRunner(),
|
||||
properties("debug=true").properties("test.metarelease=true")
|
||||
.properties(metaReleaseArgs(project).bomBranch("vGreenwich.SR2")
|
||||
.addFixedVersions(edgwareSr10()).build()),
|
||||
properties("debugx=true").properties("test.metarelease=true").properties(
|
||||
metaReleaseArgs(project).bomBranch("vGreenwich.SR2").addFixedVersions(edgwareSr10()).build()),
|
||||
context -> {
|
||||
SpringReleaser releaser = context.getBean(SpringReleaser.class);
|
||||
NonAssertingTestProjectGitHandler nonAssertingTestProjectGitHandler = context
|
||||
.getBean(NonAssertingTestProjectGitHandler.class);
|
||||
SaganUpdater saganUpdater = context.getBean(SaganUpdater.class);
|
||||
PostReleaseActions postReleaseActions = context
|
||||
.getBean(PostReleaseActions.class);
|
||||
PostReleaseActions postReleaseActions = context.getBean(PostReleaseActions.class);
|
||||
TestExecutionResultHandler testExecutionResultHandler = context
|
||||
.getBean(TestExecutionResultHandler.class);
|
||||
|
||||
ExecutionResult result = releaser
|
||||
.release(new OptionsBuilder().metaRelease(true).options());
|
||||
ExecutionResult result = releaser.release(new OptionsBuilder().metaRelease(true).options());
|
||||
|
||||
// print results
|
||||
testExecutionResultHandler.accept(result);
|
||||
@@ -97,46 +94,41 @@ public class SpringMetaReleaseAcceptanceTests
|
||||
// consul, release
|
||||
then(nonAssertingTestProjectGitHandler.clonedProjects).hasSize(2);
|
||||
// don't want to verify the docs
|
||||
thenAllStepsWereExecutedForEachProject(
|
||||
nonAssertingTestProjectGitHandler);
|
||||
thenAllStepsWereExecutedForEachProject(nonAssertingTestProjectGitHandler);
|
||||
thenSaganWasCalled(saganUpdater);
|
||||
then(clonedProject(nonAssertingTestProjectGitHandler,
|
||||
"spring-cloud-consul").tagList().call()).extracting("name")
|
||||
.contains("refs/tags/v5.3.5.RELEASE");
|
||||
then(clonedProject(nonAssertingTestProjectGitHandler, "spring-cloud-consul").tagList().call())
|
||||
.extracting("name").contains("refs/tags/v5.3.5.RELEASE");
|
||||
thenRunUpdatedTestsWereCalled(postReleaseActions);
|
||||
thenUpdateReleaseTrainDocsWasCalled(postReleaseActions);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_perform_a_meta_release_of_sc_release_and_consul_in_parallel()
|
||||
throws Exception {
|
||||
public void should_perform_a_meta_release_of_sc_release_and_consul_in_parallel() throws Exception {
|
||||
checkoutReleaseTrainBranch("/projects/spring-cloud-release/", "Greenwich");
|
||||
File origin = cloneToTemporaryDirectory(this.springCloudConsulProject);
|
||||
assertThatClonedConsulProjectIsInSnapshots(origin);
|
||||
File project = cloneToTemporaryDirectory(tmpFile("spring-cloud-consul"));
|
||||
GitTestUtils.setOriginOnProjectToTmp(origin, project);
|
||||
|
||||
run(defaultRunner(), properties("debug=true").properties("test.metarelease=true")
|
||||
.properties(metaReleaseArgsForParallel(project)
|
||||
.bomBranch("vGreenwich.SR2").addFixedVersions(edgwareSr10())
|
||||
.metaReleaseGroups("example1,example2",
|
||||
"spring-cloud-build,spring-cloud-consul,spring-cloud-release")
|
||||
.build()),
|
||||
run(defaultRunner(),
|
||||
properties("debugx=true").properties("test.metarelease=true")
|
||||
.properties(metaReleaseArgsForParallel(project).bomBranch("vGreenwich.SR2")
|
||||
.addFixedVersions(edgwareSr10())
|
||||
.metaReleaseGroups("example1,example2",
|
||||
"spring-cloud-build,spring-cloud-consul,spring-cloud-release")
|
||||
.build()),
|
||||
context -> {
|
||||
SpringReleaser releaser = context.getBean(SpringReleaser.class);
|
||||
NonAssertingTestProjectGitHandler nonAssertingTestProjectGitHandler = context
|
||||
.getBean(NonAssertingTestProjectGitHandler.class);
|
||||
SaganUpdater saganUpdater = context.getBean(SaganUpdater.class);
|
||||
DocumentationUpdater testDocumentationUpdater = context
|
||||
.getBean(DocumentationUpdater.class);
|
||||
PostReleaseActions postReleaseActions = context
|
||||
.getBean(PostReleaseActions.class);
|
||||
DocumentationUpdater testDocumentationUpdater = context.getBean(DocumentationUpdater.class);
|
||||
PostReleaseActions postReleaseActions = context.getBean(PostReleaseActions.class);
|
||||
TestExecutionResultHandler testExecutionResultHandler = context
|
||||
.getBean(TestExecutionResultHandler.class);
|
||||
|
||||
ExecutionResult result = releaser
|
||||
.release(new OptionsBuilder().metaRelease(true).options());
|
||||
ExecutionResult result = releaser.release(new OptionsBuilder().metaRelease(true).options());
|
||||
|
||||
// print results
|
||||
testExecutionResultHandler.accept(result);
|
||||
@@ -150,17 +142,15 @@ public class SpringMetaReleaseAcceptanceTests
|
||||
// thenAllStepsWereExecutedForEachProject(
|
||||
// nonAssertingTestProjectGitHandler);
|
||||
thenSaganWasCalled(saganUpdater);
|
||||
then(clonedProject(nonAssertingTestProjectGitHandler,
|
||||
"spring-cloud-consul").tagList().call()).extracting("name")
|
||||
.contains("refs/tags/v5.3.5.RELEASE");
|
||||
then(clonedProject(nonAssertingTestProjectGitHandler, "spring-cloud-consul").tagList().call())
|
||||
.extracting("name").contains("refs/tags/v5.3.5.RELEASE");
|
||||
thenRunUpdatedTestsWereCalled(postReleaseActions);
|
||||
thenUpdateReleaseTrainDocsWasCalled(postReleaseActions);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_perform_a_meta_release_dry_run_of_sc_release_and_consul()
|
||||
throws Exception {
|
||||
public void should_perform_a_meta_release_dry_run_of_sc_release_and_consul() throws Exception {
|
||||
checkoutReleaseTrainBranch("/projects/spring-cloud-release/", "Greenwich");
|
||||
File origin = cloneToTemporaryDirectory(this.springCloudConsulProject);
|
||||
assertThatClonedConsulProjectIsInSnapshots(origin);
|
||||
@@ -168,23 +158,20 @@ public class SpringMetaReleaseAcceptanceTests
|
||||
GitTestUtils.setOriginOnProjectToTmp(origin, project);
|
||||
|
||||
run(defaultRunner(),
|
||||
properties("debug=true").properties("test.metarelease=true")
|
||||
.properties(metaReleaseArgs(project).bomBranch("vGreenwich.SR2")
|
||||
.addFixedVersions(edgwareSr10()).build()),
|
||||
properties("debugx=true").properties("test.metarelease=true").properties(
|
||||
metaReleaseArgs(project).bomBranch("vGreenwich.SR2").addFixedVersions(edgwareSr10()).build()),
|
||||
context -> {
|
||||
SpringReleaser releaser = context.getBean(SpringReleaser.class);
|
||||
NonAssertingTestProjectGitHandler nonAssertingTestProjectGitHandler = context
|
||||
.getBean(NonAssertingTestProjectGitHandler.class);
|
||||
SaganUpdater saganUpdater = context.getBean(SaganUpdater.class);
|
||||
DocumentationUpdater testDocumentationUpdater = context
|
||||
.getBean(DocumentationUpdater.class);
|
||||
PostReleaseActions postReleaseActions = context
|
||||
.getBean(PostReleaseActions.class);
|
||||
DocumentationUpdater testDocumentationUpdater = context.getBean(DocumentationUpdater.class);
|
||||
PostReleaseActions postReleaseActions = context.getBean(PostReleaseActions.class);
|
||||
TestExecutionResultHandler testExecutionResultHandler = context
|
||||
.getBean(TestExecutionResultHandler.class);
|
||||
|
||||
ExecutionResult result = releaser.release(new OptionsBuilder()
|
||||
.metaRelease(true).dryRun(true).options());
|
||||
ExecutionResult result = releaser
|
||||
.release(new OptionsBuilder().metaRelease(true).dryRun(true).options());
|
||||
|
||||
// print results
|
||||
testExecutionResultHandler.accept(result);
|
||||
@@ -194,20 +181,17 @@ public class SpringMetaReleaseAcceptanceTests
|
||||
// consul, release
|
||||
then(nonAssertingTestProjectGitHandler.clonedProjects).hasSize(2);
|
||||
// only dry run tasks were called
|
||||
thenAllDryRunStepsWereExecutedForEachProject(
|
||||
nonAssertingTestProjectGitHandler);
|
||||
thenAllDryRunStepsWereExecutedForEachProject(nonAssertingTestProjectGitHandler);
|
||||
thenSaganWasNotCalled(saganUpdater);
|
||||
then(clonedProject(nonAssertingTestProjectGitHandler,
|
||||
"spring-cloud-consul").tagList().call()).extracting("name")
|
||||
.doesNotContain("refs/tags/v5.3.5.RELEASE");
|
||||
then(clonedProject(nonAssertingTestProjectGitHandler, "spring-cloud-consul").tagList().call())
|
||||
.extracting("name").doesNotContain("refs/tags/v5.3.5.RELEASE");
|
||||
thenRunUpdatedTestsWereNotCalled(postReleaseActions);
|
||||
thenUpdateReleaseTrainDocsWasNotCalled(postReleaseActions);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_not_release_any_projects_when_they_are_on_list_of_projects_to_skip()
|
||||
throws Exception {
|
||||
public void should_not_release_any_projects_when_they_are_on_list_of_projects_to_skip() throws Exception {
|
||||
checkoutReleaseTrainBranch("/projects/spring-cloud-release/", "Greenwich");
|
||||
File origin = cloneToTemporaryDirectory(this.springCloudConsulProject);
|
||||
assertThatClonedConsulProjectIsInSnapshots(origin);
|
||||
@@ -215,23 +199,17 @@ public class SpringMetaReleaseAcceptanceTests
|
||||
GitTestUtils.setOriginOnProjectToTmp(origin, project);
|
||||
File temporaryDestination = this.tmp.newFolder();
|
||||
|
||||
run(defaultRunner(),
|
||||
properties("debug=true")
|
||||
.properties("test.metarelease=true", "test.mockBuild=true")
|
||||
.properties(metaReleaseArgs(project).bomBranch("Greenwich")
|
||||
.addFixedVersions(consulAndReleaseSnapshots())
|
||||
.updateReleaseTrainWiki(false)
|
||||
.cloneDestinationDirectory(temporaryDestination)
|
||||
.projectsToSkip("spring-cloud-consul").build()),
|
||||
run(defaultRunner(), properties("debugx=true").properties("test.metarelease=true", "test.mockBuild=true")
|
||||
.properties(metaReleaseArgs(project).bomBranch("Greenwich")
|
||||
.addFixedVersions(consulAndReleaseSnapshots()).updateReleaseTrainWiki(false)
|
||||
.cloneDestinationDirectory(temporaryDestination).projectsToSkip("spring-cloud-consul").build()),
|
||||
context -> {
|
||||
SpringReleaser releaser = context.getBean(SpringReleaser.class);
|
||||
BuildProjectReleaseTask build = context
|
||||
.getBean(BuildProjectReleaseTask.class);
|
||||
BuildProjectReleaseTask build = context.getBean(BuildProjectReleaseTask.class);
|
||||
TestExecutionResultHandler testExecutionResultHandler = context
|
||||
.getBean(TestExecutionResultHandler.class);
|
||||
|
||||
ExecutionResult result = releaser
|
||||
.release(new OptionsBuilder().metaRelease(true).options());
|
||||
ExecutionResult result = releaser.release(new OptionsBuilder().metaRelease(true).options());
|
||||
|
||||
// print results
|
||||
testExecutionResultHandler.accept(result);
|
||||
@@ -244,8 +222,7 @@ public class SpringMetaReleaseAcceptanceTests
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_perform_a_meta_release_of_consul_only_when_run_from_got_passed()
|
||||
throws Exception {
|
||||
public void should_perform_a_meta_release_of_consul_only_when_run_from_got_passed() throws Exception {
|
||||
checkoutReleaseTrainBranch("/projects/spring-cloud-release/", "Greenwich");
|
||||
File origin = cloneToTemporaryDirectory(this.springCloudConsulProject);
|
||||
assertThatClonedConsulProjectIsInSnapshots(origin);
|
||||
@@ -254,24 +231,20 @@ public class SpringMetaReleaseAcceptanceTests
|
||||
File temporaryDestination = this.tmp.newFolder();
|
||||
|
||||
run(defaultRunner(),
|
||||
properties("debug=true")
|
||||
.properties("test.metarelease=true", "test.mockBuild=true")
|
||||
properties("debugx=true").properties("test.metarelease=true", "test.mockBuild=true")
|
||||
.properties(metaReleaseArgs(project).bomBranch("Greenwich")
|
||||
.addFixedVersions(releaseConsulBuildSnapshots())
|
||||
.cloneDestinationDirectory(temporaryDestination).build()),
|
||||
context -> {
|
||||
SpringReleaser releaser = context.getBean(SpringReleaser.class);
|
||||
BuildProjectReleaseTask build = context
|
||||
.getBean(BuildProjectReleaseTask.class);
|
||||
BuildProjectReleaseTask build = context.getBean(BuildProjectReleaseTask.class);
|
||||
SaganUpdater saganUpdater = context.getBean(SaganUpdater.class);
|
||||
DocumentationUpdater testDocumentationUpdater = context
|
||||
.getBean(DocumentationUpdater.class);
|
||||
DocumentationUpdater testDocumentationUpdater = context.getBean(DocumentationUpdater.class);
|
||||
TestExecutionResultHandler testExecutionResultHandler = context
|
||||
.getBean(TestExecutionResultHandler.class);
|
||||
|
||||
ExecutionResult result = releaser
|
||||
.release(new OptionsBuilder().startFrom("spring-cloud-consul")
|
||||
.metaRelease(true).options());
|
||||
.release(new OptionsBuilder().startFrom("spring-cloud-consul").metaRelease(true).options());
|
||||
|
||||
// print results
|
||||
testExecutionResultHandler.accept(result);
|
||||
@@ -290,8 +263,7 @@ public class SpringMetaReleaseAcceptanceTests
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_perform_a_meta_release_of_consul_only_when_task_names_got_passed()
|
||||
throws Exception {
|
||||
public void should_perform_a_meta_release_of_consul_only_when_task_names_got_passed() throws Exception {
|
||||
checkoutReleaseTrainBranch("/projects/spring-cloud-release/", "Greenwich");
|
||||
File origin = cloneToTemporaryDirectory(this.springCloudConsulProject);
|
||||
assertThatClonedConsulProjectIsInSnapshots(origin);
|
||||
@@ -300,24 +272,20 @@ public class SpringMetaReleaseAcceptanceTests
|
||||
File temporaryDestination = this.tmp.newFolder();
|
||||
|
||||
run(defaultRunner(),
|
||||
properties("debug=true")
|
||||
.properties("test.metarelease=true", "test.mockBuild=true")
|
||||
properties("debugx=true").properties("test.metarelease=true", "test.mockBuild=true")
|
||||
.properties(metaReleaseArgs(project).bomBranch("Greenwich")
|
||||
.addFixedVersions(releaseConsulBuildSnapshots())
|
||||
.cloneDestinationDirectory(temporaryDestination).build()),
|
||||
context -> {
|
||||
SpringReleaser releaser = context.getBean(SpringReleaser.class);
|
||||
BuildProjectReleaseTask build = context
|
||||
.getBean(BuildProjectReleaseTask.class);
|
||||
BuildProjectReleaseTask build = context.getBean(BuildProjectReleaseTask.class);
|
||||
SaganUpdater saganUpdater = context.getBean(SaganUpdater.class);
|
||||
DocumentationUpdater testDocumentationUpdater = context
|
||||
.getBean(DocumentationUpdater.class);
|
||||
DocumentationUpdater testDocumentationUpdater = context.getBean(DocumentationUpdater.class);
|
||||
TestExecutionResultHandler testExecutionResultHandler = context
|
||||
.getBean(TestExecutionResultHandler.class);
|
||||
|
||||
ExecutionResult result = releaser.release(new OptionsBuilder()
|
||||
.taskNames(Collections.singletonList("spring-cloud-consul"))
|
||||
.metaRelease(true).options());
|
||||
.taskNames(Collections.singletonList("spring-cloud-consul")).metaRelease(true).options());
|
||||
|
||||
// print results
|
||||
testExecutionResultHandler.accept(result);
|
||||
@@ -336,19 +304,18 @@ public class SpringMetaReleaseAcceptanceTests
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_not_execute_any_subsequent_task_when_first_one_fails()
|
||||
throws Exception {
|
||||
public void should_not_execute_any_subsequent_task_when_first_one_fails() throws Exception {
|
||||
checkoutReleaseTrainBranch("/projects/spring-cloud-release/", "Greenwich");
|
||||
File origin = cloneToTemporaryDirectory(this.springCloudConsulProject);
|
||||
assertThatClonedConsulProjectIsInSnapshots(origin);
|
||||
File project = cloneToTemporaryDirectory(tmpFile("spring-cloud-consul"));
|
||||
GitTestUtils.setOriginOnProjectToTmp(origin, project);
|
||||
|
||||
run(failingBuildRunner(), properties("debug=true")
|
||||
run(failingBuildRunner(), properties("debugx=true")
|
||||
.properties("test.metarelease=true", "test.metarelease.failing=true",
|
||||
"releaser.flow.default-enabled=false")
|
||||
.properties(metaReleaseArgs(project).bomBranch("vGreenwich.SR2")
|
||||
.addFixedVersions(edgwareSr10()).build()),
|
||||
.properties(
|
||||
metaReleaseArgs(project).bomBranch("vGreenwich.SR2").addFixedVersions(edgwareSr10()).build()),
|
||||
context -> {
|
||||
SpringReleaser releaser = context.getBean(SpringReleaser.class);
|
||||
NonAssertingTestProjectGitHandler nonAssertingTestProjectGitHandler = context
|
||||
@@ -357,11 +324,9 @@ public class SpringMetaReleaseAcceptanceTests
|
||||
.getBean(TestExecutionResultHandler.class);
|
||||
FirstTask firstTask = context.getBean(FirstTask.class);
|
||||
SecondTask secondTask = context.getBean(SecondTask.class);
|
||||
PostReleaseTask postReleaseTask = context
|
||||
.getBean(PostReleaseTask.class);
|
||||
PostReleaseTask postReleaseTask = context.getBean(PostReleaseTask.class);
|
||||
|
||||
ExecutionResult result = releaser
|
||||
.release(new OptionsBuilder().metaRelease(true).options());
|
||||
ExecutionResult result = releaser.release(new OptionsBuilder().metaRelease(true).options());
|
||||
|
||||
// print results
|
||||
testExecutionResultHandler.accept(result);
|
||||
@@ -370,48 +335,40 @@ public class SpringMetaReleaseAcceptanceTests
|
||||
then(result.isFailureOrUnstable()).isTrue();
|
||||
// consul
|
||||
then(nonAssertingTestProjectGitHandler.clonedProjects).hasSize(1);
|
||||
BDDMockito.then(firstTask).should().runTask(BDDMockito.argThat(
|
||||
arg -> arg.project.getName().equals("spring-cloud-consul")));
|
||||
BDDMockito.then(firstTask).should()
|
||||
.runTask(BDDMockito.argThat(arg -> arg.project.getName().equals("spring-cloud-consul")));
|
||||
BDDMockito.then(firstTask).should(BDDMockito.never())
|
||||
.runTask(BDDMockito.argThat(arg -> arg.project.getName()
|
||||
.equals("spring-cloud-release")));
|
||||
BDDMockito.then(secondTask).should(BDDMockito.never())
|
||||
.runTask(BDDMockito.any(Arguments.class));
|
||||
.runTask(BDDMockito.argThat(arg -> arg.project.getName().equals("spring-cloud-release")));
|
||||
BDDMockito.then(secondTask).should(BDDMockito.never()).runTask(BDDMockito.any(Arguments.class));
|
||||
BDDMockito.then(postReleaseTask).should(BDDMockito.never())
|
||||
.runTask(BDDMockito.any(Arguments.class));
|
||||
});
|
||||
}
|
||||
|
||||
private SpringApplicationBuilder defaultRunner() {
|
||||
return new SpringApplicationBuilder(MetaReleaseConfig.class,
|
||||
MetaReleaseScanningConfiguration.class).web(WebApplicationType.NONE)
|
||||
.properties("spring.jmx.enabled=false");
|
||||
return new SpringApplicationBuilder(MetaReleaseConfig.class, MetaReleaseScanningConfiguration.class)
|
||||
.web(WebApplicationType.NONE).properties("spring.jmx.enabled=false");
|
||||
}
|
||||
|
||||
private SpringApplicationBuilder failingBuildRunner() {
|
||||
return new SpringApplicationBuilder(
|
||||
SpringMetaReleaseAcceptanceTests.MetaReleaseConfig.class,
|
||||
return new SpringApplicationBuilder(SpringMetaReleaseAcceptanceTests.MetaReleaseConfig.class,
|
||||
SpringMetaReleaseAcceptanceTests.MetaReleaseFailingTasksScanningConfiguration.class)
|
||||
.web(WebApplicationType.NONE)
|
||||
.properties("spring.jmx.enabled=false");
|
||||
.web(WebApplicationType.NONE).properties("spring.jmx.enabled=false");
|
||||
}
|
||||
|
||||
private void thenWikiPageWasUpdated(DocumentationUpdater documentationUpdater) {
|
||||
BDDMockito.then(documentationUpdater).should()
|
||||
.updateReleaseTrainWiki(BDDMockito.any(Projects.class));
|
||||
BDDMockito.then(documentationUpdater).should().updateReleaseTrainWiki(BDDMockito.any(Projects.class));
|
||||
}
|
||||
|
||||
private void thenBuildWasCalledFor(BuildProjectReleaseTask build,
|
||||
String projectName) {
|
||||
BDDMockito.then(build).should().apply(argThat(
|
||||
argument -> argument.originalVersion.projectName.equals(projectName)
|
||||
private void thenBuildWasCalledFor(BuildProjectReleaseTask build, String projectName) {
|
||||
BDDMockito.then(build).should()
|
||||
.apply(argThat(argument -> argument.originalVersion.projectName.equals(projectName)
|
||||
|| argument.project.getAbsolutePath().endsWith(projectName)));
|
||||
}
|
||||
|
||||
private void thenBuildWasNeverCalledFor(BuildProjectReleaseTask build,
|
||||
String projectName) {
|
||||
BDDMockito.then(build).should(BDDMockito.never()).apply(argThat(
|
||||
argument -> argument.originalVersion.projectName.equals(projectName)
|
||||
private void thenBuildWasNeverCalledFor(BuildProjectReleaseTask build, String projectName) {
|
||||
BDDMockito.then(build).should(BDDMockito.never())
|
||||
.apply(argThat(argument -> argument.originalVersion.projectName.equals(projectName)
|
||||
|| argument.project.getAbsolutePath().endsWith(projectName)));
|
||||
}
|
||||
|
||||
@@ -438,8 +395,9 @@ public class SpringMetaReleaseAcceptanceTests
|
||||
@Bean
|
||||
SaganClient testSaganClient() {
|
||||
SaganClient saganClient = BDDMockito.mock(SaganClient.class);
|
||||
BDDMockito.given(saganClient.getProject(anyString()))
|
||||
.willReturn(newProject());
|
||||
given(saganClient.getProject(anyString())).willReturn(newProject());
|
||||
given(saganClient.addRelease(anyString(), any())).willReturn(true);
|
||||
given(saganClient.deleteRelease(anyString(), anyString())).willReturn(true);
|
||||
return saganClient;
|
||||
}
|
||||
|
||||
@@ -450,33 +408,27 @@ public class SpringMetaReleaseAcceptanceTests
|
||||
}
|
||||
|
||||
@Bean
|
||||
SaganUpdater testSaganUpdater(SaganClient saganClient,
|
||||
ReleaserProperties properties) {
|
||||
SaganUpdater testSaganUpdater(SaganClient saganClient, ReleaserProperties properties) {
|
||||
return BDDMockito.spy(new SaganUpdater(saganClient, properties));
|
||||
}
|
||||
|
||||
@Bean
|
||||
PostReleaseActions myPostReleaseActions() {
|
||||
return BDDMockito
|
||||
.mock(PostReleaseActions.class,
|
||||
invocation -> invocation.getMethod().getReturnType()
|
||||
.equals(ExecutionResult.class)
|
||||
? ExecutionResult.success() : null);
|
||||
return BDDMockito.mock(PostReleaseActions.class,
|
||||
invocation -> invocation.getMethod().getReturnType().equals(ExecutionResult.class)
|
||||
? ExecutionResult.success() : null);
|
||||
}
|
||||
|
||||
@Bean
|
||||
NonAssertingTestProjectGitHubHandler testProjectGitHubHandler(
|
||||
ReleaserProperties releaserProperties) {
|
||||
NonAssertingTestProjectGitHubHandler testProjectGitHubHandler(ReleaserProperties releaserProperties) {
|
||||
return new NonAssertingTestProjectGitHubHandler(releaserProperties);
|
||||
}
|
||||
|
||||
@Bean
|
||||
NonAssertingTestProjectGitHandler nonAssertingTestProjectGitHandler(
|
||||
ReleaserProperties releaserProperties,
|
||||
NonAssertingTestProjectGitHandler nonAssertingTestProjectGitHandler(ReleaserProperties releaserProperties,
|
||||
@Value("${test.projectName}") String projectName) {
|
||||
return new NonAssertingTestProjectGitHandler(releaserProperties,
|
||||
file -> FileSystemUtils
|
||||
.deleteRecursively(new File(file, projectName)));
|
||||
file -> FileSystemUtils.deleteRecursively(new File(file, projectName)));
|
||||
}
|
||||
|
||||
@Bean
|
||||
@@ -487,8 +439,7 @@ public class SpringMetaReleaseAcceptanceTests
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@ConditionalOnProperty(value = "test.metarelease", havingValue = "true",
|
||||
matchIfMissing = true)
|
||||
@ConditionalOnProperty(value = "test.metarelease", havingValue = "true", matchIfMissing = true)
|
||||
@ComponentScan({ "releaser.internal", "releaser.cloud" })
|
||||
static class MetaReleaseScanningConfiguration {
|
||||
|
||||
@@ -551,8 +502,7 @@ class FirstTask implements ReleaseReleaserTask {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExecutionResult runTask(Arguments args)
|
||||
throws BuildUnstableException, RuntimeException {
|
||||
public ExecutionResult runTask(Arguments args) throws BuildUnstableException, RuntimeException {
|
||||
return ExecutionResult.failure(new IllegalStateException("Failure"));
|
||||
}
|
||||
|
||||
@@ -586,8 +536,7 @@ class SecondTask implements ReleaseReleaserTask {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExecutionResult runTask(Arguments args)
|
||||
throws BuildUnstableException, RuntimeException {
|
||||
public ExecutionResult runTask(Arguments args) throws BuildUnstableException, RuntimeException {
|
||||
return ExecutionResult.success();
|
||||
}
|
||||
|
||||
@@ -621,8 +570,7 @@ class PostReleaseTask implements TrainPostReleaseReleaserTask {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExecutionResult runTask(Arguments args)
|
||||
throws BuildUnstableException, RuntimeException {
|
||||
public ExecutionResult runTask(Arguments args) throws BuildUnstableException, RuntimeException {
|
||||
return ExecutionResult.success();
|
||||
}
|
||||
|
||||
|
||||
@@ -49,34 +49,33 @@ import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.util.FileSystemUtils;
|
||||
|
||||
import static org.assertj.core.api.BDDAssertions.then;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Mockito.times;
|
||||
|
||||
/**
|
||||
* @author Marcin Grzejszczak
|
||||
*/
|
||||
public class SpringSingleProjectAcceptanceTests
|
||||
extends AbstractSpringCloudAcceptanceTests {
|
||||
public class SpringSingleProjectAcceptanceTests extends AbstractSpringCloudAcceptanceTests {
|
||||
|
||||
SpringApplicationBuilder runner = new SpringApplicationBuilder(
|
||||
SpringSingleProjectAcceptanceTests.SingleProjectReleaseConfig.class,
|
||||
SpringSingleProjectAcceptanceTests.SingleProjectScanningConfiguration.class)
|
||||
.web(WebApplicationType.NONE).properties("spring.jmx.enabled=false");
|
||||
SpringSingleProjectAcceptanceTests.SingleProjectScanningConfiguration.class).web(WebApplicationType.NONE)
|
||||
.properties("spring.jmx.enabled=false");
|
||||
|
||||
@Test
|
||||
public void should_fail_to_perform_a_release_of_consul_when_sc_release_contains_snapshots()
|
||||
throws Exception {
|
||||
checkoutReleaseTrainBranch("/projects/spring-cloud-release-with-snapshot/",
|
||||
"vCamden.SR5.BROKEN");
|
||||
public void should_fail_to_perform_a_release_of_consul_when_sc_release_contains_snapshots() throws Exception {
|
||||
checkoutReleaseTrainBranch("/projects/spring-cloud-release-with-snapshot/", "vCamden.SR5.BROKEN");
|
||||
File origin = cloneToTemporaryDirectory(this.springCloudConsulProject);
|
||||
assertThatClonedConsulProjectIsInSnapshots(origin);
|
||||
File project = cloneToTemporaryDirectory(tmpFile("spring-cloud-consul"));
|
||||
GitTestUtils.setOriginOnProjectToTmp(origin, project);
|
||||
|
||||
run(this.runner,
|
||||
properties("debug=true").properties(new ArgsBuilder(project, this.tmp)
|
||||
properties("debugx=true").properties(new ArgsBuilder(project, this.tmp)
|
||||
.releaseTrainUrl("/projects/spring-cloud-release-with-snapshot/")
|
||||
.bomBranch("vCamden.SR5.BROKEN").expectedVersion("1.1.2.RELEASE")
|
||||
.build()),
|
||||
.bomBranch("vCamden.SR5.BROKEN").expectedVersion("1.1.2.RELEASE").build()),
|
||||
context -> {
|
||||
SpringReleaser releaser = context.getBean(SpringReleaser.class);
|
||||
BDDAssertions.thenThrownBy(releaser::release).hasMessageContaining(
|
||||
@@ -94,28 +93,23 @@ public class SpringSingleProjectAcceptanceTests
|
||||
GitTestUtils.setOriginOnProjectToTmp(origin, project);
|
||||
|
||||
run(this.runner,
|
||||
properties("debug=true").properties(new ArgsBuilder(project, this.tmp)
|
||||
.releaseTrainUrl("/projects/spring-cloud-release/")
|
||||
.bomBranch("vGreenwich.SR2").expectedVersion("2.1.2.RELEASE")
|
||||
.build()),
|
||||
properties("debugx=true").properties(
|
||||
new ArgsBuilder(project, this.tmp).releaseTrainUrl("/projects/spring-cloud-release/")
|
||||
.bomBranch("vGreenwich.SR2").expectedVersion("2.1.2.RELEASE").build()),
|
||||
context -> {
|
||||
SpringReleaser releaser = context.getBean(SpringReleaser.class);
|
||||
TestProjectGitHubHandler gitHubHandler = context
|
||||
.getBean(TestProjectGitHubHandler.class);
|
||||
TestProjectGitHubHandler gitHubHandler = context.getBean(TestProjectGitHubHandler.class);
|
||||
SaganClient saganClient = context.getBean(SaganClient.class);
|
||||
PostReleaseActions postReleaseActions = context
|
||||
.getBean(PostReleaseActions.class);
|
||||
PostReleaseActions postReleaseActions = context.getBean(PostReleaseActions.class);
|
||||
TestExecutionResultHandler testExecutionResultHandler = context
|
||||
.getBean(TestExecutionResultHandler.class);
|
||||
|
||||
ExecutionResult result = releaser
|
||||
.release(new OptionsBuilder().interactive(true).options());
|
||||
ExecutionResult result = releaser.release(new OptionsBuilder().interactive(true).options());
|
||||
|
||||
Iterable<RevCommit> commits = listOfCommits(project);
|
||||
Iterator<RevCommit> iterator = commits.iterator();
|
||||
tagIsPresentInOrigin(origin, "v2.1.2.RELEASE");
|
||||
commitIsPresent(iterator,
|
||||
"Bumping versions to 2.1.3.SNAPSHOT after release");
|
||||
commitIsPresent(iterator, "Bumping versions to 2.1.3.SNAPSHOT after release");
|
||||
commitIsPresent(iterator, "Going back to snapshots");
|
||||
commitIsPresent(iterator, "Update SNAPSHOT to 2.1.2.RELEASE");
|
||||
pomVersionIsEqualTo(project, "2.1.3.SNAPSHOT");
|
||||
@@ -127,11 +121,10 @@ public class SpringSingleProjectAcceptanceTests
|
||||
then(releaseNotesTemplate()).doesNotExist();
|
||||
// once for updating GA
|
||||
// second time to update SNAPSHOT
|
||||
BDDMockito.then(saganClient).should(BDDMockito.times(2))
|
||||
.updateRelease(BDDMockito.eq("spring-cloud-consul"),
|
||||
BDDMockito.anyList());
|
||||
BDDMockito.then(saganClient).should()
|
||||
.deleteRelease("spring-cloud-consul", "2.1.2.BUILD-SNAPSHOT");
|
||||
BDDMockito.then(saganClient).should(times(2)).addRelease(BDDMockito.eq("spring-cloud-consul"),
|
||||
BDDMockito.any());
|
||||
BDDMockito.then(saganClient).should(times(2)).getProject("spring-cloud-consul");
|
||||
BDDMockito.then(saganClient).should().deleteRelease("spring-cloud-consul", "2.1.2.BUILD-SNAPSHOT");
|
||||
then(gitHubHandler.issueCreatedInSpringGuides).isFalse();
|
||||
then(gitHubHandler.issueCreatedInStartSpringIo).isFalse();
|
||||
thenRunUpdatedTestsWereNotCalled(postReleaseActions);
|
||||
@@ -152,34 +145,28 @@ public class SpringSingleProjectAcceptanceTests
|
||||
GitTestUtils.setOriginOnProjectToTmp(origin, project);
|
||||
|
||||
run(this.runner,
|
||||
properties("debug=true").properties(new ArgsBuilder(project, this.tmp)
|
||||
.releaseTrainUrl("/projects/spring-cloud-release/")
|
||||
.bomBranch("vGreenwich.SR2").projectName("spring-cloud-build")
|
||||
.expectedVersion("2.1.6.RELEASE").build()),
|
||||
properties("debugx=true").properties(new ArgsBuilder(project, this.tmp)
|
||||
.releaseTrainUrl("/projects/spring-cloud-release/").bomBranch("vGreenwich.SR2")
|
||||
.projectName("spring-cloud-build").expectedVersion("2.1.6.RELEASE").build()),
|
||||
context -> {
|
||||
SpringReleaser releaser = context.getBean(SpringReleaser.class);
|
||||
TestProjectGitHubHandler gitHubHandler = context
|
||||
.getBean(TestProjectGitHubHandler.class);
|
||||
TestProjectGitHubHandler gitHubHandler = context.getBean(TestProjectGitHubHandler.class);
|
||||
SaganClient saganClient = context.getBean(SaganClient.class);
|
||||
PostReleaseActions postReleaseActions = context
|
||||
.getBean(PostReleaseActions.class);
|
||||
PostReleaseActions postReleaseActions = context.getBean(PostReleaseActions.class);
|
||||
TestExecutionResultHandler testExecutionResultHandler = context
|
||||
.getBean(TestExecutionResultHandler.class);
|
||||
|
||||
ExecutionResult result = releaser
|
||||
.release(new OptionsBuilder().interactive(true).options());
|
||||
ExecutionResult result = releaser.release(new OptionsBuilder().interactive(true).options());
|
||||
|
||||
Iterable<RevCommit> commits = listOfCommits(project);
|
||||
Iterator<RevCommit> iterator = commits.iterator();
|
||||
tagIsPresentInOrigin(origin, "v2.1.6.RELEASE");
|
||||
// we're running against camden sc-release
|
||||
commitIsPresent(iterator,
|
||||
"Bumping versions to 2.1.7.SNAPSHOT after release");
|
||||
commitIsPresent(iterator, "Bumping versions to 2.1.7.SNAPSHOT after release");
|
||||
commitIsPresent(iterator, "Going back to snapshots");
|
||||
commitIsPresent(iterator, "Update SNAPSHOT to 2.1.6.RELEASE");
|
||||
pomVersionIsEqualTo(project, "2.1.7.SNAPSHOT");
|
||||
pomParentVersionIsEqualTo(project, "spring-cloud-build-dependencies",
|
||||
"2.1.6.RELEASE");
|
||||
pomParentVersionIsEqualTo(project, "spring-cloud-build-dependencies", "2.1.6.RELEASE");
|
||||
then(gitHubHandler.closedMilestones).isTrue();
|
||||
then(emailTemplate()).doesNotExist();
|
||||
then(blogTemplate()).doesNotExist();
|
||||
@@ -187,11 +174,9 @@ public class SpringSingleProjectAcceptanceTests
|
||||
then(releaseNotesTemplate()).doesNotExist();
|
||||
// once for updating GA
|
||||
// second time to update SNAPSHOT
|
||||
BDDMockito.then(saganClient).should(BDDMockito.times(2))
|
||||
.updateRelease(BDDMockito.eq("spring-cloud-build"),
|
||||
BDDMockito.anyList());
|
||||
BDDMockito.then(saganClient).should()
|
||||
.deleteRelease("spring-cloud-build", "2.1.6.BUILD-SNAPSHOT");
|
||||
BDDMockito.then(saganClient).should(times(2)).addRelease(BDDMockito.eq("spring-cloud-build"),
|
||||
BDDMockito.any());
|
||||
BDDMockito.then(saganClient).should().deleteRelease("spring-cloud-build", "2.1.6.BUILD-SNAPSHOT");
|
||||
then(gitHubHandler.issueCreatedInSpringGuides).isFalse();
|
||||
then(gitHubHandler.issueCreatedInStartSpringIo).isFalse();
|
||||
thenRunUpdatedTestsWereNotCalled(postReleaseActions);
|
||||
@@ -211,26 +196,22 @@ public class SpringSingleProjectAcceptanceTests
|
||||
GitTestUtils.setOriginOnProjectToTmp(origin, project);
|
||||
|
||||
run(this.runner,
|
||||
properties("debug=true").properties(new ArgsBuilder(project, this.tmp)
|
||||
.releaseTrainUrl("/projects/spring-cloud-release/")
|
||||
.bomBranch("vDalston.RC1").expectedVersion("1.2.0.RC1").build()),
|
||||
properties("debugx=true").properties(
|
||||
new ArgsBuilder(project, this.tmp).releaseTrainUrl("/projects/spring-cloud-release/")
|
||||
.bomBranch("vDalston.RC1").expectedVersion("1.2.0.RC1").build()),
|
||||
context -> {
|
||||
SpringReleaser releaser = context.getBean(SpringReleaser.class);
|
||||
TestProjectGitHubHandler gitHubHandler = context
|
||||
.getBean(TestProjectGitHubHandler.class);
|
||||
TestProjectGitHubHandler gitHubHandler = context.getBean(TestProjectGitHubHandler.class);
|
||||
SaganClient saganClient = context.getBean(SaganClient.class);
|
||||
PostReleaseActions postReleaseActions = context
|
||||
.getBean(PostReleaseActions.class);
|
||||
PostReleaseActions postReleaseActions = context.getBean(PostReleaseActions.class);
|
||||
TestExecutionResultHandler testExecutionResultHandler = context
|
||||
.getBean(TestExecutionResultHandler.class);
|
||||
|
||||
ExecutionResult result = releaser
|
||||
.release(new OptionsBuilder().interactive(true).options());
|
||||
ExecutionResult result = releaser.release(new OptionsBuilder().interactive(true).options());
|
||||
|
||||
Iterable<RevCommit> commits = listOfCommits(project);
|
||||
tagIsPresentInOrigin(origin, "v1.2.0.RC1");
|
||||
commitIsNotPresent(commits,
|
||||
"Bumping versions to 1.2.1.SNAPSHOT after release");
|
||||
commitIsNotPresent(commits, "Bumping versions to 1.2.1.SNAPSHOT after release");
|
||||
Iterator<RevCommit> iterator = listOfCommits(project).iterator();
|
||||
commitIsPresent(iterator, "Going back to snapshots");
|
||||
commitIsPresent(iterator, "Update SNAPSHOT to 1.2.0.RC1");
|
||||
@@ -241,12 +222,11 @@ public class SpringSingleProjectAcceptanceTests
|
||||
then(blogTemplate()).doesNotExist();
|
||||
then(tweetTemplate()).doesNotExist();
|
||||
then(releaseNotesTemplate()).doesNotExist();
|
||||
BDDMockito.then(saganClient).should().updateRelease(
|
||||
BDDMockito.eq("spring-cloud-consul"), BDDMockito.anyList());
|
||||
BDDMockito.then(saganClient).should()
|
||||
.deleteRelease("spring-cloud-consul", "1.2.0.M8");
|
||||
BDDMockito.then(saganClient).should()
|
||||
.deleteRelease("spring-cloud-consul", "1.2.0.RC1");
|
||||
BDDMockito.then(saganClient).should().addRelease(BDDMockito.eq("spring-cloud-consul"),
|
||||
BDDMockito.any());
|
||||
BDDMockito.then(saganClient).should(times(2)).getProject("spring-cloud-consul");
|
||||
BDDMockito.then(saganClient).should().deleteRelease("spring-cloud-consul", "1.2.0.M8");
|
||||
BDDMockito.then(saganClient).should().deleteRelease("spring-cloud-consul", "1.2.0.SNAPSHOT");
|
||||
// we update guides only for SR / RELEASE
|
||||
then(gitHubHandler.issueCreatedInSpringGuides).isFalse();
|
||||
then(gitHubHandler.issueCreatedInStartSpringIo).isFalse();
|
||||
@@ -259,8 +239,7 @@ public class SpringSingleProjectAcceptanceTests
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_not_clone_when_option_not_to_clone_was_switched_on()
|
||||
throws Exception {
|
||||
public void should_not_clone_when_option_not_to_clone_was_switched_on() throws Exception {
|
||||
checkoutReleaseTrainBranch("/projects/spring-cloud-release/", "master");
|
||||
File origin = cloneToTemporaryDirectory(this.springCloudConsulProject);
|
||||
assertThatClonedConsulProjectIsInSnapshots(origin);
|
||||
@@ -269,12 +248,11 @@ public class SpringSingleProjectAcceptanceTests
|
||||
final File temporaryDestination = this.tmp.newFolder();
|
||||
|
||||
run(this.runner,
|
||||
properties("debug=true").properties(new ArgsBuilder(project, this.tmp)
|
||||
.releaseTrainUrl("/projects/spring-cloud-release/")
|
||||
.bomBranch("vCamden.SR5").expectedVersion("1.1.2.RELEASE")
|
||||
properties("debugx=true").properties(new ArgsBuilder(project, this.tmp)
|
||||
.releaseTrainUrl("/projects/spring-cloud-release/").bomBranch("vCamden.SR5")
|
||||
.expectedVersion("1.1.2.RELEASE")
|
||||
// just build
|
||||
.chosenOption("6").fetchVersionsFromGit(false)
|
||||
.cloneDestinationDirectory(temporaryDestination)
|
||||
.chosenOption("6").fetchVersionsFromGit(false).cloneDestinationDirectory(temporaryDestination)
|
||||
.addFixedVersion("spring-cloud-release", "Finchley.RELEASE")
|
||||
.addFixedVersion("spring-cloud-consul", "2.3.4.RELEASE").build()),
|
||||
context -> {
|
||||
@@ -288,8 +266,7 @@ public class SpringSingleProjectAcceptanceTests
|
||||
|
||||
private void assertThatClonedBuildProjectIsInSnapshots(File origin) {
|
||||
pomVersionIsEqualTo(origin, "1.3.7.BUILD-SNAPSHOT");
|
||||
pomParentVersionIsEqualTo(origin, "spring-cloud-build-dependencies",
|
||||
"1.5.9.RELEASE");
|
||||
pomParentVersionIsEqualTo(origin, "spring-cloud-build-dependencies", "1.5.9.RELEASE");
|
||||
}
|
||||
// @formatter:on
|
||||
|
||||
@@ -305,8 +282,7 @@ public class SpringSingleProjectAcceptanceTests
|
||||
|
||||
boolean issueCreatedInStartSpringIo = false;
|
||||
|
||||
TestProjectGitHubHandler(ReleaserProperties properties, String expectedVersion,
|
||||
String projectName) {
|
||||
TestProjectGitHubHandler(ReleaserProperties properties, String expectedVersion, String projectName) {
|
||||
super(properties, Collections.emptyList());
|
||||
this.expectedVersion = expectedVersion;
|
||||
this.projectName = projectName;
|
||||
@@ -325,8 +301,7 @@ public class SpringSingleProjectAcceptanceTests
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createIssueInStartSpringIo(Projects projects,
|
||||
ProjectVersion version) {
|
||||
public void createIssueInStartSpringIo(Projects projects, ProjectVersion version) {
|
||||
this.issueCreatedInStartSpringIo = true;
|
||||
}
|
||||
|
||||
@@ -339,15 +314,15 @@ public class SpringSingleProjectAcceptanceTests
|
||||
|
||||
@Configuration
|
||||
@EnableAutoConfiguration
|
||||
@ConditionalOnProperty(value = "test.metarelease", havingValue = "false",
|
||||
matchIfMissing = true)
|
||||
@ConditionalOnProperty(value = "test.metarelease", havingValue = "false", matchIfMissing = true)
|
||||
static class SingleProjectReleaseConfig extends DefaultTestConfiguration {
|
||||
|
||||
@Bean
|
||||
SaganClient testSaganClient() {
|
||||
SaganClient saganClient = BDDMockito.mock(SaganClient.class);
|
||||
BDDMockito.given(saganClient.getProject(anyString()))
|
||||
.willReturn(newProject());
|
||||
given(saganClient.getProject(anyString())).willReturn(newProject());
|
||||
given(saganClient.addRelease(anyString(), any())).willReturn(true);
|
||||
given(saganClient.deleteRelease(anyString(), anyString())).willReturn(true);
|
||||
return saganClient;
|
||||
}
|
||||
|
||||
@@ -357,21 +332,17 @@ public class SpringSingleProjectAcceptanceTests
|
||||
}
|
||||
|
||||
@Bean
|
||||
TestProjectGitHubHandler testProjectGitHubHandler(
|
||||
ReleaserProperties releaserProperties,
|
||||
TestProjectGitHubHandler testProjectGitHubHandler(ReleaserProperties releaserProperties,
|
||||
@Value("${test.expectedVersion}") String expectedVersion,
|
||||
@Value("${test.projectName}") String projectName) {
|
||||
return new TestProjectGitHubHandler(releaserProperties, expectedVersion,
|
||||
projectName);
|
||||
return new TestProjectGitHubHandler(releaserProperties, expectedVersion, projectName);
|
||||
}
|
||||
|
||||
@Bean
|
||||
NonAssertingTestProjectGitHandler nonAssertingTestProjectGitHandler(
|
||||
ReleaserProperties releaserProperties,
|
||||
NonAssertingTestProjectGitHandler nonAssertingTestProjectGitHandler(ReleaserProperties releaserProperties,
|
||||
@Value("${test.projectName}") String projectName) {
|
||||
return new NonAssertingTestProjectGitHandler(releaserProperties,
|
||||
file -> FileSystemUtils
|
||||
.deleteRecursively(new File(file, projectName)));
|
||||
file -> FileSystemUtils.deleteRecursively(new File(file, projectName)));
|
||||
}
|
||||
|
||||
@Bean
|
||||
@@ -382,8 +353,7 @@ public class SpringSingleProjectAcceptanceTests
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@ConditionalOnProperty(value = "test.metarelease", havingValue = "false",
|
||||
matchIfMissing = true)
|
||||
@ConditionalOnProperty(value = "test.metarelease", havingValue = "false", matchIfMissing = true)
|
||||
@ComponentScan({ "releaser.internal", "releaser.cloud" })
|
||||
static class SingleProjectScanningConfiguration {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user