in app_dart/lib/src/service/build_status_provider.dart [58:102]
Future<BuildStatus?> calculateCumulativeStatus(RepositorySlug slug) async {
final List<CommitStatus> statuses = await retrieveCommitStatus(
limit: numberOfCommitsToReferenceForTreeStatus,
slug: slug,
).toList();
if (statuses.isEmpty) {
return BuildStatus.failure();
}
final Map<String, bool> tasksInProgress = _findTasksRelevantToLatestStatus(statuses);
if (tasksInProgress.isEmpty) {
return BuildStatus.failure();
}
final List<String> failedTasks = <String>[];
for (CommitStatus status in statuses) {
for (Stage stage in status.stages) {
for (Task task in stage.tasks) {
/// If a task [isRelevantToLatestStatus] but has not run yet, we look
/// for a previous run of the task from the previous commit.
final bool isRelevantToLatestStatus = tasksInProgress.containsKey(task.name);
/// Tasks that are not relevant to the latest status will have a
/// null value in the map.
final bool taskInProgress = tasksInProgress[task.name] ?? true;
if (isRelevantToLatestStatus && taskInProgress) {
if (task.isFlaky! || _isSuccessful(task)) {
/// This task no longer needs to be checked to see if it causing
/// the build status to fail.
tasksInProgress[task.name!] = false;
} else if (_isFailed(task) || _isRerunning(task)) {
failedTasks.add(task.name!);
/// This task no longer needs to be checked to see if its causing
/// the build status to fail since its been
/// added to the failedTasks list.
tasksInProgress[task.name!] = false;
}
}
}
}
}
return failedTasks.isNotEmpty ? BuildStatus.failure(failedTasks) : BuildStatus.success();
}