From ad936b4e4b778dde40b6adfea265b5f97f76f62d Mon Sep 17 00:00:00 2001 From: Christopher Fujino Date: Tue, 14 Sep 2021 14:39:17 -0700 Subject: [PATCH] [flutter_conductor] Support initial stable release version (#89775) --- dev/conductor/lib/start.dart | 16 ++- dev/conductor/test/start_test.dart | 182 +++++++++++++++++++++++++++++ 2 files changed, 197 insertions(+), 1 deletion(-) diff --git a/dev/conductor/lib/start.dart b/dev/conductor/lib/start.dart index b22f7904854..abe5584ab23 100644 --- a/dev/conductor/lib/start.dart +++ b/dev/conductor/lib/start.dart @@ -315,7 +315,21 @@ class StartCommand extends Command { if (incrementLetter == 'm') { nextVersion = Version.fromCandidateBranch(candidateBranch); } else { - nextVersion = Version.increment(lastVersion, incrementLetter); + if (incrementLetter == 'z') { + if (lastVersion.type == VersionType.stable) { + nextVersion = Version.increment(lastVersion, incrementLetter); + } else { + // This is the first stable release, so hardcode the z as 0 + nextVersion = Version( + x: lastVersion.x, + y: lastVersion.y, + z: 0, + type: VersionType.stable, + ); + } + } else { + nextVersion = Version.increment(lastVersion, incrementLetter); + } } state.releaseVersion = nextVersion.toString(); diff --git a/dev/conductor/test/start_test.dart b/dev/conductor/test/start_test.dart index f56e789eeaf..11a112cd5b2 100644 --- a/dev/conductor/test/start_test.dart +++ b/dev/conductor/test/start_test.dart @@ -289,6 +289,188 @@ void main() { expect(state.conductorVersion, revision); expect(state.incrementLevel, incrementLevel); }); + + test('can convert from dev style version to stable version', () async { + const String revision2 = 'def789'; + const String revision3 = '123abc'; + const String previousDartRevision = '171876a4e6cf56ee6da1f97d203926bd7afda7ef'; + const String nextDartRevision = 'f6c91128be6b77aef8351e1e3a9d07c85bc2e46e'; + const String previousVersion = '1.2.0-1.0.pre'; + const String nextVersion = '1.2.0'; + const String incrementLevel = 'z'; + + final Directory engine = fileSystem.directory(checkoutsParentDirectory) + .childDirectory('flutter_conductor_checkouts') + .childDirectory('engine'); + + final File depsFile = engine.childFile('DEPS'); + + final List engineCommands = [ + FakeCommand( + command: [ + 'git', + 'clone', + '--origin', + 'upstream', + '--', + EngineRepository.defaultUpstream, + engine.path, + ], + onRun: () { + // Create the DEPS file which the tool will update + engine.createSync(recursive: true); + depsFile.writeAsStringSync(generateMockDeps(previousDartRevision)); + } + ), + const FakeCommand( + command: ['git', 'remote', 'add', 'mirror', engineMirror], + ), + const FakeCommand( + command: ['git', 'fetch', 'mirror'], + ), + const FakeCommand( + command: ['git', 'checkout', 'upstream/$candidateBranch'], + ), + const FakeCommand( + command: ['git', 'rev-parse', 'HEAD'], + stdout: revision2, + ), + const FakeCommand( + command: [ + 'git', + 'checkout', + '-b', + 'cherrypicks-$candidateBranch', + ], + ), + const FakeCommand( + command: ['git', 'status', '--porcelain'], + stdout: 'MM path/to/DEPS', + ), + const FakeCommand( + command: ['git', 'add', '--all'], + ), + const FakeCommand( + command: ['git', 'commit', "--message='Update Dart SDK to $nextDartRevision'"], + ), + const FakeCommand( + command: ['git', 'rev-parse', 'HEAD'], + stdout: revision2, + ), + const FakeCommand( + command: ['git', 'rev-parse', 'HEAD'], + stdout: revision2, + ), + ]; + + final List frameworkCommands = [ + FakeCommand( + command: [ + 'git', + 'clone', + '--origin', + 'upstream', + '--', + FrameworkRepository.defaultUpstream, + fileSystem.path.join( + checkoutsParentDirectory, + 'flutter_conductor_checkouts', + 'framework', + ), + ], + ), + const FakeCommand( + command: ['git', 'remote', 'add', 'mirror', frameworkMirror], + ), + const FakeCommand( + command: ['git', 'fetch', 'mirror'], + ), + const FakeCommand( + command: ['git', 'checkout', 'upstream/$candidateBranch'], + ), + const FakeCommand( + command: ['git', 'rev-parse', 'HEAD'], + stdout: revision3, + ), + const FakeCommand( + command: [ + 'git', + 'checkout', + '-b', + 'cherrypicks-$candidateBranch', + ], + ), + const FakeCommand( + command: [ + 'git', + 'describe', + '--match', + '*.*.*', + '--tags', + 'refs/remotes/upstream/$candidateBranch', + ], + stdout: '$previousVersion-42-gabc123', + ), + const FakeCommand( + command: ['git', 'rev-parse', 'HEAD'], + stdout: revision3, + ), + ]; + + final CommandRunner runner = createRunner( + commands: [ + const FakeCommand( + command: ['git', 'rev-parse', 'HEAD'], + stdout: revision, + ), + ...engineCommands, + ...frameworkCommands, + ], + ); + + final String stateFilePath = fileSystem.path.join( + platform.environment['HOME']!, + kStateFileName, + ); + + await runner.run([ + 'start', + '--$kFrameworkMirrorOption', + frameworkMirror, + '--$kEngineMirrorOption', + engineMirror, + '--$kCandidateOption', + candidateBranch, + '--$kReleaseOption', + releaseChannel, + '--$kStateOption', + stateFilePath, + '--$kDartRevisionOption', + nextDartRevision, + '--$kIncrementOption', + incrementLevel, + ]); + + final File stateFile = fileSystem.file(stateFilePath); + + final pb.ConductorState state = pb.ConductorState(); + state.mergeFromProto3Json( + jsonDecode(stateFile.readAsStringSync()), + ); + + expect(processManager.hasRemainingExpectations, false); + expect(state.isInitialized(), true); + expect(state.releaseChannel, releaseChannel); + expect(state.releaseVersion, nextVersion); + expect(state.engine.candidateBranch, candidateBranch); + expect(state.engine.startingGitHead, revision2); + expect(state.engine.dartRevision, nextDartRevision); + expect(state.framework.candidateBranch, candidateBranch); + expect(state.framework.startingGitHead, revision3); + expect(state.currentPhase, ReleasePhase.APPLY_ENGINE_CHERRYPICKS); + expect(state.conductorVersion, revision); + expect(state.incrementLevel, incrementLevel); + }); }, onPlatform: { 'windows': const Skip('Flutter Conductor only supported on macos/linux'), });