Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions app_dart/lib/src/foundation/github_checks_util.dart
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ class GithubChecksUtil {
github.CheckRunConclusion? conclusion,
String? detailsUrl,
github.CheckRunOutput? output,
List<github.CheckRunAction>? actions,
}) async {
const r = RetryOptions(maxAttempts: 3, delayFactor: Duration(seconds: 2));
return r.retry(
Expand All @@ -88,6 +89,7 @@ class GithubChecksUtil {
conclusion: conclusion,
detailsUrl: detailsUrl,
output: output,
actions: actions,
);
},
retryIf: (Exception e) => e is github.GitHubError || e is SocketException,
Expand Down
40 changes: 40 additions & 0 deletions app_dart/lib/src/model/common/failed_presubmit_checks.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Copyright 2026 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

/// @docImport 'failed_presubmit_checks.dart';
library;

import 'package:github/github.dart';

import '../firestore/base.dart';

/// 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.

final CheckRun checkRunGuard;
final CiStage stage;
final List<String> checkNames;

const FailedChecksForRerun({
required this.checkRunGuard,
required this.stage,
required this.checkNames,
});

@override
bool operator ==(Object other) =>
identical(this, other) ||
(other is FailedChecksForRerun &&
other.checkRunGuard == checkRunGuard &&
other.stage == stage &&
other.checkNames == checkNames);

@override
int get hashCode => Object.hashAll([checkRunGuard, stage, checkNames]);

@override
String toString() =>
'FailedChecksForRerun("$checkRunGuard", "$stage", "$checkNames")';
}
6 changes: 3 additions & 3 deletions app_dart/lib/src/model/firestore/presubmit_check.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ import '../../service/firestore.dart';
import '../bbv2_extension.dart';
import 'base.dart';

const String collectionId = 'presubmit_checks';

