Skip to content

Commit ee5fc1f

Browse files
authored
Merge pull request #23 from gsmet/add-more-information-2
Some refinements for added information
2 parents c36bdc7 + 54ff42c commit ee5fc1f

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

action.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ inputs:
2525
quarkus-sha:
2626
description: 'The Git sha of the Quarkus build used to run the tests'
2727
required: false
28+
project-sha:
29+
description: 'The Git sha of the project currently under test'
30+
required: false
2831

2932
runs:
3033
using: "composite"

src/main/java/io/quarkus/bot/reportstatus/InputKeys.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ private InputKeys() {
1111
static final String REPOSITORY = "repository";
1212
static final String RUN_ID = "run-id";
1313
static final String QUARKUS_SHA = "quarkus-sha";
14+
static final String PROJECT_SHA = "project-sha";
1415
}

src/main/java/io/quarkus/bot/reportstatus/ReportStatusInIssue.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,10 @@ void reportStatus(Commands commands, Inputs inputs, Context context) throws IOEx
6868
commands.notice(String.format("The issue is currently %s", issue.getState().toString()));
6969
}
7070

71+
String quarkusSha = inputs.get(InputKeys.QUARKUS_SHA).orElse(null);
72+
String projectSha = inputs.get(InputKeys.PROJECT_SHA).orElse(null);
7173
Status existingStatus = extractStatus(issue.getBody());
72-
State newState = new State(Instant.now(), context.getGitHubSha(), inputs.get(InputKeys.QUARKUS_SHA).orElse(null));
74+
State newState = new State(Instant.now(), quarkusSha, projectSha);
7375

7476
final State firstFailure;
7577
final State lastFailure;
@@ -100,7 +102,8 @@ void reportStatus(Commands commands, Inputs inputs, Context context) throws IOEx
100102
commands.notice(String.format("Comment added on issue %s - %s", issue.getHtmlUrl().toString(),
101103
comment.getHtmlUrl().toString()));
102104

103-
firstFailure = State.KEEP_EXISTING;
105+
// for old reports, we won't have the first failure previously set so let's set it to the new state as an approximation
106+
firstFailure = existingStatus.firstFailure() != null ? State.KEEP_EXISTING : newState;
104107
} else {
105108
issue.reopen();
106109
final GHIssueComment comment = issue.comment(String.format(
@@ -115,12 +118,12 @@ void reportStatus(Commands commands, Inputs inputs, Context context) throws IOEx
115118

116119
Status newStatus;
117120
if (existingStatus != null) {
118-
newStatus = new Status(Instant.now(), !succeed, repositoryName, runId,
121+
newStatus = new Status(Instant.now(), !succeed, repositoryName, runId, quarkusSha, projectSha,
119122
firstFailure == State.KEEP_EXISTING ? existingStatus.firstFailure() : firstFailure,
120123
lastFailure == State.KEEP_EXISTING ? existingStatus.lastFailure() : lastFailure,
121124
lastSuccess == State.KEEP_EXISTING ? existingStatus.lastSuccess() : lastSuccess);
122125
} else {
123-
newStatus = new Status(Instant.now(), !succeed, repositoryName, runId,
126+
newStatus = new Status(Instant.now(), !succeed, repositoryName, runId, quarkusSha, projectSha,
124127
firstFailure, lastFailure, lastSuccess);
125128
}
126129

@@ -164,7 +167,7 @@ public Status extractStatus(String body) {
164167
}
165168

166169
public record Status(Instant updatedAt, boolean failure, String repository, Long runId,
167-
State firstFailure, State lastFailure, State lastSuccess) {
170+
String quarkusSha, String projectSha, State firstFailure, State lastFailure, State lastSuccess) {
168171
}
169172

170173
public record State(Instant date, String quarkusSha, String projectSha) {

0 commit comments

Comments
 (0)