-
Notifications
You must be signed in to change notification settings - Fork 100
re-run failed tests using check-run re-run failed button
#4922
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
Conversation
|
autosubmit label was removed for flutter/cocoon/4922, because - The status or check suite common-validations has failed. Please fix the issues identified (or deflake) before re-applying this label. |
re-run failed button
| /// Contains the list of failed checks that are proposed to be re-run. | ||
| /// | ||
| /// See: [UnifiedCheckRun.reInitializeFailedChecks] | ||
| class FailedChecksForRerun { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note to self, i wonder if we should use @freezed here - we don't currently have it as a dependency, so don't treat this as a request for anything.
| final failedBuilds = guard.builds?.entries | ||
| .where((entry) => entry.value.isFailure) | ||
| .map((entry) => entry.key) | ||
| .toList(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this method could be added to the PresubmitGuard to provide a getter for "failedBuilds"
final failedBuilds = [
for (final Map(:key, :value) in guard.builds?.entries)
if (value.isFailure)
key,
];| if (checkRunEvent.requestedAction?.identifier == 're_run_failed') { | ||
| log.info( | ||
| 'Requested to re-run failed tests for ${checkRunEvent.checkRun!.id} check-run id', | ||
| ); | ||
| // The CheckRunEvent.checkRun.pullRequests array is empty for this | ||
| // event, so we need to find the matching pull request. | ||
| final slug = checkRunEvent.repository!.slug(); | ||
| final headSha = checkRunEvent.checkRun!.headSha!; | ||
| final checkSuiteId = checkRunEvent.checkRun!.checkSuite!.id!; | ||
| final pullRequest = await _githubChecksService | ||
| .findMatchingPullRequest(slug, headSha, checkSuiteId); | ||
|
|
||
| final failedChecks = await UnifiedCheckRun.reInitializeFailedChecks( | ||
| firestoreService: _firestore, | ||
| slug: slug, | ||
| pullRequestId: pullRequest!.number!, | ||
| checkRunId: checkRunEvent.checkRun!.id!, | ||
| ); | ||
|
|
||
| if (failedChecks == null) { | ||
| log.error( | ||
| 'No failed targets found for ${checkRunEvent.checkRun!.id} check-run id', | ||
| ); | ||
| return ProcessCheckRunResult.missingEntity( | ||
| 'No failed targets found for ${checkRunEvent.checkRun!.id} check-run id', | ||
| ); | ||
| } | ||
|
|
||
| final (targets, artifacts) = await _getAllTargetsForPullRequest( | ||
| slug, | ||
| pullRequest, | ||
| ); | ||
|
|
||
| final failedTargets = targets | ||
| .where((target) => failedChecks.checkNames.contains(target.name)) | ||
| .toList(); | ||
| if (failedTargets.length != failedChecks.checkNames.length) { | ||
| log.error('Failed to find all failed targets in presubmit targets'); | ||
| return const ProcessCheckRunResult.missingEntity( | ||
| 'Failed to find all failed targets in presubmit targets', | ||
| ); | ||
| } | ||
|
|
||
| await _luciBuildService.scheduleTryBuilds( | ||
| targets: failedTargets, | ||
| pullRequest: pullRequest, | ||
| engineArtifacts: artifacts, | ||
| checkRunGuard: failedChecks.checkRunGuard, | ||
| stage: failedChecks.stage, | ||
| ); | ||
| } else { | ||
| log.warn( | ||
| 'Requested unexpected action: ${checkRunEvent.requestedAction?.identifier} for ${checkRunEvent.checkRun!.id} check-run id', | ||
| ); | ||
| } | ||
| break; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you could move this out to a "_reRunFailed" and then we could just:
switch (checkRunEvent.requestedAction?.identifier) {
case 're_run_failed':
_reRunFailed(pr);
default:
log.warn(
'Requested unexpected action: ${checkRunEvent.requestedAction?.identifier} for ${checkRunEvent.checkRun!.id} check-run id',
);
}implemented comments from: #4922 Fixes: flutter/flutter#181334
Re-run failed tests using check-run
re-run failedbutton added toMerge Queue Guardcheck-run when tests failed andMerge Queue Guardcheck-runconclusionchanged toaction_requiredon git-hub UIGitHub API used:
https://docs.github.com/en/rest/guides/using-the-rest-api-to-interact-with-checks?apiVersion=2022-11-28#check-runs-and-requested-actions
https://docs.github.com/en/webhooks/webhook-events-and-payloads?actionType=requested_action#check_run
Fixes: flutter/flutter#181334