Skip to content

Commit

Permalink
Merge pull request #47 from gsmet/maintenance
Browse files Browse the repository at this point in the history
Include maintenance information in ReleaseInformation
  • Loading branch information
gsmet authored Jan 16, 2024
2 parents ade6fe6 + 182b8bf commit 2dfc5b4
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 17 deletions.
14 changes: 12 additions & 2 deletions src/main/java/io/quarkus/bot/release/ReleaseInformation.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ public class ReleaseInformation {
private final boolean major;

private String version;
private boolean maintenance;

@JsonCreator
public ReleaseInformation(String version, String branch, String qualifier, boolean major) {
public ReleaseInformation(String version, String branch, String qualifier, boolean major, boolean maintenance) {
this.version = version;
this.branch = branch;
this.qualifier = qualifier;
this.major = major;
this.maintenance = maintenance;
}

public String getVersion() {
Expand All @@ -33,10 +35,18 @@ public String getQualifier() {
return qualifier;
}

public boolean isMaintenance() {
return maintenance;
}

public void setVersion(String version) {
this.version = version;
}

public void setMaintenance(boolean maintenance) {
this.maintenance = maintenance;
}

@JsonIgnore
public boolean isFinal() {
return qualifier == null || qualifier.isBlank() || qualifier.equals("Final");
Expand Down Expand Up @@ -80,7 +90,7 @@ public boolean equals(Object obj) {

@Override
public String toString() {
return "ReleaseInformation [version=" + version + ", branch=" + branch + ", qualifier=" + qualifier + ", major=" + major
return "ReleaseInformation [version=" + version + ", branch=" + branch + ", qualifier=" + qualifier + ", major=" + major + ",maintenance=" + maintenance
+ "]";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ public int run(Context context, Commands commands, ReleaseInformation releaseInf

if (releaseInformation.isFinal()) {
comment.append("Time to write the announcement:\n\n");
comment.append("* Update the versions in `_data/versions.yaml`\n");
if (!releaseInformation.isMaintenance()) {
comment.append("* Update the versions in `_data/versions.yaml`\n");
}
comment.append("* Write a blog post for [the website](https://github.com/quarkusio/quarkusio.github.io)\n");
comment.append(
" * Use a previous announcement as a template (be aware, annoucements are very different for the first final of a major/minor and the follow-up micros)\n");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package io.quarkus.bot.release.step;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;

import jakarta.inject.Inject;
import jakarta.inject.Singleton;
Expand Down Expand Up @@ -35,10 +33,10 @@ public boolean shouldPause(Context context, Commands commands, ReleaseInformatio
comment.append("- Quarkus `").append(releaseInformation.getVersion()).append("`\n");
comment.append("- On branch `").append(releaseInformation.getBranch()).append("`\n");
comment.append("- With Java `").append(jdks.getJdkVersion(releaseInformation.getBranch())).append("`\n");
if (Files.exists(Path.of("work", "maintenance"))) {
if (releaseInformation.isMaintenance()) {
comment.append("- This is a `maintenance` release.\n");
}
if (Files.exists(Path.of("work", "preview"))) {
if (!releaseInformation.isFinal()) {
comment.append("- This is a `preview` release (e.g. `Alpha`, `Beta`, `CR`).\n");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public int run(Context context, Commands commands, ReleaseInformation releaseInf
}

releaseInformation.setVersion(Files.readString(Path.of("work", "newVersion")).trim());
releaseInformation.setMaintenance(Files.exists(Path.of("work", "maintenance")));
issues.appendReleaseInformation(updatedIssueBody, releaseInformation);

return exitCode;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/io/quarkus/bot/release/util/Issues.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public ReleaseInformation extractReleaseInformationFromForm(String description)
throw new IllegalStateException("Unable to extract a branch from the description");
}

return new ReleaseInformation(null, branch, qualifier, major);
return new ReleaseInformation(null, branch, qualifier, major, false);
}

public ReleaseInformation extractReleaseInformation(UpdatedIssueBody updatedIssueBody) {
Expand Down
6 changes: 3 additions & 3 deletions src/test/java/io/quarkus/bot/release/BranchesTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,23 @@ public class BranchesTest {

@Test
void testPreviewRelease() {
ReleaseInformation releaseInformation = new ReleaseInformation("3.6.0.CR1", "3.6", "CR1", false);
ReleaseInformation releaseInformation = new ReleaseInformation("3.6.0.CR1", "3.6", "CR1", false, false);

assertThat(Branches.getPlatformPreparationBranch(releaseInformation)).isEqualTo(Branches.MAIN);
assertThat(Branches.getPlatformReleaseBranch(releaseInformation)).isEqualTo(Branches.MAIN);
}

@Test
void testFirstFinalRelease() {
ReleaseInformation releaseInformation = new ReleaseInformation("3.6.0", "3.6", null, false);
ReleaseInformation releaseInformation = new ReleaseInformation("3.6.0", "3.6", null, false, false);

assertThat(Branches.getPlatformPreparationBranch(releaseInformation)).isEqualTo(Branches.MAIN);
assertThat(Branches.getPlatformReleaseBranch(releaseInformation)).isEqualTo("3.6");
}

@Test
void testBugfixFinalRelease() {
ReleaseInformation releaseInformation = new ReleaseInformation("3.6.1", "3.6", null, false);
ReleaseInformation releaseInformation = new ReleaseInformation("3.6.1", "3.6", null, false, false);

assertThat(Branches.getPlatformPreparationBranch(releaseInformation)).isEqualTo("3.6");
assertThat(Branches.getPlatformReleaseBranch(releaseInformation)).isEqualTo("3.6");
Expand Down
17 changes: 11 additions & 6 deletions src/test/java/io/quarkus/bot/release/IssuesTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ void testExtractReleaseInformationFromForm() {
- [ ] This release is a major version.
""";

assertThat(issues.extractReleaseInformationFromForm(description)).isEqualTo(new ReleaseInformation(null, "3.6", null, false));
assertThat(issues.extractReleaseInformationFromForm(description)).isEqualTo(new ReleaseInformation(null, "3.6", null, false, false));

description = """
### Branch
Expand All @@ -51,14 +51,14 @@ void testExtractReleaseInformationFromForm() {
- [X] This release is a major version.
""";

assertThat(issues.extractReleaseInformationFromForm(description)).isEqualTo(new ReleaseInformation(null, "main", "CR1", true));
assertThat(issues.extractReleaseInformationFromForm(description)).isEqualTo(new ReleaseInformation(null, "main", "CR1", true, false));

assertThrows(IllegalStateException.class, () -> issues.extractReleaseInformationFromForm("foobar"));
}

@Test
void testAppendReleaseInformation() {
assertThat(issues.appendReleaseInformation(new UpdatedIssueBody(""), new ReleaseInformation(null, "3.6", null, false))).isEqualTo("""
assertThat(issues.appendReleaseInformation(new UpdatedIssueBody(""), new ReleaseInformation(null, "3.6", null, false, false))).isEqualTo("""
<!-- quarkus-release/release-information:
Expand All @@ -67,6 +67,7 @@ void testAppendReleaseInformation() {
branch: "3.6"
qualifier: null
major: false
maintenance: false
-->""");

assertThat(issues.appendReleaseInformation(new UpdatedIssueBody("""
Expand All @@ -77,7 +78,8 @@ void testAppendReleaseInformation() {
branch: "3.6"
qualifier: null
major: false
-->"""), new ReleaseInformation("3.7.1", "3.7", "CR1", true))).isEqualTo("""
maintenance: false
-->"""), new ReleaseInformation("3.7.1", "3.7", "CR1", true, false))).isEqualTo("""
This is a comment.
<!-- quarkus-release/release-information:
Expand All @@ -86,6 +88,7 @@ void testAppendReleaseInformation() {
branch: "3.7"
qualifier: "CR1"
major: true
maintenance: false
-->""");
}

Expand All @@ -100,14 +103,15 @@ void testExtractReleaseInformation() {
branch: "4.0"
qualifier: CR1
major: true
maintenance: true
-->
<!-- quarkus-release/release-status:
---
currentStep: "APPROVE_RELEASE"
currentStepStatus: "STARTED"
workflowRunId: 123
-->"""))).isEqualTo(new ReleaseInformation(null, "4.0", "CR1", true));
-->"""))).isEqualTo(new ReleaseInformation(null, "4.0", "CR1", true, true));

assertThat(issues.extractReleaseInformation(new UpdatedIssueBody("""
This is a comment.
Expand All @@ -118,14 +122,15 @@ void testExtractReleaseInformation() {
branch: "4.0"
qualifier: CR1
major: true
maintenance: false
-->
<!-- quarkus-release/release-status:
---
currentStep: "APPROVE_RELEASE"
currentStepStatus: "STARTED"
workflowRunId: 123
-->"""))).isEqualTo(new ReleaseInformation("4.0.0.CR1", "4.0", "CR1", true));
-->"""))).isEqualTo(new ReleaseInformation("4.0.0.CR1", "4.0", "CR1", true, false));
}

@Test
Expand Down

0 comments on commit 2dfc5b4

Please sign in to comment.