Skip to content

Commit

Permalink
Merge pull request #21 from gsmet/finalize-first-iteration
Browse files Browse the repository at this point in the history
Finalize first iteration
  • Loading branch information
gsmet authored Dec 2, 2023
2 parents 78dafc3 + fcbff56 commit 38880d1
Show file tree
Hide file tree
Showing 22 changed files with 462 additions and 305 deletions.
9 changes: 0 additions & 9 deletions action.docker.yml

This file was deleted.

98 changes: 0 additions & 98 deletions src/main/docker/Dockerfile.jvm

This file was deleted.

94 changes: 0 additions & 94 deletions src/main/docker/Dockerfile.legacy-jar

This file was deleted.

27 changes: 0 additions & 27 deletions src/main/docker/Dockerfile.native

This file was deleted.

30 changes: 0 additions & 30 deletions src/main/docker/Dockerfile.native-micro

This file was deleted.

30 changes: 21 additions & 9 deletions src/main/java/io/quarkus/bot/release/ReleaseAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,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(releaseInformation, currentReleaseStatus, issueComment)) {
if (stepHandler.shouldContinue(context, commands, releaseInformation, currentReleaseStatus, issueComment)) {
react(commands, issueComment, ReactionContent.PLUS_ONE);
currentReleaseStatus = currentReleaseStatus.progress(StepStatus.COMPLETED);
updateReleaseStatus(issue, updatedIssueBody, currentReleaseStatus);
Expand All @@ -182,6 +182,8 @@ private void handleSteps(Context context, Commands commands, GHIssue issue, Upda
progressInformation(context, commands, releaseInformation, currentReleaseStatus, issue,
"Proceeding to step " + currentReleaseStatus.getCurrentStep().getDescription());

StepHandler currentStepHandler;

for (Step currentStep : Step.values()) {
if (currentStep.ordinal() < currentReleaseStatus.getCurrentStep().ordinal()) {
// we already handled this step, skipping to next one
Expand All @@ -194,19 +196,20 @@ private void handleSteps(Context context, Commands commands, GHIssue issue, Upda

commands.notice("Running step " + currentStep.getDescription());

currentStepHandler = getStepHandler(currentStep);

try {
StepHandler stepHandler = getStepHandler(currentStep);

currentReleaseStatus = currentReleaseStatus.progress(currentStep);
updateReleaseStatus(issue, updatedIssueBody, currentReleaseStatus);

if (stepHandler.shouldPause(releaseInformation, releaseStatus)) {
if (currentStepHandler.shouldPause(context, commands, releaseInformation, releaseStatus)) {
currentReleaseStatus = currentReleaseStatus.progress(StepStatus.PAUSED);
updateReleaseStatus(issue, updatedIssueBody, currentReleaseStatus);
return;
}

int exitCode = stepHandler.run(context, commands, releaseInformation, issue, updatedIssueBody);
int exitCode = currentStepHandler.run(context, commands, releaseInformation, issue, updatedIssueBody);
handleExitCode(exitCode, currentStep);

currentReleaseStatus = currentReleaseStatus.progress(StepStatus.COMPLETED);
Expand All @@ -218,11 +221,11 @@ private void handleSteps(Context context, Commands commands, GHIssue issue, Upda
} catch (Exception e) {
if (currentStep.isRecoverable()) {
progressError(context, commands, releaseInformation, currentReleaseStatus, issue, updatedIssueBody,
e.getMessage());
e.getMessage(), currentStepHandler.getErrorHelp());
throw e;
} else {
fatalError(context, commands, releaseInformation, currentReleaseStatus, issue, updatedIssueBody,
e.getMessage());
e.getMessage(), currentStepHandler.getErrorHelp());
throw e;
}
}
Expand Down Expand Up @@ -289,11 +292,13 @@ private static void progressInformation(Context context, Commands commands, Rele
}

private void progressError(Context context, Commands commands, ReleaseInformation releaseInformation,
ReleaseStatus releaseStatus, GHIssue issue, UpdatedIssueBody updatedIssueBody, String error) {
ReleaseStatus releaseStatus, GHIssue issue, UpdatedIssueBody updatedIssueBody, String error,
String errorHelp) {
try {
ReleaseStatus currentReleaseStatus = releaseStatus.progress(StepStatus.FAILED);
issue.setBody(issues.appendReleaseStatus(updatedIssueBody, currentReleaseStatus));
commands.setOutput(Outputs.INTERACTION_COMMENT, ":rotating_light: " + error
+ (errorHelp != null && !errorHelp.isBlank() ? "\n\n" + errorHelp : "")
+ "\n\nYou can find more information about the failure [here](" + getWorkflowRunUrl(context) + ").\n\n"
+ "This is not a fatal error, you can retry by adding a `" + Command.RETRY.getFullCommand() + "` comment."
+ youAreHere(releaseInformation, currentReleaseStatus));
Expand All @@ -304,10 +309,17 @@ private void progressError(Context context, Commands commands, ReleaseInformatio

private void fatalError(Context context, Commands commands, ReleaseInformation releaseInformation,
ReleaseStatus releaseStatus, GHIssue issue, UpdatedIssueBody updatedIssueBody, String error) {
fatalError(context, commands, releaseInformation, releaseStatus, issue, updatedIssueBody, error, null);
}

private void fatalError(Context context, Commands commands, ReleaseInformation releaseInformation,
ReleaseStatus releaseStatus, GHIssue issue, UpdatedIssueBody updatedIssueBody, String error, String errorHelp) {
try {
ReleaseStatus currentReleaseStatus = releaseStatus.progress(Status.FAILED, StepStatus.FAILED);
issue.setBody(issues.appendReleaseStatus(updatedIssueBody, currentReleaseStatus));
issue.comment(":rotating_light: " + error + "\n\nYou can find more information about the failure [here]("
issue.comment(":rotating_light: " + error
+ (errorHelp != null && !errorHelp.isBlank() ? "\n\n" + errorHelp : "")
+ "\n\nYou can find more information about the failure [here]("
+ getWorkflowRunUrl(context) + ").\n\n"
+ "This is a fatal error, the issue will be closed."
+ youAreHere(releaseInformation, currentReleaseStatus));
Expand All @@ -322,7 +334,7 @@ private static String getWorkflowRunUrl(Context context) {
}

private static String youAreHere(ReleaseInformation releaseInformation, ReleaseStatus releaseStatus) {
return "\n\n<details><summary>You are here</summary>\n\n" +
return "\n\n<details><summary>Where am I?</summary>\n\n" +
Arrays.stream(Step.values())
.filter(s -> releaseInformation.isFinal() || !s.isForFinalReleasesOnly())
.map(s -> {
Expand Down
Loading

0 comments on commit 38880d1

Please sign in to comment.