@immutable
final class PresubmitCheckId extends AppDocumentId<PresubmitCheck> {
PresubmitCheckId({
Expand Down Expand Up @@ -87,6 +85,7 @@ final class PresubmitCheckId extends AppDocumentId<PresubmitCheck> {
}

final class PresubmitCheck extends AppDocument<PresubmitCheck> {
static const collectionId = 'presubmit_checks';
static const fieldCheckRunId = 'checkRunId';
static const fieldBuildName = 'buildName';
static const fieldBuildNumber = 'buildNumber';
Expand Down Expand Up @@ -181,10 +180,11 @@ final class PresubmitCheck extends AppDocument<PresubmitCheck> {
required String buildName,
required int checkRunId,
required int creationTime,
int? attemptNumber,
}) {
return PresubmitCheck(
buildName: buildName,
attemptNumber: 1,
attemptNumber: attemptNumber ?? 1,
checkRunId: checkRunId,
creationTime: creationTime,
status: TaskStatus.waitingForBackfill,
Expand Down
44 changes: 34 additions & 10 deletions app_dart/lib/src/model/firestore/presubmit_guard.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ final class PresubmitGuardId extends AppDocumentId<PresubmitGuard> {
final class PresubmitGuard extends AppDocument<PresubmitGuard> {
static const collectionId = 'presubmit_guards';
static const fieldCheckRun = 'check_run';
static const fieldCheckRunId = 'check_run_id';
static const fieldPullRequestId = 'pull_request_id';
static const fieldSlug = 'slug';
static const fieldStage = 'stage';
static const fieldCommitSha = 'commit_sha';
static const fieldAuthor = 'author';
static const fieldCreationTime = 'creation_time';
Expand All @@ -60,12 +64,14 @@ final class PresubmitGuard extends AppDocument<PresubmitGuard> {
required int pullRequestId,
required int checkRunId,
required CiStage stage,
}) => PresubmitGuardId(
slug: slug,
pullRequestId: pullRequestId,
checkRunId: checkRunId,
stage: stage,
);
}) {
return PresubmitGuardId(
slug: slug,
pullRequestId: pullRequestId,
checkRunId: checkRunId,
stage: stage,
);
}

/// Returns a firebase documentName used in [fromFirestore].
static String documentNameFor({
Expand Down Expand Up @@ -136,18 +142,22 @@ final class PresubmitGuard extends AppDocument<PresubmitGuard> {
required CiStage stage,
required int creationTime,
required String author,
int? remainingBuilds,
int? failedBuilds,
required int remainingBuilds,
required int failedBuilds,
Map<String, TaskStatus>? builds,
}) {
return PresubmitGuard._(
{
fieldCheckRunId: checkRun.id!.toValue(),
fieldPullRequestId: pullRequestId.toValue(),
fieldSlug: slug.fullName.toValue(),
fieldStage: stage.name.toValue(),
fieldCommitSha: commitSha.toValue(),
fieldCreationTime: creationTime.toValue(),
fieldAuthor: author.toValue(),
fieldCheckRun: json.encode(checkRun.toJson()).toValue(),
fieldRemainingBuilds: ?remainingBuilds?.toValue(),
fieldFailedBuilds: ?failedBuilds?.toValue(),
fieldRemainingBuilds: remainingBuilds.toValue(),
fieldFailedBuilds: failedBuilds.toValue(),
if (builds != null)
fieldBuilds: Value(
mapValue: MapValue(
Expand Down Expand Up @@ -196,27 +206,41 @@ final class PresubmitGuard extends AppDocument<PresubmitGuard> {

/// The repository that this stage is recorded for.
RepositorySlug get slug {
if (fields[fieldSlug] != null) {
return RepositorySlug.full(fields[fieldSlug]!.stringValue!);
}
// Read it from the document name.
final [owner, repo, _, _, _] = p.posix.basename(name!).split('_');
return RepositorySlug(owner, repo);
}

/// The pull request for which this stage is recorded for.
int get pullRequestId {
if (fields[fieldPullRequestId] != null) {
return int.parse(fields[fieldPullRequestId]!.integerValue!);
}
// Read it from the document name.
final [_, _, pullRequestId, _, _] = p.posix.basename(name!).split('_');
return int.parse(pullRequestId);
}

/// Which commit this stage is recorded for.
int get checkRunId {
if (fields[fieldCheckRunId] != null) {
return int.parse(fields[fieldCheckRunId]!.integerValue!);
}
// Read it from the document name.
final [_, _, _, checkRunId, _] = p.posix.basename(name!).split('_');
return int.parse(checkRunId);
}

/// The stage of the CI process.
CiStage get stage {
if (fields[fieldStage] != null) {
return CiStage.values.firstWhere(
(e) => e.name == fields[fieldStage]!.stringValue!,
);
}
// Read it from the document name.
final [_, _, _, _, stageName] = p.posix.basename(name!).split('_');
return CiStage.values.firstWhere((e) => e.name == stageName);
Expand Down
18 changes: 18 additions & 0 deletions app_dart/lib/src/model/github/checks.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class CheckRunEvent extends HookEvent {
String? action;
User? sender;
Repository? repository;
RequestedAction? requestedAction;

Map<String, dynamic> toJson() => _$CheckRunEventToJson(this);

Expand Down Expand Up @@ -63,6 +64,23 @@ class CheckRun {
}
}

/// Data model for a `requested_action` event.
@JsonSerializable(fieldRename: FieldRename.snake)
class RequestedAction {
const RequestedAction({required this.identifier});

factory RequestedAction.fromJson(Map<String, dynamic> input) =>
_$RequestedActionFromJson(input);
final String identifier;

Map<String, dynamic> toJson() => _$RequestedActionToJson(this);

@override
String toString() {
return 'RequestedAction ${const JsonEncoder.withIndent(' ').convert(toJson())}';
}
}

/// Data model for a `merge_group` event.
///
/// The event may request one of two actions:
Expand Down
32 changes: 22 additions & 10 deletions app_dart/lib/src/model/github/checks.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions app_dart/lib/src/service/firestore.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const String kFieldFilterOpNotEqual = 'NOT_EQUAL';
const String kCompositeFilterOpAnd = 'AND';
const String kCompositeFilterOpOr = 'OR';
const String kQueryOrderDescending = 'DESCENDING';
const String kQueryOrderAscending = 'ASCENDING';

const int kFilterStringSpaceSplitElements = 2;
const int kFilterStringSpaceSplitOpIndex = 1;
Expand Down
Loading
Loading