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: 1 addition & 1 deletion app_dart/lib/cocoon_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ export 'src/foundation/utils.dart';
export 'src/model/firestore/base.dart' hide AppDocument;
export 'src/model/firestore/commit.dart';
export 'src/model/firestore/pr_check_runs.dart';
export 'src/model/firestore/presubmit_check.dart';
export 'src/model/firestore/presubmit_guard.dart';
export 'src/model/firestore/presubmit_job.dart';
export 'src/model/firestore/suppressed_test.dart';
export 'src/model/firestore/task.dart';
export 'src/model/firestore/tree_status_change.dart';
Expand Down
4 changes: 2 additions & 2 deletions app_dart/lib/server.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import 'dart:math';

import 'cocoon_service.dart';
import 'src/request_handlers/get_engine_artifacts_ready.dart';
import 'src/request_handlers/get_presubmit_checks.dart';
import 'src/request_handlers/get_presubmit_guard.dart';
import 'src/request_handlers/get_presubmit_guard_summaries.dart';
import 'src/request_handlers/get_presubmit_jobs.dart';
import 'src/request_handlers/get_tree_status_changes.dart';
import 'src/request_handlers/github_webhook_replay.dart';
import 'src/request_handlers/lookup_hash.dart';
Expand Down Expand Up @@ -207,7 +207,7 @@ Server createServer({
config: config,
firestore: firestore,
),
'/api/public/get-presubmit-checks': GetPresubmitChecks(
'/api/public/get-presubmit-jobs': GetPresubmitJobs(
config: config,
firestore: firestore,
),
Expand Down
2 changes: 1 addition & 1 deletion app_dart/lib/src/generated_config.dart

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

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// 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';
/// @docImport 'failed_presubmit_jobs.dart';
library;

import 'package:collection/collection.dart';
Expand All @@ -11,40 +11,37 @@ import 'package:github/github.dart';

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

/// Contains the list of failed checks that are proposed to be re-run.
/// Contains the list of failed jobs that are proposed to be re-run.
///
/// See: [UnifiedCheckRun.reInitializeFailedChecks]
class FailedChecksForRerun {
/// See: [UnifiedCheckRun.reInitializeFailedJobs]
class FailedJobsForRerun {
final CheckRun checkRunGuard;
final CiStage stage;
final Map<String, int> checkRetries;
final Map<String, int> jobRetries;

const FailedChecksForRerun({
const FailedJobsForRerun({
required this.checkRunGuard,
required this.stage,
required this.checkRetries,
required this.jobRetries,
});

@override
bool operator ==(Object other) =>
identical(this, other) ||
(other is FailedChecksForRerun &&
(other is FailedJobsForRerun &&
other.checkRunGuard == checkRunGuard &&
other.stage == stage &&
const DeepCollectionEquality().equals(
other.checkRetries,
checkRetries,
));
const DeepCollectionEquality().equals(other.jobRetries, jobRetries));

@override
int get hashCode => Object.hashAll([
checkRunGuard,
stage,
...checkRetries.keys,
...checkRetries.values,
...jobRetries.keys,
...jobRetries.values,
]);

@override
String toString() =>
'FailedChecksForRerun("$checkRunGuard", "$stage", "$checkRetries")';
'FailedChecksForRerun("$checkRunGuard", "$stage", "$jobRetries")';
}
36 changes: 18 additions & 18 deletions app_dart/lib/src/model/common/presubmit_completed_check.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ import '../firestore/base.dart';
import '../firestore/presubmit_guard.dart';
import '../github/checks.dart' as cocoon_checks;
import 'checks_extension.dart';
import 'presubmit_check_state.dart';
import 'presubmit_job_state.dart';

/// Unified representation of a completed presubmit check.
/// Unified representation of a completed presubmit job.
///
/// This class abstracts away the source of the check (GitHub CheckRun or BuildBucket Build)
/// This class abstracts away the source of the job (GitHub CheckRun or BuildBucket Build)
/// to allow unified processing logic.
@immutable
class PresubmitCompletedCheck {
class PresubmitCompletedJob {
final String name;
final String sha;
final RepositorySlug slug;
Expand All @@ -35,14 +35,14 @@ class PresubmitCompletedCheck {
final String? headBranch;
final bool isUnifiedCheckRun;
final CiStage? stage;
final int? pullRequestNumber;
final int? prNum;
final int attempt;
final int? startTime;
final int? endTime;
final String? summary;
final int? buildNumber;

const PresubmitCompletedCheck({
const PresubmitCompletedJob({
required this.name,
required this.sha,
required this.slug,
Expand All @@ -53,20 +53,20 @@ class PresubmitCompletedCheck {
required this.headBranch,
required this.isUnifiedCheckRun,
this.stage,
this.pullRequestNumber,
this.prNum,
this.attempt = 1,
this.startTime,
this.endTime,
this.summary,
this.buildNumber,
});

/// Creates a [PresubmitCompletedCheck] from a GitHub [CheckRun].
factory PresubmitCompletedCheck.fromCheckRun(
/// Creates a [PresubmitCompletedJob] from a GitHub [CheckRun].
factory PresubmitCompletedJob.fromCheckRun(
cocoon_checks.CheckRun checkRun,
RepositorySlug slug,
) {
return PresubmitCompletedCheck(
return PresubmitCompletedJob(
name: checkRun.name!,
sha: checkRun.headSha!,
slug: slug,
Expand All @@ -84,13 +84,13 @@ class PresubmitCompletedCheck {
);
}

/// Creates a [PresubmitCompletedCheck] from a BuildBucket [Build].
factory PresubmitCompletedCheck.fromBuild(
/// Creates a [PresubmitCompletedJob] from a BuildBucket [Build].
factory PresubmitCompletedJob.fromBuild(
Build build,
PresubmitUserData userData, {
TaskStatus? status,
}) {
return PresubmitCompletedCheck(
return PresubmitCompletedJob(
name: build.builder.builder,
sha: userData.commit.sha,
slug: userData.commit.slug,
Expand All @@ -101,7 +101,7 @@ class PresubmitCompletedCheck {
headBranch: userData.commit.branch,
isUnifiedCheckRun: userData.guardCheckRunId != null,
stage: userData.stage,
pullRequestNumber: userData.pullRequestNumber,
prNum: userData.pullRequestNumber,
attempt: _getAttempt(build),
startTime: build.startTime.toDateTime().microsecondsSinceEpoch,
endTime: build.endTime.toDateTime().microsecondsSinceEpoch,
Expand Down Expand Up @@ -134,15 +134,15 @@ class PresubmitCompletedCheck {
PresubmitGuardId get guardId {
return PresubmitGuardId(
slug: slug,
pullRequestId: pullRequestNumber ?? 0,
prNum: prNum ?? 0,
checkRunId: checkRunId,
stage: stage ?? CiStage.fusionTests,
);
}

PresubmitCheckState get state {
return PresubmitCheckState(
buildName: name,
PresubmitJobState get state {
return PresubmitJobState(
jobName: name,
status: status,
attemptNumber: attempt,
startTime: startTime,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

/// @docImport 'presubmit_check_state.dart';
/// @docImport 'presubmit_job_state.dart';
library;

import 'package:buildbucket/buildbucket_pb.dart' as bbv2;
Expand All @@ -12,17 +12,17 @@ import '../../service/luci_build_service/build_tags.dart';
import '../bbv2_extension.dart';

/// Represents the current state of a check run.
class PresubmitCheckState {
final String buildName;
class PresubmitJobState {
final String jobName;
final TaskStatus status;
final int attemptNumber; //static int _currentAttempt(BuildTags buildTags)
final int? startTime;
final int? endTime;
final String? summary;
final int? buildNumber;

const PresubmitCheckState({
required this.buildName,
const PresubmitJobState({
required this.jobName,
required this.status,
required this.attemptNumber,
this.startTime,
Expand All @@ -32,9 +32,9 @@ class PresubmitCheckState {
});
}

extension BuildToPresubmitCheckState on bbv2.Build {
PresubmitCheckState toPresubmitCheckState() => PresubmitCheckState(
buildName: builder.builder,
extension BuildToPresubmitJobState on bbv2.Build {
PresubmitJobState toPresubmitJobState() => PresubmitJobState(
jobName: builder.builder,
status: status.toTaskStatus(),
attemptNumber: BuildTags.fromStringPairs(tags).currentAttempt,
startTime: startTime.toDateTime().microsecondsSinceEpoch,
Expand Down
Loading
Loading