Skip to content

Commit 2dd521d

Browse files
Remove revert bot from autosubmit. (#5091)
This functionality has been replaced by a GitHub action, so we're going to remove this feature from cocoon.
1 parent 994995d commit 2dd521d

56 files changed

Lines changed: 65 additions & 5615 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

app_dart/lib/src/request_handlers/github/webhook_subscription.dart

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -388,30 +388,6 @@ final class GithubWebhookSubscription extends SubscriptionHandler {
388388

389389
log.debug('Pull request ${pr.number} was closed and merged.');
390390

391-
// To avoid polluting the repo with temporary revert branches, delete the
392-
// branch after the reverted PR is merged.
393-
//
394-
// This can be done no ealier than the event declaring the PR both
395-
// 'closed' and merged, because:
396-
//
397-
// * If the branch is deleted before the PR reaches 'closed', then GitHub
398-
// will force-close the PR because the branch is the source of all the
399-
// code changes in the PR. In a previous iteration, Cocoon used to
400-
// delete the branch immediately after merging it. However, with merge
401-
// queues a PR is not merged by Cocoon anymore. It stays open while in
402-
// the merge queue. Deleting the branch while in the queue would close
403-
// the PR and not merge it.
404-
// * If a PR is closed but not merged, the author may still want to reopen
405-
// the PR. That would not be possible if the source branch was deleted.
406-
final isRevertPullRequest =
407-
pr.labels?.any((label) => label.name == Config.revertOfLabel) == true;
408-
if (isRevertPullRequest) {
409-
log.info('Revert merged successfully, deleting branch ${pr.head!.ref!}');
410-
final slug = pullRequestEvent.repository!.slug();
411-
final githubService = await config.createGithubService(slug);
412-
await githubService.deleteBranch(slug, pr.head!.ref!);
413-
}
414-
415391
if (await _commitExistsInGob(pr)) {
416392
log.debug(
417393
'Merged commit was found on GoB mirror. Scheduling postsubmit tasks...',

app_dart/lib/src/service/config.dart

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -152,13 +152,6 @@ interface class Config extends DynamicallyUpdatedConfig {
152152
return defaultBranches[slug] ?? kDefaultBranchName;
153153
}
154154

155-
// The name of the bot that generates automated revert requests.
156-
String get autosubmitBot => 'auto-submit[bot]';
157-
158-
// The name of the label that the bot uses to identify the automatically
159-
// created pull request.
160-
static const String revertOfLabel = 'revert of';
161-
162155
/// Memorystore subcache name to store [CocoonConfig] values in.
163156
static const String configCacheName = 'config';
164157

app_dart/lib/src/service/scheduler.dart

Lines changed: 60 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -391,18 +391,6 @@ class Scheduler {
391391
unlockMergeGroup = true;
392392
}
393393

394-
// Both the author and label should be checked to make sure that no one is
395-
// attempting to get a pull request without check through.
396-
if (pullRequest.user!.login == _config.autosubmitBot &&
397-
pullRequest.labels!.any(
398-
(element) => element.name == Config.revertOfLabel,
399-
)) {
400-
log.info(
401-
'Skipping generating the full set of checks for revert request.',
402-
);
403-
unlockMergeGroup = true;
404-
break;
405-
}
406394
// Feature request: skip engine builds and tests in monorepo if the PR only contains framework related
407395
// files.
408396
// NOTE: This creates an empty staging doc for the engine builds as staging is handled on check_run completion
@@ -1415,84 +1403,73 @@ detailsUrl: $detailsUrl
14151403
required _FlutterRepoTestsToRun testsToRun,
14161404
}) async {
14171405
try {
1418-
// Both the author and label should be checked to make sure that no one is
1419-
// attempting to get a pull request without check through.
1420-
if (pullRequest.user!.login == _config.autosubmitBot &&
1421-
pullRequest.labels!.any(
1422-
(element) => element.name == Config.revertOfLabel,
1423-
)) {
1424-
log.info(
1425-
'$logCrumb: skipping generating the full set of checks for revert request.',
1426-
);
1427-
} else {
1428-
// Schedule the tests that would have run in a call to triggerPresubmitTargets - but for both the
1429-
// engine and the framework.
1430-
var presubmitTargets = await _getTestsForStage(
1431-
pullRequest,
1432-
CiStage.fusionTests,
1433-
skipEngine:
1434-
testsToRun != _FlutterRepoTestsToRun.engineTestsAndFrameworkTests,
1435-
);
1436-
1437-
// Create the document for tracking test check runs.
1438-
final List<String> tasks;
1439-
if (testsToRun == _FlutterRepoTestsToRun.frameworkFlutterAnalyzeOnly) {
1440-
const linuxAnalyze = 'Linux analyze';
1441-
final singleTarget = presubmitTargets.firstWhereOrNull(
1442-
(t) => t.name == linuxAnalyze,
1443-
);
1444-
if (singleTarget == null) {
1445-
log.warn('No target found named "$linuxAnalyze"');
1446-
tasks = [];
1447-
presubmitTargets = [];
1448-
} else {
1449-
log.info('Only running target "$linuxAnalyze"');
1450-
tasks = [linuxAnalyze];
1451-
presubmitTargets = [singleTarget];
1452-
}
1453-
} else {
1454-
tasks = [...presubmitTargets.map((t) => t.name)];
1455-
}
1406+
// Schedule the tests that would have run in a call to triggerPresubmitTargets - but for both the
1407+
// engine and the framework.
1408+
var presubmitTargets = await _getTestsForStage(
1409+
pullRequest,
1410+
CiStage.fusionTests,
1411+
skipEngine:
1412+
testsToRun != _FlutterRepoTestsToRun.engineTestsAndFrameworkTests,
1413+
);
14561414

1457-
await UnifiedCheckRun.initializeCiStagingDocument(
1458-
firestoreService: _firestore,
1459-
slug: pullRequest.base!.repo!.slug(),
1460-
sha: pullRequest.head!.sha!,
1461-
stage: CiStage.fusionTests,
1462-
tasks: tasks,
1463-
config: _config,
1464-
pullRequest: pullRequest,
1465-
checkRun: checkRunGuard,
1415+
// Create the document for tracking test check runs.
1416+
final List<String> tasks;
1417+
if (testsToRun == _FlutterRepoTestsToRun.frameworkFlutterAnalyzeOnly) {
1418+
const linuxAnalyze = 'Linux analyze';
1419+
final singleTarget = presubmitTargets.firstWhereOrNull(
1420+
(t) => t.name == linuxAnalyze,
14661421
);
1467-
1468-
// Here is where it gets fun: how do framework tests* know what engine
1469-
// artifacts to fetch and use on CI? For presubmits on flutter/flutter;
1470-
// see https://github.com/flutter/flutter/issues/164031.
1471-
//
1472-
// *In theory, also engine tests, but engine tests build from the engine
1473-
// from source and rely on remote-build execution (RBE) for builds to
1474-
// fast and cached.
1475-
final EngineArtifacts engineArtifacts;
1476-
if (testsToRun != _FlutterRepoTestsToRun.engineTestsAndFrameworkTests) {
1477-
// Use the engine that this PR was branched off of.
1478-
engineArtifacts = EngineArtifacts.usingExistingEngine(
1479-
commitSha: pullRequest.base!.sha!,
1480-
);
1422+
if (singleTarget == null) {
1423+
log.warn('No target found named "$linuxAnalyze"');
1424+
tasks = [];
1425+
presubmitTargets = [];
14811426
} else {
1482-
// Use the engine that was built from source *for* this PR.
1483-
engineArtifacts = EngineArtifacts.builtFromSource(
1484-
commitSha: pullRequest.head!.sha!,
1485-
);
1427+
log.info('Only running target "$linuxAnalyze"');
1428+
tasks = [linuxAnalyze];
1429+
presubmitTargets = [singleTarget];
14861430
}
1431+
} else {
1432+
tasks = [...presubmitTargets.map((t) => t.name)];
1433+
}
14871434

1488-
await _luciBuildService.scheduleTryBuilds(
1489-
targets: presubmitTargets,
1490-
pullRequest: pullRequest,
1491-
engineArtifacts: engineArtifacts,
1492-
checkRunGuard: checkRunGuard,
1493-
stage: CiStage.fusionTests,
1435+
await UnifiedCheckRun.initializeCiStagingDocument(
1436+
firestoreService: _firestore,
1437+
slug: pullRequest.base!.repo!.slug(),
1438+
sha: pullRequest.head!.sha!,
1439+
stage: CiStage.fusionTests,
1440+
tasks: tasks,
1441+
config: _config,
1442+
pullRequest: pullRequest,
1443+
checkRun: checkRunGuard,
1444+
);
1445+
1446+
// Here is where it gets fun: how do framework tests* know what engine
1447+
// artifacts to fetch and use on CI? For presubmits on flutter/flutter;
1448+
// see https://github.com/flutter/flutter/issues/164031.
1449+
//
1450+
// *In theory, also engine tests, but engine tests build from the engine
1451+
// from source and rely on remote-build execution (RBE) for builds to
1452+
// fast and cached.
1453+
final EngineArtifacts engineArtifacts;
1454+
if (testsToRun != _FlutterRepoTestsToRun.engineTestsAndFrameworkTests) {
1455+
// Use the engine that this PR was branched off of.
1456+
engineArtifacts = EngineArtifacts.usingExistingEngine(
1457+
commitSha: pullRequest.base!.sha!,
1458+
);
1459+
} else {
1460+
// Use the engine that was built from source *for* this PR.
1461+
engineArtifacts = EngineArtifacts.builtFromSource(
1462+
commitSha: pullRequest.head!.sha!,
14941463
);
14951464
}
1465+
1466+
await _luciBuildService.scheduleTryBuilds(
1467+
targets: presubmitTargets,
1468+
pullRequest: pullRequest,
1469+
engineArtifacts: engineArtifacts,
1470+
checkRunGuard: checkRunGuard,
1471+
stage: CiStage.fusionTests,
1472+
);
14961473
} on FormatException catch (e, s) {
14971474
log.warn(
14981475
'$logCrumb: FormatException encountered when scheduling presubmit '

app_dart/test/request_handlers/github/webhook_subscription_test.dart

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -342,10 +342,6 @@ void main() {
342342
merged: true,
343343
baseSha: 'abc',
344344
mergeCommitSha: 'cde',
345-
346-
// Just spelling this out here, because this test specifically tests a
347-
// non-revert PR.
348-
withRevertOf: false,
349345
);
350346

351347
await tester.post(webhook);
@@ -358,52 +354,6 @@ void main() {
358354
},
359355
);
360356

361-
test('Removes temporary revert branches upon merging the PR', () async {
362-
const issueNumber = 123;
363-
364-
firestore.putDocument(generateFirestoreCommit(1));
365-
366-
tester.message = generateGithubWebhookMessage(
367-
action: 'closed',
368-
number: issueNumber,
369-
baseRef: 'dev',
370-
merged: true,
371-
baseSha: 'abc',
372-
mergeCommitSha: 'cde',
373-
withRevertOf: true,
374-
headRef: 'test/headref',
375-
);
376-
377-
await tester.post(webhook);
378-
379-
// This was a merged revert PR. The temp branch should be deleted.
380-
expect(githubService.deletedBranches, [
381-
(RepositorySlug('flutter', 'flutter'), 'test/headref'),
382-
]);
383-
});
384-
385-
test(
386-
'Does NOT remove temporary revert branches upon closing a revert PR because the PR may be manually reopened',
387-
() async {
388-
const issueNumber = 123;
389-
390-
tester.message = generateGithubWebhookMessage(
391-
action: 'closed',
392-
number: issueNumber,
393-
baseRef: 'dev',
394-
merged: false,
395-
baseSha: 'sha1',
396-
mergeCommitSha: 'sha2',
397-
withRevertOf: true,
398-
);
399-
400-
await tester.post(webhook);
401-
402-
// This was a closed (not merged) revert PR, so no branches deleted.
403-
expect(githubService.deletedBranches, isEmpty);
404-
},
405-
);
406-
407357
test('Acts on opened against master when default is main', () async {
408358
const issueNumber = 123;
409359

app_dart/test/service/scheduler_test.dart

Lines changed: 0 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -2991,83 +2991,6 @@ targets:
29912991
},
29922992
);
29932993

2994-
test('Do not schedule other targets on revert request.', () async {
2995-
final releasePullRequest = generatePullRequest(
2996-
labels: [IssueLabel(name: 'revert of')],
2997-
);
2998-
2999-
releasePullRequest.user = User(login: 'auto-submit[bot]');
3000-
3001-
await scheduler.triggerPresubmitTargets(
3002-
pullRequest: releasePullRequest,
3003-
);
3004-
expect(
3005-
verify(
3006-
mockGithubChecksUtil.createCheckRun(
3007-
any,
3008-
any,
3009-
any,
3010-
captureAny,
3011-
output: captureAnyNamed('output'),
3012-
),
3013-
).captured,
3014-
<Object?>[
3015-
Config.kMergeQueueLockName,
3016-
const CheckRunOutput(
3017-
title: Config.kMergeQueueLockName,
3018-
summary: Scheduler.kMergeQueueLockDescription,
3019-
),
3020-
Config.kDashboardCheckName,
3021-
const CheckRunOutput(
3022-
title: Config.kDashboardCheckName,
3023-
summary: Scheduler.kDashboardChecksDescription,
3024-
),
3025-
Config.kCiYamlCheckName,
3026-
// No other targets should be created.
3027-
const CheckRunOutput(
3028-
title: Config.kCiYamlCheckName,
3029-
summary:
3030-
'If this check is stuck pending, push an empty commit to retrigger the checks',
3031-
),
3032-
],
3033-
);
3034-
});
3035-
3036-
test('Unlocks merge group on revert request.', () async {
3037-
final releasePullRequest = generatePullRequest(
3038-
labels: [IssueLabel(name: 'revert of')],
3039-
);
3040-
3041-
releasePullRequest.user = User(login: 'auto-submit[bot]');
3042-
3043-
await scheduler.triggerPresubmitTargets(
3044-
pullRequest: releasePullRequest,
3045-
);
3046-
expect(
3047-
verify(
3048-
mockGithubChecksUtil.updateCheckRun(
3049-
any,
3050-
any,
3051-
any,
3052-
status: captureAnyNamed('status'),
3053-
conclusion: captureAnyNamed('conclusion'),
3054-
output: captureAnyNamed('output'),
3055-
),
3056-
).captured,
3057-
<Object?>[
3058-
CheckRunStatus.completed,
3059-
CheckRunConclusion.success,
3060-
null,
3061-
CheckRunStatus.completed,
3062-
CheckRunConclusion.success,
3063-
null,
3064-
CheckRunStatus.completed,
3065-
CheckRunConclusion.success,
3066-
null,
3067-
],
3068-
);
3069-
});
3070-
30712994
test(
30722995
'filters out presubmit targets that do not exist in main and do not filter targets not in main',
30732996
() async {

auto_submit/bin/server.dart

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import 'package:appengine/appengine.dart';
88
import 'package:auto_submit/helpers.dart';
99
import 'package:auto_submit/request_handling/authentication.dart';
1010
import 'package:auto_submit/requests/check_pull_request.dart';
11-
import 'package:auto_submit/requests/check_revert_request.dart';
1211
import 'package:auto_submit/requests/github_webhook.dart';
1312
import 'package:auto_submit/requests/readiness_check.dart';
1413
import 'package:auto_submit/service/config.dart';
@@ -40,10 +39,6 @@ Future<void> main() async {
4039
'/check-pull-request',
4140
CheckPullRequest(config: config, cronAuthProvider: authProvider).run,
4241
)
43-
..get(
44-
'/check-revert-requests',
45-
CheckRevertRequest(config: config, cronAuthProvider: authProvider).run,
46-
)
4742
..get('/readiness_check', ReadinessCheck(config: config).run);
4843
await serveHandler(router.call);
4944
});

0 commit comments

Comments
 (0)