diff --git a/dev/conductor/core/lib/src/next.dart b/dev/conductor/core/lib/src/next.dart index 575ce035c2..258706c1d3 100644 --- a/dev/conductor/core/lib/src/next.dart +++ b/dev/conductor/core/lib/src/next.dart @@ -101,22 +101,6 @@ class NextContext extends Context { upstreamRemote: upstream, previousCheckoutLocation: state.engine.checkoutPath, ); - // check if the candidate branch is enabled in .ci.yaml - final CiYaml engineCiYaml = await engine.ciYaml; - if (!engineCiYaml.enabledBranches.contains(state.engine.candidateBranch)) { - engineCiYaml.enableBranch(state.engine.candidateBranch); - // commit - final String revision = await engine.commit( - 'add branch ${state.engine.candidateBranch} to enabled_branches in .ci.yaml', - addFirst: true, - ); - // append to list of cherrypicks so we know a PR is required - state.engine.cherrypicks.add(pb.Cherrypick( - appliedRevision: revision, - state: pb.CherrypickState.COMPLETED, - )); - } - if (!state_import.requiresEnginePR(state)) { stdio.printStatus( 'This release has no engine cherrypicks. No Engine PR is necessary.\n', @@ -213,21 +197,6 @@ class NextContext extends Context { previousCheckoutLocation: state.framework.checkoutPath, ); - // Check if the current candidate branch is enabled - if (!(await framework.ciYaml).enabledBranches.contains(state.framework.candidateBranch)) { - (await framework.ciYaml).enableBranch(state.framework.candidateBranch); - // commit - final String revision = await framework.commit( - 'add branch ${state.framework.candidateBranch} to enabled_branches in .ci.yaml', - addFirst: true, - ); - // append to list of cherrypicks so we know a PR is required - state.framework.cherrypicks.add(pb.Cherrypick( - appliedRevision: revision, - state: pb.CherrypickState.COMPLETED, - )); - } - stdio.printStatus('Rolling new engine hash $engineRevision to framework checkout...'); final bool needsCommit = await framework.updateEngineRevision(engineRevision); if (needsCommit) { diff --git a/dev/conductor/core/lib/src/repository.dart b/dev/conductor/core/lib/src/repository.dart index 36e44403aa..f33dc472ad 100644 --- a/dev/conductor/core/lib/src/repository.dart +++ b/dev/conductor/core/lib/src/repository.dart @@ -844,46 +844,4 @@ class CiYaml { /// This is not cached as the contents can be written to while the conductor /// is running. YamlMap get contents => loadYaml(stringContents) as YamlMap; - - List get enabledBranches { - final YamlList yamlList = contents['enabled_branches'] as YamlList; - return yamlList.map((dynamic element) { - return element as String; - }).toList(); - } - - static final RegExp _enabledBranchPattern = RegExp(r'enabled_branches:'); - - /// Update this .ci.yaml file with the given branch name. - /// - /// The underlying [File] is written to, but not committed to git. This method - /// will throw a [ConductorException] if the [branchName] is already present - /// in the file or if the file does not have an "enabled_branches:" field. - void enableBranch(String branchName) { - final List newStrings = []; - if (enabledBranches.contains(branchName)) { - throw ConductorException('${file.path} already contains the branch $branchName'); - } - if (!_enabledBranchPattern.hasMatch(stringContents)) { - throw ConductorException( - 'Did not find the expected string "enabled_branches:" in the file ${file.path}', - ); - } - final List lines = stringContents.split('\n'); - bool insertedCurrentBranch = false; - for (final String line in lines) { - // Every existing line should be copied to the new Yaml - newStrings.add(line); - if (insertedCurrentBranch) { - continue; - } - if (_enabledBranchPattern.hasMatch(line)) { - insertedCurrentBranch = true; - // Indent two spaces - final String indent = ' ' * 2; - newStrings.add('$indent- ${branchName.trim()}'); - } - } - file.writeAsStringSync(newStrings.join('\n'), flush: true); - } } diff --git a/dev/conductor/core/lib/src/start.dart b/dev/conductor/core/lib/src/start.dart index 3227396e05..f4865f22ba 100644 --- a/dev/conductor/core/lib/src/start.dart +++ b/dev/conductor/core/lib/src/start.dart @@ -235,7 +235,7 @@ class StartContext extends Context { }) : git = Git(processManager), engine = EngineRepository( checkouts, - initialRef: candidateBranch, + initialRef: 'upstream/$candidateBranch', upstreamRemote: Remote( name: RemoteName.upstream, url: engineUpstream, @@ -246,7 +246,7 @@ class StartContext extends Context { ), ), framework = FrameworkRepository( checkouts, - initialRef: candidateBranch, + initialRef: 'upstream/$candidateBranch', upstreamRemote: Remote( name: RemoteName.upstream, url: frameworkUpstream, diff --git a/dev/conductor/core/test/next_test.dart b/dev/conductor/core/test/next_test.dart index edfb98c988..b3aac64443 100644 --- a/dev/conductor/core/test/next_test.dart +++ b/dev/conductor/core/test/next_test.dart @@ -25,7 +25,6 @@ void main() { const String remoteUrl = 'https://github.com/org/repo.git'; const String revision1 = 'd3af60d18e01fcb36e0c0fa06c8502e4935ed095'; const String revision2 = 'f99555c1e1392bf2a8135056b9446680c2af4ddf'; - const String revision3 = '98a5ca242b9d270ce000b26309b8a3cdc9c89df5'; const String revision4 = '280e23318a0d8341415c66aa32581352a421d974'; const String releaseVersion = '1.2.0-3.0.pre'; const String releaseChannel = 'beta'; @@ -82,12 +81,7 @@ void main() { group('APPLY_ENGINE_CHERRYPICKS to CODESIGN_ENGINE_BINARIES', () { test('does not prompt user and updates currentPhase if there are no engine cherrypicks', () async { - final FakeProcessManager processManager = FakeProcessManager.list([ - const FakeCommand(command: ['git', 'fetch', 'upstream']), - const FakeCommand( - command: ['git', 'checkout', workingBranch], - ), - ]); + final FakeProcessManager processManager = FakeProcessManager.empty(); final FakePlatform platform = FakePlatform( environment: { 'HOME': ['path', 'to', 'home'].join(localPathSeparator), @@ -145,24 +139,7 @@ void main() { final File ciYaml = fileSystem.file('$checkoutsParentDirectory/engine/.ci.yaml') ..createSync(recursive: true); _initializeCiYamlFile(ciYaml); - final FakeProcessManager processManager = FakeProcessManager.list([ - const FakeCommand(command: ['git', 'fetch', 'upstream']), - const FakeCommand(command: ['git', 'checkout', workingBranch]), - const FakeCommand( - command: ['git', 'status', '--porcelain'], - stdout: 'MM blah', - ), - const FakeCommand(command: ['git', 'add', '--all']), - const FakeCommand(command: [ - 'git', - 'commit', - "--message='add branch $candidateBranch to enabled_branches in .ci.yaml'", - ]), - const FakeCommand( - command: ['git', 'rev-parse', 'HEAD'], - stdout: revision2, - ), - ]); + final FakeProcessManager processManager = FakeProcessManager.empty(); final FakePlatform platform = FakePlatform( environment: { 'HOME': ['path', 'to', 'home'].join(localPathSeparator), @@ -228,16 +205,6 @@ void main() { _initializeCiYamlFile(file); }, ), - const FakeCommand( - command: ['git', 'status', '--porcelain'], - stdout: 'MM .ci.yaml', - ), - const FakeCommand(command: ['git', 'add', '--all']), - const FakeCommand(command: ['git', 'commit', "--message='add branch $candidateBranch to enabled_branches in .ci.yaml'"]), - const FakeCommand( - command: ['git', 'rev-parse', 'HEAD'], - stdout: revision2, - ), const FakeCommand(command: ['git', 'push', 'mirror', 'HEAD:refs/heads/$workingBranch']), ]); final FakePlatform platform = FakePlatform( @@ -355,6 +322,7 @@ void main() { fileSystem.file(stateFile), ); + expect(processManager, hasNoRemainingExpectations); expect(stdio.stdout, contains('Has CI passed for the engine PR and binaries been codesigned? (y/n) ')); expect(finalState.currentPhase, ReleasePhase.CODESIGN_ENGINE_BINARIES); expect(stdio.error.contains('Aborting command.'), true); @@ -392,6 +360,7 @@ void main() { fileSystem.file(stateFile), ); + expect(processManager, hasNoRemainingExpectations); expect(stdio.stdout, contains('Has CI passed for the engine PR and binaries been codesigned? (y/n) ')); expect(finalState.currentPhase, ReleasePhase.APPLY_FRAMEWORK_CHERRYPICKS); }); @@ -524,20 +493,6 @@ void main() { _initializeCiYamlFile(file); }, ), - const FakeCommand( - command: ['git', 'status', '--porcelain'], - stdout: 'MM /path/to/.ci.yaml', - ), - const FakeCommand(command: ['git', 'add', '--all']), - const FakeCommand(command: [ - 'git', - 'commit', - "--message='add branch $candidateBranch to enabled_branches in .ci.yaml'", - ]), - const FakeCommand( - command: ['git', 'rev-parse', 'HEAD'], - stdout: revision3, - ), const FakeCommand( command: ['git', 'status', '--porcelain'], stdout: 'MM /path/to/engine.version', @@ -614,20 +569,6 @@ void main() { ), const FakeCommand(command: ['git', 'fetch', 'upstream']), const FakeCommand(command: ['git', 'checkout', workingBranch]), - const FakeCommand( - command: ['git', 'status', '--porcelain'], - stdout: 'MM path/to/.ci.yaml', - ), - const FakeCommand(command: ['git', 'add', '--all']), - const FakeCommand(command: [ - 'git', - 'commit', - "--message='add branch $candidateBranch to enabled_branches in .ci.yaml'", - ]), - const FakeCommand( - command: ['git', 'rev-parse', 'HEAD'], - stdout: revision3, - ), const FakeCommand( command: ['git', 'status', '--porcelain'], stdout: 'MM path/to/engine.version', @@ -697,20 +638,6 @@ void main() { stdout: 'MM path/to/.ci.yaml', ), const FakeCommand(command: ['git', 'add', '--all']), - const FakeCommand(command: [ - 'git', - 'commit', - "--message='add branch $candidateBranch to enabled_branches in .ci.yaml'", - ]), - const FakeCommand( - command: ['git', 'rev-parse', 'HEAD'], - stdout: revision3, - ), - const FakeCommand( - command: ['git', 'status', '--porcelain'], - stdout: 'MM path/to/engine.version', - ), - const FakeCommand(command: ['git', 'add', '--all']), const FakeCommand(command: [ 'git', 'commit', diff --git a/dev/conductor/core/test/repository_test.dart b/dev/conductor/core/test/repository_test.dart index 9c74618001..5fe2f18c24 100644 --- a/dev/conductor/core/test/repository_test.dart +++ b/dev/conductor/core/test/repository_test.dart @@ -384,130 +384,6 @@ vars = { ); }); - test('ciYaml.enableBranch() will prepend the given branch to the yaml list of enabled_branches', () async { - const String commit1 = 'abc123'; - final File ciYaml = fileSystem.file('/flutter_conductor_checkouts/framework/.ci.yaml'); - processManager.addCommands([ - FakeCommand( - command: [ - 'git', - 'clone', - '--origin', - 'upstream', - '--', - FrameworkRepository.defaultUpstream, - fileSystem.path - .join(rootDir, 'flutter_conductor_checkouts', 'framework'), - ], - onRun: () { - ciYaml.createSync(recursive: true); - ciYaml.writeAsStringSync(''' -# Friendly note - -enabled_branches: - - ${FrameworkRepository.defaultBranch} - - dev - - beta - - stable -'''); - }), - const FakeCommand(command: [ - 'git', - 'checkout', - FrameworkRepository.defaultBranch, - ]), - const FakeCommand(command: [ - 'git', - 'rev-parse', - 'HEAD', - ], stdout: commit1), - ]); - final Checkouts checkouts = Checkouts( - fileSystem: fileSystem, - parentDirectory: fileSystem.directory(rootDir), - platform: platform, - processManager: processManager, - stdio: stdio, - ); - - final FrameworkRepository framework = FrameworkRepository(checkouts); - expect( - (await framework.ciYaml).enabledBranches, - [FrameworkRepository.defaultBranch, 'dev', 'beta', 'stable'], - ); - - (await framework.ciYaml).enableBranch('foo'); - expect( - (await framework.ciYaml).enabledBranches, - ['foo', FrameworkRepository.defaultBranch, 'dev', 'beta', 'stable'], - ); - - expect( - (await framework.ciYaml).stringContents, - ''' -# Friendly note - -enabled_branches: - - foo - - ${FrameworkRepository.defaultBranch} - - dev - - beta - - stable -''' - ); - }); - - test('ciYaml.enableBranch() will throw if the input branch is already present in the yaml file', () { - const String commit1 = 'abc123'; - final File ciYaml = fileSystem.file('/flutter_conductor_checkouts/framework/.ci.yaml'); - processManager.addCommands([ - FakeCommand( - command: [ - 'git', - 'clone', - '--origin', - 'upstream', - '--', - FrameworkRepository.defaultUpstream, - fileSystem.path - .join(rootDir, 'flutter_conductor_checkouts', 'framework'), - ], - onRun: () { - ciYaml.createSync(recursive: true); - ciYaml.writeAsStringSync(''' -enabled_branches: - - ${FrameworkRepository.defaultBranch} - - dev - - beta - - stable -'''); - }), - const FakeCommand(command: [ - 'git', - 'checkout', - FrameworkRepository.defaultBranch, - ]), - const FakeCommand(command: [ - 'git', - 'rev-parse', - 'HEAD', - ], stdout: commit1), - ]); - final Checkouts checkouts = Checkouts( - fileSystem: fileSystem, - parentDirectory: fileSystem.directory(rootDir), - platform: platform, - processManager: processManager, - stdio: stdio, - ); - - final FrameworkRepository framework = FrameworkRepository(checkouts); - expect( - () async => (await framework.ciYaml).enableBranch(FrameworkRepository.defaultBranch), - throwsExceptionWith('.ci.yaml already contains the branch ${FrameworkRepository.defaultBranch}'), - ); - }); - test('framework repo set as localUpstream ensures requiredLocalBranches exist locally', () async { const String commit = 'deadbeef'; const String candidateBranch = 'flutter-1.2-candidate.3'; diff --git a/dev/conductor/core/test/start_test.dart b/dev/conductor/core/test/start_test.dart index 7f5c6c6884..88857c8170 100644 --- a/dev/conductor/core/test/start_test.dart +++ b/dev/conductor/core/test/start_test.dart @@ -163,7 +163,7 @@ void main() { command: ['git', 'fetch', 'mirror'], ), const FakeCommand( - command: ['git', 'checkout', candidateBranch], + command: ['git', 'checkout', 'upstream/$candidateBranch'], ), const FakeCommand( command: ['git', 'rev-parse', 'HEAD'], @@ -220,7 +220,7 @@ void main() { command: ['git', 'fetch', 'mirror'], ), const FakeCommand( - command: ['git', 'checkout', candidateBranch], + command: ['git', 'checkout', 'upstream/$candidateBranch'], ), const FakeCommand( command: ['git', 'rev-parse', 'HEAD'], @@ -349,7 +349,7 @@ void main() { command: ['git', 'fetch', 'mirror'], ), const FakeCommand( - command: ['git', 'checkout', candidateBranch], + command: ['git', 'checkout', 'upstream/$candidateBranch'], ), const FakeCommand( command: ['git', 'rev-parse', 'HEAD'], @@ -406,7 +406,7 @@ void main() { command: ['git', 'fetch', 'mirror'], ), const FakeCommand( - command: ['git', 'checkout', candidateBranch], + command: ['git', 'checkout', 'upstream/$candidateBranch'], ), const FakeCommand( command: ['git', 'rev-parse', 'HEAD'], @@ -542,7 +542,7 @@ void main() { command: ['git', 'fetch', 'mirror'], ), const FakeCommand( - command: ['git', 'checkout', candidateBranch], + command: ['git', 'checkout', 'upstream/$candidateBranch'], ), const FakeCommand( command: ['git', 'rev-parse', 'HEAD'], @@ -599,7 +599,7 @@ void main() { command: ['git', 'fetch', 'mirror'], ), const FakeCommand( - command: ['git', 'checkout', candidateBranch], + command: ['git', 'checkout', 'upstream/$candidateBranch'], ), const FakeCommand( command: ['git', 'rev-parse', 'HEAD'], @@ -729,7 +729,7 @@ void main() { command: ['git', 'fetch', 'mirror'], ), const FakeCommand( - command: ['git', 'checkout', candidateBranch], + command: ['git', 'checkout', 'upstream/$candidateBranch'], ), const FakeCommand( command: ['git', 'rev-parse', 'HEAD'], @@ -782,7 +782,7 @@ void main() { command: ['git', 'fetch', 'mirror'], ), const FakeCommand( - command: ['git', 'checkout', candidateBranch], + command: ['git', 'checkout', 'upstream/$candidateBranch'], ), const FakeCommand( command: ['git', 'rev-parse', 'HEAD'],