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
4 changes: 2 additions & 2 deletions app_dart/lib/src/model/common/checks_extension.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ extension ChecksExtension on TaskStatus {
TaskStatus.failed || TaskStatus.infraFailure => 'failure',
TaskStatus.cancelled => 'cancelled',
TaskStatus.skipped => 'skipped',
_ => 'neutral',
_ => '',
};
}

Expand All @@ -37,7 +37,7 @@ extension ChecksExtension on TaskStatus {
TaskStatus.infraFailure => CheckRunConclusion.failure,
TaskStatus.cancelled => CheckRunConclusion.cancelled,
TaskStatus.skipped => CheckRunConclusion.skipped,
_ => CheckRunConclusion.neutral,
_ => CheckRunConclusion.empty,
};
}

Expand Down
15 changes: 0 additions & 15 deletions app_dart/lib/src/model/common/presubmit_check_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,6 @@ class PresubmitCheckState {
this.endTime,
this.summary,
});

/// Returns true if the build is waiting for backfill or in progress.
bool get isBuildInProgress =>
status == TaskStatus.waitingForBackfill ||
status == TaskStatus.inProgress;

/// Returns true if the build succeeded or was skipped.
bool get isBuildSuccessed =>
status == TaskStatus.succeeded || status == TaskStatus.skipped;

/// Returns true if the build failed, had an infra failure, or was cancelled.
bool get isBuildFailed =>
status == TaskStatus.failed ||
status == TaskStatus.infraFailure ||
status == TaskStatus.cancelled;
}

extension BuildToPresubmitCheckState on bbv2.Build {
Expand Down
10 changes: 5 additions & 5 deletions app_dart/lib/src/service/firestore/unified_check_run.dart
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ final class UnifiedCheckRun {

// If build is in progress, we should only update appropriate checks with
// that [TaskStatus]
if (state.isBuildInProgress) {
if (state.status.isBuildInProgress) {
presubmitCheck.startTime = state.startTime!;
} else {
// "remaining" should go down if buildSuccessed of any attempt
Expand All @@ -285,8 +285,8 @@ final class UnifiedCheckRun {
// So if the test existed and either remaining or failed_count is changed;
// the response is valid.

if (state.isBuildSuccessed ||
state.attemptNumber == 1 && state.isBuildFailed) {
if (state.status.isBuildSuccessed ||
state.attemptNumber == 1 && state.status.isBuildFailed) {
// Guard against going negative and log enough info so we can debug.
if (remaining == 0) {
throw '$logCrumb: field "${PresubmitGuard.fieldRemainingBuilds}" is already zero for $transaction / ${presubmitGuardDocument.fields}';
Expand All @@ -297,7 +297,7 @@ final class UnifiedCheckRun {

// Only rollback the "failed" counter if this is a successful test run,
// i.e. the test failed, the user requested a rerun, and now it passes.
if (state.attemptNumber > 1 && state.isBuildSuccessed) {
if (state.attemptNumber > 1 && state.status.isBuildSuccessed) {
log.info(
'$logCrumb: conclusion flipped to positive - assuming test was re-run',
);
Expand All @@ -309,7 +309,7 @@ final class UnifiedCheckRun {
}

// Only increment the "failed" counter if the conclusion failed for the first attempt.
if (state.attemptNumber == 1 && state.isBuildFailed) {
if (state.attemptNumber == 1 && state.status.isBuildFailed) {
log.info('$logCrumb: test failed');
valid = true;
failed = failed + 1;
Expand Down
5 changes: 5 additions & 0 deletions app_dart/lib/src/service/scheduler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -968,6 +968,11 @@ $s
state: check.state,
);
} else {
// for github flow check runs are processed only if the build succeeded or
// some kind of failure occurred.
if (!check.status.isBuildCompleted) {
return true;
}
// Check runs are fired at every stage. However, at this point it is unknown
// if this check run belongs in the engine build stage or in the test stage.
// So first look for it in the engine stage, and if it's missing, look for
Expand Down
21 changes: 21 additions & 0 deletions packages/cocoon_common/lib/task_status.dart
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,27 @@ enum TaskStatus {
/// Whether the status represents a running state.
bool get isRunning => this == inProgress;

/// Returns true if the build is waiting for backfill or in progress.
bool get isBuildInProgress =>
this == TaskStatus.waitingForBackfill || this == TaskStatus.inProgress;

/// Returns true if the build succeeded or was skipped.
bool get isBuildSuccessed =>
this == TaskStatus.succeeded || this == TaskStatus.skipped;

/// Returns true if the build failed, had an infra failure, or was cancelled.
bool get isBuildFailed =>
this == TaskStatus.failed ||
this == TaskStatus.infraFailure ||
this == TaskStatus.cancelled;

/// Returns true if the build succeeded or some kind of failure occurred.
bool get isBuildCompleted =>
this == TaskStatus.succeeded ||
this == TaskStatus.failed ||
this == TaskStatus.infraFailure ||
this == TaskStatus.cancelled;

/// Returns the JSON representation of `this`.
Object? toJson() => _schemaValue;

Expand Down
Loading