diff --git a/app_dart/lib/src/service/luci_build_service.dart b/app_dart/lib/src/service/luci_build_service.dart index 68614a762..cfae590e5 100644 --- a/app_dart/lib/src/service/luci_build_service.dart +++ b/app_dart/lib/src/service/luci_build_service.dart @@ -445,6 +445,25 @@ class LuciBuildService { ); } + if (isUnifiedCheckRunFlow && dashboardChecks != null) { + // For unified check run flow, update dashboard checks to in progress. + try { + await _githubChecksUtil.updateCheckRun( + _config, + slug, + dashboardChecks, + status: CheckRunStatus.inProgress, + ); + } catch (e, s) { + // We are not going to block on this error. + log.warn( + 'Failed to update dashboard checks for PR# ${pullRequest.number} to in progress', + e, + s, + ); + } + } + return targets.keys.toList(); } diff --git a/app_dart/test/service/luci_build_service/schedule_try_builds_test.dart b/app_dart/test/service/luci_build_service/schedule_try_builds_test.dart index bafc563e4..ea459b2ee 100644 --- a/app_dart/test/service/luci_build_service/schedule_try_builds_test.dart +++ b/app_dart/test/service/luci_build_service/schedule_try_builds_test.dart @@ -448,6 +448,15 @@ void main() { // Should NOT create individual check runs verifyNever(mockGithubChecksUtil.createCheckRun(any, any, any, any)); + verify( + mockGithubChecksUtil.updateCheckRun( + any, + RepositorySlug.full('flutter/flutter'), + checkRunGuard, + status: CheckRunStatus.inProgress, + ), + ).called(1); + final bbv2.ScheduleBuildRequest scheduleBuild; { final batchRequest = bbv2.BatchRequest().createEmptyInstance(); @@ -528,6 +537,15 @@ void main() { ), ).called(1); + verifyNever( + mockGithubChecksUtil.updateCheckRun( + any, + any, + any, + status: anyNamed('status'), + ), + ); + final bbv2.ScheduleBuildRequest scheduleBuild; { final batchRequest = bbv2.BatchRequest().createEmptyInstance(); @@ -541,6 +559,77 @@ void main() { expect(userData.checkRunId, 456); expect(userData.guardCheckRunId, isNull); }); + + test( + 'does not update dashboard checks when unified flow is disabled', + () async { + final pullRequest = generatePullRequest( + id: 1, + repo: 'flutter', + headSha: 'headsha123', + ); + + final buildTarget = generateTarget( + 1, + properties: {'os': 'abc'}, + slug: RepositorySlug.full('flutter/flutter'), + name: 'Linux foo', + ); + + // Disable Unified Check Run Flow but provide a guard (unexpected but should be handled) + luci = LuciBuildService( + config: FakeConfig( + dynamicConfig: DynamicConfig( + unifiedCheckRunFlow: UnifiedCheckRunFlow(useForAll: false), + ), + ), + cache: CacheService.inMemory(), + buildBucketClient: mockBuildBucketClient, + githubChecksUtil: mockGithubChecksUtil, + pubsub: pubSub, + gerritService: gerritService, + firestore: firestore, + ); + + final checkRunGuard = generateCheckRun(1234, name: 'Guard'); + + when( + mockGithubChecksUtil.createCheckRun(any, any, any, any), + ).thenAnswer((_) async => generateCheckRun(456, name: 'Linux foo')); + + await expectLater( + luci.scheduleTryBuilds( + pullRequest: pullRequest, + targets: [buildTarget], + engineArtifacts: EngineArtifacts.builtFromSource( + commitSha: pullRequest.head!.sha!, + ), + dashboardChecks: checkRunGuard, // Pass guard even though disabled + ), + completion([isTarget.hasName('Linux foo')]), + ); + + // Should NOT update dashboard checks + verifyNever( + mockGithubChecksUtil.updateCheckRun( + any, + any, + any, + status: anyNamed('status'), + ), + ); + + // Should create individual check run because unified flow is disabled + verify( + mockGithubChecksUtil.createCheckRun( + any, + RepositorySlug.full('flutter/flutter'), + 'headsha123', + 'Linux foo', + ), + ).called(1); + }, + ); }); group('Ordered Presubmit', () {