Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support emergency releases for LTS regular release cadence #186

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 34 additions & 5 deletions src/main/java/io/quarkus/bot/release/ReleaseInformation.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,21 @@ public class ReleaseInformation {
private final String branch;
private final String originBranch;
private final String qualifier;
private final boolean emergency;
private final boolean major;

private String version;
private boolean firstFinal;
private boolean maintenance;

@JsonCreator
public ReleaseInformation(String version, String branch, String originBranch, String qualifier, boolean major,
boolean firstFinal, boolean maintenance) {
public ReleaseInformation(String version, String branch, String originBranch, String qualifier, boolean emergency,
boolean major, boolean firstFinal, boolean maintenance) {
this.version = version;
this.branch = branch;
this.originBranch = originBranch;
this.qualifier = qualifier;
this.emergency = emergency;
this.major = major;
this.firstFinal = firstFinal;
this.maintenance = maintenance;
Expand Down Expand Up @@ -93,6 +95,10 @@ public void setVersion(String version, boolean firstFinal, boolean maintenance)
this.version = version;
this.firstFinal = firstFinal;
this.maintenance = maintenance;

if (firstFinal && emergency) {
throw new IllegalStateException("An emergency release may not be the first final release of a branch");
}
}

@JsonIgnore
Expand Down Expand Up @@ -152,6 +158,13 @@ public boolean isMajor() {
return major;
}

/**
* @return whether this is an emergency release (e.g. 3.17.7.1). Emergency releases are only used for LTS branches with regular release cadence.
*/
public boolean isEmergency() {
return emergency;
}

/**
* @return whether the origin branch for creating the branch is the main branch (see {@link #getOriginBranch()} for more
* details)
Expand All @@ -175,9 +188,24 @@ public boolean isLtsMaintenanceReleaseWithRegularReleaseCadence() {
return Branches.isLtsBranchWithRegularReleaseCadence(branch) && isFinal() && !isFirstFinal();
}

@JsonIgnore
public void checkConsistency() {
if (emergency) {
if (!Branches.isLtsBranchWithRegularReleaseCadence(branch)) {
throw new IllegalStateException("Emergency releases are only supported for LTS branches with regular release cadence.");
}
if (major) {
throw new IllegalStateException("A release may not be both an emergency and a major release");
}
if (qualifier != null) {
throw new IllegalStateException("An emergency release may not have a qualifier");
}
}
}

@Override
public int hashCode() {
return Objects.hash(branch, major, qualifier);
return Objects.hash(branch, qualifier, emergency, major);
}

@Override
Expand All @@ -192,6 +220,7 @@ public boolean equals(Object obj) {
return Objects.equals(version, this.version)
&& Objects.equals(branch, other.branch)
&& Objects.equals(originBranch, other.originBranch)
&& emergency == other.emergency
&& major == other.major
&& Objects.equals(qualifier, other.qualifier)
&& firstFinal == other.firstFinal
Expand All @@ -201,8 +230,8 @@ public boolean equals(Object obj) {
@Override
public String toString() {
return "ReleaseInformation [version=" + version + ", branch=" + branch + ", originBranch=" + originBranch
+ ", qualifier=" + qualifier + ", major=" + major
+ ",firstFinal=" + firstFinal + ",maintenance=" + maintenance
+ ", qualifier=" + qualifier + ", emergency=" + emergency + ", major=" + major
+ ", firstFinal=" + firstFinal + ", maintenance=" + maintenance
+ "]";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ public boolean shouldPause(Context context, Commands commands, GitHub quarkusBot
if (releaseInformation.isMaintenance()) {
comment.append("- This is a `maintenance` release.\n");
}
if (releaseInformation.isEmergency()) {
comment.append("- This is an `emergency` release.\n");
}
if (!releaseInformation.isFinal()) {
comment.append("- This is a `preview` release (e.g. `Alpha`, `Beta`, `CR`).\n");
}
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/io/quarkus/bot/release/step/Prerequisites.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ public int run(Context context, Commands commands, GitHub quarkusBotGitHub, Rele
if (releaseInformation.getQualifier() != null) {
command.add("--qualifier=" + releaseInformation.getQualifier());
}
if (releaseInformation.isEmergency()) {
command.add("--emergency");
}
if (releaseInformation.isMajor()) {
command.add("--major");
}
Expand Down
26 changes: 21 additions & 5 deletions src/main/java/io/quarkus/bot/release/util/Issues.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public final class Issues {

private static final String BRANCH = "### Branch";
private static final String QUALIFIER = "### Qualifier";
private static final String EMERGENCY_RELEASE = "### Emergency release";
private static final String MAJOR_VERSION = "### Major version";
private static final String ORIGIN_BRANCH = "### Origin branch";
private static final String NO_RESPONSE = "_No response_";
Expand All @@ -38,10 +39,12 @@ public ReleaseInformation extractReleaseInformationFromForm(String description)
String branch = null;
String qualifier = null;
boolean major = false;
boolean emergency = false;
String originBranch = Branches.MAIN;

boolean inBranch = false;
boolean inQualifier = false;
boolean inEmergencyRelease = false;
boolean inMajor = false;
boolean inOriginBranch = false;

Expand All @@ -57,6 +60,10 @@ public ReleaseInformation extractReleaseInformationFromForm(String description)
inQualifier = true;
continue;
}
if (EMERGENCY_RELEASE.equals(line)) {
inEmergencyRelease = true;
continue;
}
if (MAJOR_VERSION.equals(line)) {
inMajor = true;
continue;
Expand All @@ -75,23 +82,32 @@ public ReleaseInformation extractReleaseInformationFromForm(String description)
inQualifier = false;
continue;
}
if (inMajor) {
major = line.contains("[X]");
inMajor = false;
break;
if (inEmergencyRelease) {
emergency = line.contains("[X]");
inEmergencyRelease = false;
continue;
}
if (inOriginBranch) {
originBranch = NO_RESPONSE.equals(line) ? Branches.MAIN : line;
inOriginBranch = false;
continue;
}
if (inMajor) {
major = line.contains("[X]");
inMajor = false;
break;
}
}

if (branch == null) {
throw new IllegalStateException("Unable to extract a branch from the description");
}

return new ReleaseInformation(null, branch, originBranch, qualifier, major, false, false);
ReleaseInformation releaseInformation = new ReleaseInformation(null, branch, originBranch, qualifier, emergency, major, false, false);

releaseInformation.checkConsistency();

return releaseInformation;
}

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", Branches.MAIN, "CR1", false, false, false);
ReleaseInformation releaseInformation = new ReleaseInformation("3.6.0.CR1", "3.6", Branches.MAIN, "CR1", false, false, 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", Branches.MAIN, null, false, true, false);
ReleaseInformation releaseInformation = new ReleaseInformation("3.6.0", "3.6", Branches.MAIN, null, false, false, true, 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", Branches.MAIN, null, false, false, false);
ReleaseInformation releaseInformation = new ReleaseInformation("3.6.1", "3.6", Branches.MAIN, null, false, false, false, false);

assertThat(Branches.getPlatformPreparationBranch(releaseInformation)).isEqualTo("3.6");
assertThat(Branches.getPlatformReleaseBranch(releaseInformation)).isEqualTo("3.6");
Expand Down
Loading
Loading