Skip to content
Open
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
1 change: 0 additions & 1 deletion app_dart/lib/cocoon_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ export 'src/service/config.dart';
export 'src/service/firestore.dart';
export 'src/service/flags/dynamic_config.dart';
export 'src/service/flags/ordered_presubmit_flags.dart';
export 'src/service/flags/unified_check_run_flow_flags.dart';
export 'src/service/gerrit_service.dart';
export 'src/service/github_checks_service.dart';
export 'src/service/issue_service.dart';
Expand Down
11 changes: 6 additions & 5 deletions app_dart/lib/src/model/common/presubmit_completed_check.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ class PresubmitCompletedJob {
final int checkRunId;
final int? checkSuiteId;
final String? headBranch;
final bool isUnifiedCheckRun;
final CiStage? stage;
final int? prNum;
final int attempt;
Expand All @@ -53,7 +52,6 @@ class PresubmitCompletedJob {
required this.checkRunId,
required this.checkSuiteId,
required this.headBranch,
required this.isUnifiedCheckRun,
this.stage,
this.prNum,
this.attempt = 1,
Expand All @@ -80,7 +78,6 @@ class PresubmitCompletedJob {
checkRunId: userData.guardCheckRunId ?? userData.checkRunId!,
checkSuiteId: userData.checkSuiteId,
headBranch: userData.commit.branch,
isUnifiedCheckRun: userData.guardCheckRunId != null,
stage: userData.stage,
prNum: userData.pullRequestNumber,
attempt: _getAttempt(build),
Expand All @@ -103,7 +100,7 @@ class PresubmitCompletedJob {
cocoon_checks.CheckRun get checkRun {
return cocoon_checks.CheckRun(
id: checkRunId,
name: isUnifiedCheckRun ? Config.kDashboardCheckName : name,
name: Config.kDashboardCheckName,
headSha: sha,
conclusion: status.toConclusion(),
checkSuite: CheckSuite(
Expand All @@ -121,7 +118,11 @@ class PresubmitCompletedJob {
slug: slug,
prNum: prNum ?? 0,
checkRunId: checkRunId,
stage: stage ?? CiStage.fusionTests,
stage:
stage ??
(slug == Config.flutterSlug
? CiStage.fusionTests
: CiStage.genericTests),
);
}

Expand Down
58 changes: 17 additions & 41 deletions app_dart/lib/src/request_handlers/presubmit_subscription.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,11 @@ base class PresubmitSubscription extends SubscriptionHandler {
required super.subscriptionName,
super.authProvider,
}) : _ciYamlFetcher = ciYamlFetcher,
_githubChecksService = githubChecksService,
_luciBuildService = luciBuildService,
_scheduler = scheduler,
_firestore = firestore;

final LuciBuildService _luciBuildService;
final GithubChecksService _githubChecksService;
final CiYamlFetcher _ciYamlFetcher;
final Scheduler _scheduler;
final FirestoreService _firestore;
Expand Down Expand Up @@ -143,20 +141,16 @@ base class PresubmitSubscription extends SubscriptionHandler {
tagSet ??= BuildTags.fromStringPairs(build.tags);
final builderName = build.builder.builder;
var rescheduled = false;
final isUnifiedCheckRun = userData.guardCheckRunId != null;
log.info('Unified Check Run ${isUnifiedCheckRun ? 'Enabled' : 'Disabled'}');
if (build.status.isTaskFailed()) {
if (isUnifiedCheckRun) {
// If failed we need summaryMarkdown. For github check run flow this
// called in [GithubChecksService.updateCheckStatus(...)]
build = await _luciBuildService.getBuildById(
build.id,
buildMask: bbv2.BuildMask(
// Need to use allFields as there is a bug with fieldMask and summaryMarkdown.
allFields: true,
),
);
}
// If failed we need summaryMarkdown. For github check run flow this
// called in [GithubChecksService.updateCheckStatus(...)]
build = await _luciBuildService.getBuildById(
build.id,
buildMask: bbv2.BuildMask(
// Need to use allFields as there is a bug with fieldMask and summaryMarkdown.
allFields: true,
),
);
final maxAttempt = await _getMaxAttempt(
userData.commit,
builderName,
Expand All @@ -165,17 +159,14 @@ base class PresubmitSubscription extends SubscriptionHandler {
if (tagSet.currentAttempt < maxAttempt) {
rescheduled = true;
log.info('Rerunning failed task: $builderName');
if (isUnifiedCheckRun) {
await UnifiedCheckRun.reInitializeInProgressJob(
firestoreService: _firestore,
completedJob: PresubmitCompletedJob.fromBuild(
build,
userData,
summaryPrepend:
'### ⚠️ Test failed but automatically rescheduled',
),
);
}
await UnifiedCheckRun.reInitializeInProgressJob(
firestoreService: _firestore,
completedJob: PresubmitCompletedJob.fromBuild(
build,
userData,
summaryPrepend: '### ⚠️ Test failed but automatically rescheduled',
),
);
await _luciBuildService.reschedulePresubmitBuild(
builderName: builderName,
build: build,
Expand All @@ -199,21 +190,6 @@ base class PresubmitSubscription extends SubscriptionHandler {
'### ⚠️ Test failed but marked as suppressed on dashboard';
}
}
if (!isUnifiedCheckRun) {
if (userData.checkRunId == null) {
log.error('checkRunId is null for non-unified check run');
return;
}
await _githubChecksService.updateCheckStatus(
checkRunId: userData.checkRunId!,
build: build,
luciBuildService: _luciBuildService,
slug: userData.commit.slug,
rescheduled: rescheduled,
conclusionOverride: override,
summaryPrepend: suppressedMessage,
);
}
if (!rescheduled) {
final check = PresubmitCompletedJob.fromBuild(
build,
Expand Down
8 changes: 2 additions & 6 deletions app_dart/lib/src/service/firestore/unified_check_run.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,10 @@ final class UnifiedCheckRun {
CheckRun? mergeQueueGuard,
@visibleForTesting DateTime Function() utcNow = DateTime.timestamp,
}) async {
if (dashboardChecks != null &&
pullRequest != null &&
config.flags.isUnifiedCheckRunFlowEnabledForUser(
pullRequest.user!.login!,
)) {
if (dashboardChecks != null && pullRequest != null) {
// Create the presubmit_guard and associated presubmit_job documents.
log.info(
'Storing UnifiedCheckRun data for ${slug.fullName}#${pullRequest.number} as it enabled for user ${pullRequest.user!.login}.',
'Storing UnifiedCheckRun data for ${slug.fullName}#${pullRequest.number}.',
);
// We store the creation time of the guard since there might be several
// guards for the same PR created and each new one created after previous
Expand Down
10 changes: 4 additions & 6 deletions app_dart/lib/src/service/luci_build_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,6 @@ class LuciBuildService {
final slug = pullRequest.base!.repo!.slug();
final commitBranch = pullRequest.base!.ref!.replaceAll('refs/heads/', '');
final isFusion = slug == Config.flutterSlug;
final isUnifiedCheckRunFlow = _config.flags
.isUnifiedCheckRunFlowEnabledForUser(pullRequest.user!.login!);
final isOrderedPresubmit = _config.flags.isOrderedPresubmitEnabledForUser(
pullRequest.user!.login!,
);
Expand All @@ -307,7 +305,7 @@ class LuciBuildService {
late PresubmitUserData userData;
// If the unified check run flow is enabled, do not create individual
// check runs for each target but use the guard check run instead.
if (isUnifiedCheckRunFlow && dashboardChecks != null) {
if (dashboardChecks != null) {
userData = PresubmitUserData(
commit: CommitRef(slug: slug, sha: commitSha, branch: commitBranch),
guardCheckRunId: dashboardChecks.id!,
Expand All @@ -326,7 +324,7 @@ class LuciBuildService {
for (final MapEntry(key: target, value: attemptNumber) in targets.entries) {
// If the unified check run flow is disabled create individual check runs
// for each target.
if (!isUnifiedCheckRunFlow || dashboardChecks == null) {
if (dashboardChecks == null) {
final checkRun = await _githubChecksUtil.createCheckRun(
_config,
target.slug,
Expand Down Expand Up @@ -396,7 +394,7 @@ class LuciBuildService {
userData: userData,
properties: properties,
// if unified check run flow is enabled, use guard check run othervise check run id.
tags: isUnifiedCheckRunFlow && dashboardChecks != null
tags: dashboardChecks != null
? BuildTags([
GuardCheckRunIdBuildTag(
guardCheckRunId: dashboardChecks.id!,
Expand Down Expand Up @@ -449,7 +447,7 @@ class LuciBuildService {
// initial run. For Re-run Failed Checks, if all failed jobs were reset, we
// need to re-request the check run before updating it to in progress.
final isRerun = targets.values.first > 1;
if (isUnifiedCheckRunFlow && dashboardChecks != null) {
if (dashboardChecks != null) {
if (isRerun && stage != null) {
try {
final presubmitGuardDoc = await _firestore.getDocument(
Expand Down
Loading
Loading