Skip to content

Conversation

@ievdokdm
Copy link
Contributor

@ievdokdm ievdokdm commented Jan 21, 2026

Re-run failed tests using check-run re-run failed button added to Merge Queue Guard check-run when tests failed and Merge Queue Guard check-run conclusion changed to action_required on git-hub UI

GitHub 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

@ievdokdm ievdokdm requested a review from jtmcdole January 21, 2026 01:41
@ievdokdm ievdokdm added the autosubmit Merge PR when tree becomes green via auto submit App. label Jan 21, 2026
@auto-submit
Copy link
Contributor

auto-submit bot commented Jan 22, 2026

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.

@auto-submit auto-submit bot removed the autosubmit Merge PR when tree becomes green via auto submit App. label Jan 22, 2026
@ievdokdm ievdokdm changed the title boilerplate for re-run failed tests re-run failed tests using check-run re-run failed button Jan 22, 2026
@ievdokdm ievdokdm added the autosubmit Merge PR when tree becomes green via auto submit App. label Jan 22, 2026
/// Contains the list of failed checks that are proposed to be re-run.
///
/// See: [UnifiedCheckRun.reInitializeFailedChecks]
class FailedChecksForRerun {
Copy link
Member

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.

Comment on lines +101 to +104
final failedBuilds = guard.builds?.entries
.where((entry) => entry.value.isFailure)
.map((entry) => entry.key)
.toList();
Copy link
Member

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,
];

Comment on lines +1626 to +1681
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;
Copy link
Member

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',
    );
}

@auto-submit auto-submit bot merged commit 9b4f9da into flutter:main Jan 22, 2026
17 checks passed
@ievdokdm ievdokdm mentioned this pull request Jan 22, 2026
auto-submit bot pushed a commit that referenced this pull request Jan 22, 2026
implemented comments from: #4922
Fixes: flutter/flutter#181334
@ievdokdm ievdokdm deleted the 176982-checkrun-actions branch January 22, 2026 22:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autosubmit Merge PR when tree becomes green via auto submit App.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement re-run failed checks flow

2 participants