Skip to content

Commit

Permalink
Merge pull request #30 from gsmet/third-iteration
Browse files Browse the repository at this point in the history
Handle the Platform release and call a monitoring workflow
  • Loading branch information
gsmet authored Dec 15, 2023
2 parents b6a0b7c + 0f53892 commit 78b43ef
Show file tree
Hide file tree
Showing 14 changed files with 346 additions and 125 deletions.
12 changes: 9 additions & 3 deletions src/main/java/io/quarkus/bot/release/LookingAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,34 @@

import org.jboss.logging.Logger;
import org.kohsuke.github.GHEventPayload;
import org.kohsuke.github.GHUser;
import org.kohsuke.github.Reactable;
import org.kohsuke.github.ReactionContent;

import io.quarkiverse.githubaction.Action;
import io.quarkiverse.githubapp.event.Issue;
import io.quarkiverse.githubapp.event.IssueComment;
import io.quarkus.bot.release.util.Users;

public class LookingAction {

private static final Logger LOG = Logger.getLogger(LookingAction.class);

@Action("looking")
void looking(@Issue.Opened GHEventPayload.Issue issuePayload) {
looking(issuePayload.getIssue());
looking(issuePayload.getSender(), issuePayload.getIssue());
}

@Action("looking")
void looking(@IssueComment.Created GHEventPayload.IssueComment issueCommentPayload) {
looking(issueCommentPayload.getComment());
looking(issueCommentPayload.getSender(), issueCommentPayload.getComment());
}

private void looking(Reactable reactable) {
private void looking(GHUser sender, Reactable reactable) {
if (Users.isIgnored(sender.getLogin())) {
return;
}

try {
reactable.createReaction(ReactionContent.EYES);
} catch (Exception e) {
Expand Down
11 changes: 6 additions & 5 deletions src/main/java/io/quarkus/bot/release/ReleaseAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ void startRelease(Context context, Commands commands, @Issue.Opened GHEventPaylo
throw new IllegalStateException("No RELEASE_GITHUB_TOKEN around");
}

if (!issuePayload.getRepository().hasPermission(issuePayload.getSender(), GHPermissionType.WRITE)) {
if (!issuePayload.getRepository().hasPermission(issuePayload.getSender(), GHPermissionType.WRITE)
|| Users.isIgnored(issuePayload.getSender().getLogin())) {
react(commands, issue, ReactionContent.MINUS_ONE);
issue.comment(":rotating_light: You don't have the permission to start a release.");
issue.close();
Expand Down Expand Up @@ -97,7 +98,7 @@ void onComment(Context context, Commands commands, @IssueComment.Created GHEvent
GHIssue issue = issueCommentPayload.getIssue();
UpdatedIssueBody updatedIssueBody = new UpdatedIssueBody(issue.getBody());

if (Users.isBot(issueCommentPayload.getSender().getLogin())) {
if (Users.isIgnored(issueCommentPayload.getSender().getLogin())) {
return;
}

Expand Down Expand Up @@ -162,7 +163,7 @@ private void handleSteps(Context context, Commands commands, GHIssue issue, Upda
// Handle paused, we will continue the process with the next step
StepHandler stepHandler = getStepHandler(currentReleaseStatus.getCurrentStep());

if (stepHandler.shouldContinue(context, commands, releaseInformation, currentReleaseStatus, issueComment)) {
if (stepHandler.shouldContinue(context, commands, releaseInformation, currentReleaseStatus, issue, issueComment)) {
react(commands, issueComment, ReactionContent.PLUS_ONE);
currentReleaseStatus = currentReleaseStatus.progress(StepStatus.COMPLETED);
updateReleaseStatus(issue, updatedIssueBody, currentReleaseStatus);
Expand Down Expand Up @@ -207,7 +208,7 @@ private void handleSteps(Context context, Commands commands, GHIssue issue, Upda
currentReleaseStatus = currentReleaseStatus.progress(currentStep);
updateReleaseStatus(issue, updatedIssueBody, currentReleaseStatus);

if (currentStepHandler.shouldPause(context, commands, releaseInformation, releaseStatus)) {
if (currentStepHandler.shouldPause(context, commands, releaseInformation, releaseStatus, issue, issueComment)) {
currentReleaseStatus = currentReleaseStatus.progress(StepStatus.PAUSED);
updateReleaseStatus(issue, updatedIssueBody, currentReleaseStatus);
return;
Expand Down Expand Up @@ -271,7 +272,7 @@ private void updateReleaseStatus(GHIssue issue, UpdatedIssueBody updatedIssueBod
private static void react(Commands commands, final Reactable reactable, ReactionContent reactionContent) {
try {
reactable.listReactions().toList().stream()
.filter(r -> Users.isBot(r.getUser().getLogin()))
.filter(r -> Users.isIgnored(r.getUser().getLogin()))
.filter(r -> r.getContent() == ReactionContent.EYES)
.forEach(r -> {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class ApproveCoreRelease implements StepHandler {
Jdks jdks;

@Override
public boolean shouldPause(Context context, Commands commands, ReleaseInformation releaseInformation, ReleaseStatus releaseStatus) {
public boolean shouldPause(Context context, Commands commands, ReleaseInformation releaseInformation, ReleaseStatus releaseStatus, GHIssue issue, GHIssueComment issueComment) {
StringBuilder comment = new StringBuilder();
comment.append("We are going to release the following release:\n\n");
comment.append("- Quarkus `").append(releaseInformation.getVersion()).append("`\n");
Expand All @@ -48,7 +48,7 @@ public boolean shouldPause(Context context, Commands commands, ReleaseInformatio

@Override
public boolean shouldContinue(Context context, Commands commands,
ReleaseInformation releaseInformation, ReleaseStatus releaseStatus, GHIssueComment issueComment) {
ReleaseInformation releaseInformation, ReleaseStatus releaseStatus, GHIssue issue, GHIssueComment issueComment) {
return Command.YES.matches(issueComment.getBody());
}

Expand Down
107 changes: 107 additions & 0 deletions src/main/java/io/quarkus/bot/release/step/PreparePlatform.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
package io.quarkus.bot.release.step;

import java.io.IOException;

import jakarta.inject.Singleton;

import org.kohsuke.github.GHIssue;
import org.kohsuke.github.GHIssueComment;

import io.quarkiverse.githubaction.Commands;
import io.quarkiverse.githubaction.Context;
import io.quarkus.arc.Unremovable;
import io.quarkus.bot.release.ReleaseInformation;
import io.quarkus.bot.release.ReleaseStatus;
import io.quarkus.bot.release.util.Branches;
import io.quarkus.bot.release.util.Command;
import io.quarkus.bot.release.util.Outputs;
import io.quarkus.bot.release.util.UpdatedIssueBody;

@Singleton
@Unremovable
public class PreparePlatform implements StepHandler {

@Override
public boolean shouldPause(Context context, Commands commands, ReleaseInformation releaseInformation,
ReleaseStatus releaseStatus, GHIssue issue, GHIssueComment issueComment) {

String platformPreparationBranch = Branches.getPlatformPreparationBranch(releaseInformation);
String platformReleaseBranch = Branches.getPlatformReleaseBranch(releaseInformation);

StringBuilder comment = new StringBuilder();
if (releaseInformation.isFirstFinal()) {
comment.append("Now is time to update Quarkus in the Quarkus Platform. This is a manual process.\n\n");
comment.append(":warning: **This is the `.0` release so we update the Platform first then wait one week for the Platform members to contribute their updates then we release. Make sure you follow the instructions closely.**\n\n");
} else {
comment.append("Now is time to update Quarkus in the Quarkus Platform. This is a manual process:\n\n");
}

if (!releaseInformation.isFinal()) {
comment.append("* In the case of `preview releases` (e.g. `Alpha1`, `CR1`...), the release will be built from the main branch\n");
}
comment.append("* Then follow (roughly) this process:\n\n");
comment.append("```\n");
comment.append("cd <your quarkus-platform clone>\n");
comment.append("git checkout " + platformPreparationBranch + "\n");
comment.append("git pull upstream " + platformPreparationBranch + "\n");
comment.append("git checkout -b quarkus-" + releaseInformation.getVersion() + "\n");
comment.append("./update-quarkus-version.sh " + releaseInformation.getVersion() + "\n");
comment.append("```\n\n");
comment.append("* Check the diff with `git diff`\n\n");
comment.append("```\n");
comment.append("git add .\n");
comment.append("git commit -m 'Upgrade to Quarkus " + releaseInformation.getVersion() + "'\n");
comment.append("git push origin quarkus-" + releaseInformation.getVersion() + "\n");
comment.append("```\n\n");
comment.append("* [Create a pull request](https://github.com/quarkusio/quarkus-platform/pulls) for branch `" + platformPreparationBranch + "`\n");
comment.append("* Wait for CI to go green\n");
comment.append("* Merge the pull request\n");
if (releaseInformation.isFirstFinal()) {
comment.append("* Send an email to the Platform coordination mailing list: [[email protected]](mailto:[email protected]) :\n\n");
comment.append("> Quarkus " + releaseInformation.getVersion() + " core artifacts are available\n\n");
comment.append("> Hi,\n"
+ "> \n"
+ "> The Quarkus " + releaseInformation.getVersion() + " core artifacts are available on Maven Central.\n"
+ "> \n"
+ "> CI is still running for the upgrade, the pull request will be merged once CI has passed.\n"
+ "> We will ping teams in the pull request if some components have issues.\n\n"
+ "> If you want to update your components, please create your pull requests and make sure they are merged before next Tuesday.\n"
+ "> \n"
+ "> Thanks.\n\n");
comment.append("* If CI failed for some Platform members, please contact them so that they are aware of the issues\n\n");
comment.append(":warning: **IMPORTANT - STOP HERE**\n");
comment.append(":warning: **IMPORTANT - Wait a week before continuing with the Platform release**\n\n");
comment.append("* Make sure you have merged all the pull requests that should be included in this version of the Platform\n\n");
comment.append("* Once all the pull requests are merged, create the branch:\n\n");
comment.append("```\n");
comment.append("git checkout main\n");
comment.append("git pull upstream main\n");
comment.append("git checkout -b " + platformReleaseBranch + "\n");
comment.append("git push upstream " + platformReleaseBranch + "\n");
comment.append("```\n\n");
} else {
comment.append("* Make sure you have merged [all the pull requests](https://github.com/quarkusio/quarkus-platform/pulls) that should be included in this version of the Platform\n\n");
}

comment.append(
"Once everything has been merged to branch `" + platformReleaseBranch + "`, you can continue with the release by adding a `"
+ Command.CONTINUE.getFullCommand() + "` comment.");
commands.setOutput(Outputs.INTERACTION_COMMENT, comment.toString());

return true;
}

@Override
public boolean shouldContinue(Context context, Commands commands,
ReleaseInformation releaseInformation, ReleaseStatus releaseStatus, GHIssue issue, GHIssueComment issueComment) {
return Command.CONTINUE.matches(issueComment.getBody());
}

@Override
public int run(Context context, Commands commands, ReleaseInformation releaseInformation, GHIssue issue,
UpdatedIssueBody updatedIssueBody) throws IOException, InterruptedException {
issue.comment(":white_check_mark: The Platform branch `" + Branches.getPlatformPreparationBranch(releaseInformation)
+ "` is ready to be released, continuing...");
return 0;
}
}
107 changes: 12 additions & 95 deletions src/main/java/io/quarkus/bot/release/step/ReleasePlatform.java
Original file line number Diff line number Diff line change
@@ -1,119 +1,36 @@
package io.quarkus.bot.release.step;

import java.io.IOException;
import java.util.List;

import jakarta.inject.Inject;
import jakarta.inject.Singleton;

import org.kohsuke.github.GHIssue;
import org.kohsuke.github.GHIssueComment;

import io.quarkiverse.githubaction.Commands;
import io.quarkiverse.githubaction.Context;
import io.quarkus.arc.Unremovable;
import io.quarkus.bot.release.ReleaseInformation;
import io.quarkus.bot.release.ReleaseStatus;
import io.quarkus.bot.release.util.Command;
import io.quarkus.bot.release.util.Outputs;
import io.quarkus.bot.release.util.Branches;
import io.quarkus.bot.release.util.Processes;
import io.quarkus.bot.release.util.UpdatedIssueBody;
import io.quarkus.bot.release.util.Versions;

@Singleton
@Unremovable
public class ReleasePlatform implements StepHandler {

@Override
public boolean shouldPause(Context context, Commands commands, ReleaseInformation releaseInformation,
ReleaseStatus releaseStatus) {

String branch;
if (releaseInformation.isFinal()) {
branch = releaseInformation.getBranch();
} else {
branch = "main";
}

StringBuilder comment = new StringBuilder();
if (releaseInformation.isFirstFinal()) {
comment.append("Now is time to update Quarkus in the Quarkus Platform. This is a manual process.\n\n");
comment.append(":warning: **This is the `.0` release so we update the Platform first then wait one week for the Platform members to contribute their updates then we release. Make sure you follow the instructions closely.**\n\n");
} else {
comment.append("Now is time to release the Quarkus Platform. This is a manual process:\n\n");
}
comment.append("* Make sure you have merged [all the pull requests](https://github.com/quarkusio/quarkus-platform/pulls) that should be included in this version of the Platform\n");
comment.append("* Then follow (roughly) this process:\n\n");
comment.append("```\n");
comment.append("cd <your quarkus-platform clone>\n");
comment.append("git checkout " + branch + "\n");
comment.append("git pull upstream " + branch + "\n");
comment.append("git checkout -b quarkus-" + releaseInformation.getVersion() + "\n");
comment.append("./update-quarkus-version.sh " + releaseInformation.getVersion() + "\n");
comment.append("```\n\n");
comment.append("* Check the diff with `git diff`\n\n");
comment.append("```\n");
comment.append("git add .\n");
comment.append("git commit -m 'Upgrade to Quarkus " + releaseInformation.getVersion() + "'\n");
comment.append("git push origin quarkus-" + releaseInformation.getVersion() + "\n");
comment.append("```\n\n");
comment.append("* [Create a pull request](https://github.com/quarkusio/quarkus-platform/pulls) for branch " + branch + "\n");
comment.append("* Wait for CI to go green\n");
comment.append("* Merge the pull request\n");
if (releaseInformation.isFirstFinal()) {
comment.append("* Send an email to the Platform coordination mailing list: [[email protected]](mailto:[email protected]) :\n\n");
comment.append("> Quarkus " + releaseInformation.getVersion() + " core artifacts are available\n\n");
comment.append("> Hi,\n"
+ "> \n"
+ "> The Quarkus " + releaseInformation.getVersion() + " core artifacts are available on Maven Central.\n"
+ "> \n"
+ "> CI is still running for the upgrade, the pull request will be merged once CI has passed.\n"
+ "> We will ping teams in the pull request if some components have issues.\n\n"
+ "> If you want to update your components, please create your pull requests and make sure they are merged before next Tuesday.\n"
+ "> \n"
+ "> Thanks.\n\n");
comment.append("* Merge the pull request when it has passed\n");
comment.append("* If CI fails for some Platform members, please contact them so that they are aware of the issues\n\n");
comment.append(":warning: **IMPORTANT - STOP HERE**\n");
comment.append(":warning: **IMPORTANT - Wait a week before continuing with the Platform release**\n\n");
comment.append("* Make sure you have merged all the pull requests that should be included in this version of the Platform\n\n");
comment.append("```\n");
comment.append("git checkout main\n");
comment.append("git pull upstream main\n");
comment.append("git checkout -b " + releaseInformation.getBranch() + "\n");
comment.append("git push upstream " + releaseInformation.getBranch() + "\n");
comment.append("```\n\n");
} else {
comment.append("```\n");
comment.append("git checkout " + branch + "\n");
comment.append("git pull upstream " + branch + "\n");
comment.append("```\n\n");
}
comment.append("* Then actually release the version with the following line:\n\n");
comment.append("> TAG=" + releaseInformation.getVersion() + " && ./check-version.sh $TAG && ./mvnw release:prepare release:perform -DdevelopmentVersion=999-SNAPSHOT -DreleaseVersion=$TAG -Dtag=$TAG -DperformRelease -Prelease,releaseNexus -DskipTests -Darguments=-DskipTests\n\n");
if (Versions.getVersion(releaseInformation.getBranch()).compareTo(Versions.VERSION_3_2) < 0) {
comment.append("* Release the staging repository **manually** at https://s01.oss.sonatype.org/#stagingRepositories.\n\n");
}
comment.append(
"**IMPORTANT** You need to wait for them to be synced to Maven Central before continuing with the release:\n\n");
comment.append("* Wait for 40 minutes\n");
comment.append("* Check that https://repo1.maven.org/maven2/io/quarkus/platform/quarkus-bom/" + releaseInformation.getVersion() + "/"
+ " does not return a 404\n\n");
comment.append(
"Once these two conditions are met, you can continue with the release by adding a `"
+ Command.CONTINUE.getFullCommand() + "` comment.");
commands.setOutput(Outputs.INTERACTION_COMMENT, comment.toString());

return true;
}

@Override
public boolean shouldContinue(Context context, Commands commands,
ReleaseInformation releaseInformation, ReleaseStatus releaseStatus, GHIssueComment issueComment) {
return Command.CONTINUE.matches(issueComment.getBody());
}
@Inject
Processes processes;

@Override
public int run(Context context, Commands commands, ReleaseInformation releaseInformation, GHIssue issue,
UpdatedIssueBody updatedIssueBody) throws IOException, InterruptedException {
issue.comment(":white_check_mark: Platform artifacts have been synced to Maven Central, continuing...");
return 0;
String platformReleaseBranch = Branches.getPlatformReleaseBranch(releaseInformation);

return processes.execute(List.of(
"./release-platform.sh",
platformReleaseBranch
));
}
}
Loading

0 comments on commit 78b43ef

Please sign in to comment.