From bc70ae0f57b4a22722523ec28945344fb3dd4468 Mon Sep 17 00:00:00 2001 From: Casey Hillers Date: Mon, 17 Oct 2022 06:45:19 -0700 Subject: [PATCH] [packaging] Remove dev references (#113462) --- dev/bots/prepare_package.dart | 53 ++++++--------- dev/bots/test/prepare_package_test.dart | 88 ++++++++++++------------- 2 files changed, 64 insertions(+), 77 deletions(-) diff --git a/dev/bots/prepare_package.dart b/dev/bots/prepare_package.dart index b2cc416b45..2989701b02 100644 --- a/dev/bots/prepare_package.dart +++ b/dev/bots/prepare_package.dart @@ -52,29 +52,19 @@ class PreparePackageException implements Exception { } } -enum Branch { dev, beta, stable } +enum Branch { + beta, + stable; -String getBranchName(Branch branch) { - switch (branch) { - case Branch.beta: - return 'beta'; - case Branch.dev: - return 'dev'; - case Branch.stable: - return 'stable'; - } -} - -Branch fromBranchName(String name) { - switch (name) { - case 'beta': - return Branch.beta; - case 'dev': - return Branch.dev; - case 'stable': - return Branch.stable; - default: - throw ArgumentError('Invalid branch name.'); + static Branch fromName(String name) { + switch (name) { + case 'beta': + return Branch.beta; + case 'stable': + return Branch.stable; + default: + throw ArgumentError('Invalid branch name.'); + } } } @@ -304,9 +294,6 @@ class ArchiveCreator { .trim().split(' ').last.replaceAll('"', '').split('_')[1]; })(); - /// Get the name of the channel as a string. - String get branchName => getBranchName(branch); - /// Returns a default archive name when given a Git revision. /// Used when an output filename is not given. Future get _archiveName async { @@ -321,7 +308,8 @@ class ArchiveCreator { // unpacking it!) So, we use .zip for Mac, and the files are about // 220MB larger than they need to be. :-( final String suffix = platform.isLinux ? 'tar.xz' : 'zip'; - return 'flutter_${os}_$arch${_version[frameworkVersionTag]}-$branchName.$suffix'; + final String package = '${os}_$arch${_version[frameworkVersionTag]}'; + return 'flutter_$package-${branch.name}.$suffix'; } /// Checks out the flutter repo and prepares it for other operations. @@ -425,7 +413,7 @@ class ArchiveCreator { // We want the user to start out the in the specified branch instead of a // detached head. To do that, we need to make sure the branch points at the // desired revision. - await _runGit(['clone', '-b', branchName, gobMirror], workingDirectory: tempDir); + await _runGit(['clone', '-b', branch.name, gobMirror], workingDirectory: tempDir); await _runGit(['reset', '--hard', revision]); // Make the origin point to github instead of the chromium mirror. @@ -624,8 +612,7 @@ class ArchivePublisher { final File outputFile; final ProcessRunner _processRunner; final bool dryRun; - String get branchName => getBranchName(branch); - String get destinationArchivePath => '$branchName/$platformName/${path.basename(outputFile.path)}'; + String get destinationArchivePath => '${branch.name}/$platformName/${path.basename(outputFile.path)}'; static String getMetadataFilename(Platform platform) => 'releases_${platform.operatingSystem.toLowerCase()}.json'; Future _getChecksum(File archiveFile) async { @@ -666,14 +653,14 @@ class ArchivePublisher { if (!jsonData.containsKey('current_release')) { jsonData['current_release'] = {}; } - (jsonData['current_release'] as Map)[branchName] = revision; + (jsonData['current_release'] as Map)[branch.name] = revision; if (!jsonData.containsKey('releases')) { jsonData['releases'] = >[]; } final Map newEntry = {}; newEntry['hash'] = revision; - newEntry['channel'] = branchName; + newEntry['channel'] = branch.name; newEntry['version'] = version[frameworkVersionTag]; newEntry['dart_sdk_version'] = version[dartVersionTag]; newEntry['dart_sdk_arch'] = version[dartTargetArchTag]; @@ -825,7 +812,7 @@ Future main(List rawArguments) async { 'archive with. Must be the full 40-character hash. Required.'); argParser.addOption( 'branch', - allowed: Branch.values.map((Branch branch) => getBranchName(branch)), + allowed: Branch.values.map((Branch branch) => branch.name), help: 'The Flutter branch to build the archive with. Required.', ); argParser.addOption( @@ -907,7 +894,7 @@ Future main(List rawArguments) async { final bool publish = parsedArguments['publish'] as bool; final bool dryRun = parsedArguments['dry_run'] as bool; - final Branch branch = fromBranchName(parsedArguments['branch'] as String); + final Branch branch = Branch.fromName(parsedArguments['branch'] as String); final ArchiveCreator creator = ArchiveCreator( tempDir, outputDir, diff --git a/dev/bots/test/prepare_package_test.dart b/dev/bots/test/prepare_package_test.dart index c1fdf559ee..28485b5553 100644 --- a/dev/bots/test/prepare_package_test.dart +++ b/dev/bots/test/prepare_package_test.dart @@ -101,7 +101,7 @@ void main() { tempDir, tempDir, testRef, - Branch.dev, + Branch.beta, processManager: processManager, subprocessOutput: false, platform: platform, @@ -120,10 +120,10 @@ void main() { test('sets PUB_CACHE properly', () async { final String createBase = path.join(tempDir.absolute.path, 'create_'); final String archiveName = path.join(tempDir.absolute.path, - 'flutter_${platformName}_v1.2.3-dev${platform.isLinux ? '.tar.xz' : '.zip'}'); + 'flutter_${platformName}_v1.2.3-beta${platform.isLinux ? '.tar.xz' : '.zip'}'); processManager.addCommands(convertResults(?>{ - 'git clone -b dev https://flutter.googlesource.com/mirrors/flutter': null, + 'git clone -b beta https://flutter.googlesource.com/mirrors/flutter': null, 'git reset --hard $testRef': null, 'git remote set-url origin https://github.com/flutter/flutter.git': null, 'git describe --tags --exact-match $testRef': [ProcessResult(0, 0, 'v1.2.3', '')], @@ -132,7 +132,7 @@ void main() { ProcessResult(0, 0, '{"dartSdkVersion": "3.2.1"}', ''), ], '$dart --version': [ - ProcessResult(0, 0, 'Dart SDK version: 2.17.0-63.0.dev (dev) (Wed Jan 26 03:48:52 2022 -0800) on "${platformName}_x64"', ''), + ProcessResult(0, 0, 'Dart SDK version: 2.17.0-63.0.beta (beta) (Wed Jan 26 03:48:52 2022 -0800) on "${platformName}_x64"', ''), ], if (platform.isWindows) '7za x ${path.join(tempDir.path, 'mingit.zip')}': null, '$flutter doctor': null, @@ -157,9 +157,9 @@ void main() { test('calls the right commands for archive output', () async { final String createBase = path.join(tempDir.absolute.path, 'create_'); final String archiveName = path.join(tempDir.absolute.path, - 'flutter_${platformName}_v1.2.3-dev${platform.isLinux ? '.tar.xz' : '.zip'}'); + 'flutter_${platformName}_v1.2.3-beta${platform.isLinux ? '.tar.xz' : '.zip'}'); final Map?> calls = ?>{ - 'git clone -b dev https://flutter.googlesource.com/mirrors/flutter': null, + 'git clone -b beta https://flutter.googlesource.com/mirrors/flutter': null, 'git reset --hard $testRef': null, 'git remote set-url origin https://github.com/flutter/flutter.git': null, 'git describe --tags --exact-match $testRef': [ProcessResult(0, 0, 'v1.2.3', '')], @@ -168,7 +168,7 @@ void main() { ProcessResult(0, 0, '{"dartSdkVersion": "3.2.1"}', ''), ], '$dart --version': [ - ProcessResult(0, 0, 'Dart SDK version: 2.17.0-63.0.dev (dev) (Wed Jan 26 03:48:52 2022 -0800) on "${platformName}_x64"', ''), + ProcessResult(0, 0, 'Dart SDK version: 2.17.0-63.0.beta (beta) (Wed Jan 26 03:48:52 2022 -0800) on "${platformName}_x64"', ''), ], if (platform.isWindows) '7za x ${path.join(tempDir.path, 'mingit.zip')}': null, '$flutter doctor': null, @@ -191,7 +191,7 @@ void main() { tempDir, tempDir, testRef, - Branch.dev, + Branch.beta, processManager: processManager, subprocessOutput: false, platform: platform, @@ -204,9 +204,9 @@ void main() { test('adds the arch name to the archive for non-x64', () async { final String createBase = path.join(tempDir.absolute.path, 'create_'); final String archiveName = path.join(tempDir.absolute.path, - 'flutter_${platformName}_arm64_v1.2.3-dev${platform.isLinux ? '.tar.xz' : '.zip'}'); + 'flutter_${platformName}_arm64_v1.2.3-beta${platform.isLinux ? '.tar.xz' : '.zip'}'); final Map?> calls = ?>{ - 'git clone -b dev https://flutter.googlesource.com/mirrors/flutter': null, + 'git clone -b beta https://flutter.googlesource.com/mirrors/flutter': null, 'git reset --hard $testRef': null, 'git remote set-url origin https://github.com/flutter/flutter.git': null, 'git describe --tags --exact-match $testRef': [ProcessResult(0, 0, 'v1.2.3', '')], @@ -215,7 +215,7 @@ void main() { ProcessResult(0, 0, '{"dartSdkVersion": "3.2.1"}', ''), ], '$dart --version': [ - ProcessResult(0, 0, 'Dart SDK version: 2.17.0-63.0.dev (dev) (Wed Jan 26 03:48:52 2022 -0800) on "${platformName}_arm64"', ''), + ProcessResult(0, 0, 'Dart SDK version: 2.17.0-63.0.beta (beta) (Wed Jan 26 03:48:52 2022 -0800) on "${platformName}_arm64"', ''), ], if (platform.isWindows) '7za x ${path.join(tempDir.path, 'mingit.zip')}': null, '$flutter doctor': null, @@ -238,7 +238,7 @@ void main() { tempDir, tempDir, testRef, - Branch.dev, + Branch.beta, processManager: processManager, subprocessOutput: false, platform: platform, @@ -250,7 +250,7 @@ void main() { test('throws when a command errors out', () async { final Map> calls = >{ - 'git clone -b dev https://flutter.googlesource.com/mirrors/flutter': + 'git clone -b beta https://flutter.googlesource.com/mirrors/flutter': [ProcessResult(0, 0, 'output1', '')], 'git reset --hard $testRef': [ProcessResult(0, -1, 'output2', '')], }; @@ -261,9 +261,9 @@ void main() { test('non-strict mode calls the right commands', () async { final String createBase = path.join(tempDir.absolute.path, 'create_'); final String archiveName = path.join(tempDir.absolute.path, - 'flutter_${platformName}_v1.2.3-dev${platform.isLinux ? '.tar.xz' : '.zip'}'); + 'flutter_${platformName}_v1.2.3-beta${platform.isLinux ? '.tar.xz' : '.zip'}'); final Map?> calls = ?>{ - 'git clone -b dev https://flutter.googlesource.com/mirrors/flutter': null, + 'git clone -b beta https://flutter.googlesource.com/mirrors/flutter': null, 'git reset --hard $testRef': null, 'git remote set-url origin https://github.com/flutter/flutter.git': null, 'git describe --tags --abbrev=0 $testRef': [ProcessResult(0, 0, 'v1.2.3', '')], @@ -272,7 +272,7 @@ void main() { ProcessResult(0, 0, '{"dartSdkVersion": "3.2.1"}', ''), ], '$dart --version': [ - ProcessResult(0, 0, 'Dart SDK version: 2.17.0-63.0.dev (dev) (Wed Jan 26 03:48:52 2022 -0800) on "${platformName}_x64"', ''), + ProcessResult(0, 0, 'Dart SDK version: 2.17.0-63.0.beta (beta) (Wed Jan 26 03:48:52 2022 -0800) on "${platformName}_x64"', ''), ], if (platform.isWindows) '7za x ${path.join(tempDir.path, 'mingit.zip')}': null, '$flutter doctor': null, @@ -294,7 +294,7 @@ void main() { tempDir, tempDir, testRef, - Branch.dev, + Branch.beta, strict: false, processManager: processManager, subprocessOutput: false, @@ -308,11 +308,11 @@ void main() { test('fails if binary is not codesigned', () async { final String createBase = path.join(tempDir.absolute.path, 'create_'); final String archiveName = path.join(tempDir.absolute.path, - 'flutter_${platformName}_v1.2.3-dev${platform.isLinux ? '.tar.xz' : '.zip'}'); + 'flutter_${platformName}_v1.2.3-beta${platform.isLinux ? '.tar.xz' : '.zip'}'); final ProcessResult codesignFailure = ProcessResult(1, 1, '', 'code object is not signed at all'); final String binPath = path.join(tempDir.path, 'flutter', 'bin', 'cache', 'dart-sdk', 'bin', 'dart'); final Map?> calls = ?>{ - 'git clone -b dev https://flutter.googlesource.com/mirrors/flutter': null, + 'git clone -b beta https://flutter.googlesource.com/mirrors/flutter': null, 'git reset --hard $testRef': null, 'git remote set-url origin https://github.com/flutter/flutter.git': null, 'git describe --tags --exact-match $testRef': [ProcessResult(0, 0, 'v1.2.3', '')], @@ -321,7 +321,7 @@ void main() { ProcessResult(0, 0, '{"dartSdkVersion": "3.2.1"}', ''), ], '$dart --version': [ - ProcessResult(0, 0, 'Dart SDK version: 2.17.0-63.0.dev (dev) (Wed Jan 26 03:48:52 2022 -0800) on "${platformName}_x64"', ''), + ProcessResult(0, 0, 'Dart SDK version: 2.17.0-63.0.beta (beta) (Wed Jan 26 03:48:52 2022 -0800) on "${platformName}_x64"', ''), ], if (platform.isWindows) '7za x ${path.join(tempDir.path, 'mingit.zip')}': null, '$flutter doctor': null, @@ -344,7 +344,7 @@ void main() { tempDir, tempDir, testRef, - Branch.dev, + Branch.beta, processManager: processManager, subprocessOutput: false, platform: platform, @@ -392,15 +392,15 @@ void main() { "base_url": "https://storage.googleapis.com/flutter_infra_release/releases", "current_release": { "beta": "3ea4d06340a97a1e9d7cae97567c64e0569dcaa2", - "dev": "5a58b36e36b8d7aace89d3950e6deb307956a6a0" + "beta": "5a58b36e36b8d7aace89d3950e6deb307956a6a0" }, "releases": [ { "hash": "5a58b36e36b8d7aace89d3950e6deb307956a6a0", - "channel": "dev", + "channel": "beta", "version": "v0.2.3", "release_date": "2018-03-20T01:47:02.851729Z", - "archive": "dev/$platformName/flutter_${platformName}_v0.2.3-dev.zip", + "archive": "beta/$platformName/flutter_${platformName}_v0.2.3-beta.zip", "sha256": "4fe85a822093e81cb5a66c7fc263f68de39b5797b294191b6d75e7afcc86aff8", "dart_sdk_arch": "x64" }, @@ -409,7 +409,7 @@ void main() { "channel": "beta", "version": "v0.2.2", "release_date": "2018-03-16T18:48:13.375013Z", - "archive": "dev/$platformName/flutter_${platformName}_v0.2.2-dev.zip", + "archive": "beta/$platformName/flutter_${platformName}_v0.2.2-beta.zip", "sha256": "6073331168cdb37a4637a5dc073d6a7ef4e466321effa2c529fa27d2253a4d4b", "dart_sdk_arch": "x64" }, @@ -418,7 +418,7 @@ void main() { "channel": "stable", "version": "v0.0.0", "release_date": "2018-03-20T01:47:02.851729Z", - "archive": "stable/$platformName/flutter_${platformName}_v0.0.0-dev.zip", + "archive": "stable/$platformName/flutter_${platformName}_v0.0.0-beta.zip", "sha256": "5dd34873b3a3e214a32fd30c2c319a0f46e608afb72f0d450b2d621a6d02aebd", "dart_sdk_arch": "x64" } @@ -470,7 +470,7 @@ void main() { expect(contents, contains('"hash": "5a58b36e36b8d7aace89d3950e6deb307956a6a0"')); expect(contents, contains('"hash": "b9bd51cc36b706215915711e580851901faebb40"')); expect(contents, contains('"channel": "beta"')); - expect(contents, contains('"channel": "dev"')); + expect(contents, contains('"channel": "beta"')); // Make sure old matching entries are removed. expect(contents, isNot(contains('v0.0.0'))); final Map jsonData = json.decode(contents) as Map; @@ -495,15 +495,15 @@ void main() { "base_url": "https://storage.googleapis.com/flutter_infra_release/releases", "current_release": { "beta": "3ea4d06340a97a1e9d7cae97567c64e0569dcaa2", - "dev": "5a58b36e36b8d7aace89d3950e6deb307956a6a0" + "beta": "5a58b36e36b8d7aace89d3950e6deb307956a6a0" }, "releases": [ { "hash": "5a58b36e36b8d7aace89d3950e6deb307956a6a0", - "channel": "dev", + "channel": "beta", "version": "v0.2.3", "release_date": "2018-03-20T01:47:02.851729Z", - "archive": "dev/$platformName/flutter_${platformName}_v0.2.3-dev.zip", + "archive": "beta/$platformName/flutter_${platformName}_v0.2.3-beta.zip", "sha256": "4fe85a822093e81cb5a66c7fc263f68de39b5797b294191b6d75e7afcc86aff8" }, { @@ -511,7 +511,7 @@ void main() { "channel": "beta", "version": "v0.2.2", "release_date": "2018-03-16T18:48:13.375013Z", - "archive": "dev/$platformName/flutter_${platformName}_v0.2.2-dev.zip", + "archive": "beta/$platformName/flutter_${platformName}_v0.2.2-beta.zip", "sha256": "6073331168cdb37a4637a5dc073d6a7ef4e466321effa2c529fa27d2253a4d4b" }, { @@ -519,7 +519,7 @@ void main() { "channel": "stable", "version": "v0.0.0", "release_date": "2018-03-20T01:47:02.851729Z", - "archive": "stable/$platformName/flutter_${platformName}_v0.0.0-dev.zip", + "archive": "stable/$platformName/flutter_${platformName}_v0.0.0-beta.zip", "sha256": "5dd34873b3a3e214a32fd30c2c319a0f46e608afb72f0d450b2d621a6d02aebd" } ] @@ -574,7 +574,7 @@ void main() { "base_url": "https://storage.googleapis.com/flutter_infra_release/releases", "current_release": { "beta": "3ea4d06340a97a1e9d7cae97567c64e0569dcaa2", - "dev": "5a58b36e36b8d7aace89d3950e6deb307956a6a0" + "beta": "5a58b36e36b8d7aace89d3950e6deb307956a6a0" }, "releases": [ { @@ -582,7 +582,7 @@ void main() { "channel": "stable", "version": "v1.2.3", "release_date": "2018-03-20T01:47:02.851729Z", - "archive": "dev/$platformName/flutter_${platformName}_v0.2.3-dev.zip", + "archive": "beta/$platformName/flutter_${platformName}_v0.2.3-beta.zip", "sha256": "4fe85a822093e81cb5a66c7fc263f68de39b5797b294191b6d75e7afcc86aff8", "dart_sdk_arch": "x64" } @@ -639,15 +639,15 @@ void main() { "base_url": "https://storage.googleapis.com/flutter_infra_release/releases", "current_release": { "beta": "3ea4d06340a97a1e9d7cae97567c64e0569dcaa2", - "dev": "5a58b36e36b8d7aace89d3950e6deb307956a6a0" + "beta": "5a58b36e36b8d7aace89d3950e6deb307956a6a0" }, "releases": [ { "hash": "5a58b36e36b8d7aace89d3950e6deb307956a6a0", - "channel": "dev", + "channel": "beta", "version": "v0.2.3", "release_date": "2018-03-20T01:47:02.851729Z", - "archive": "dev/$platformName/flutter_${platformName}_v0.2.3-dev.zip", + "archive": "beta/$platformName/flutter_${platformName}_v0.2.3-beta.zip", "sha256": "4fe85a822093e81cb5a66c7fc263f68de39b5797b294191b6d75e7afcc86aff8" }, { @@ -655,7 +655,7 @@ void main() { "channel": "beta", "version": "v0.2.2", "release_date": "2018-03-16T18:48:13.375013Z", - "archive": "dev/$platformName/flutter_${platformName}_v0.2.2-dev.zip", + "archive": "beta/$platformName/flutter_${platformName}_v0.2.2-beta.zip", "sha256": "6073331168cdb37a4637a5dc073d6a7ef4e466321effa2c529fa27d2253a4d4b" }, { @@ -663,7 +663,7 @@ void main() { "channel": "stable", "version": "v0.0.0", "release_date": "2018-03-20T01:47:02.851729Z", - "archive": "stable/$platformName/flutter_${platformName}_v0.0.0-dev.zip", + "archive": "stable/$platformName/flutter_${platformName}_v0.0.0-beta.zip", "sha256": "5dd34873b3a3e214a32fd30c2c319a0f46e608afb72f0d450b2d621a6d02aebd" } ] @@ -761,15 +761,15 @@ void main() { "base_url": "https://storage.googleapis.com/flutter_infra_release/releases", "current_release": { "beta": "3ea4d06340a97a1e9d7cae97567c64e0569dcaa2", - "dev": "5a58b36e36b8d7aace89d3950e6deb307956a6a0" + "beta": "5a58b36e36b8d7aace89d3950e6deb307956a6a0" }, "releases": [ { "hash": "5a58b36e36b8d7aace89d3950e6deb307956a6a0", - "channel": "dev", + "channel": "beta", "version": "v0.2.3", "release_date": "2018-03-20T01:47:02.851729Z", - "archive": "dev/$platformName/flutter_${platformName}_v0.2.3-dev.zip", + "archive": "beta/$platformName/flutter_${platformName}_v0.2.3-beta.zip", "sha256": "4fe85a822093e81cb5a66c7fc263f68de39b5797b294191b6d75e7afcc86aff8" }, { @@ -777,7 +777,7 @@ void main() { "channel": "beta", "version": "v0.2.2", "release_date": "2018-03-16T18:48:13.375013Z", - "archive": "dev/$platformName/flutter_${platformName}_v0.2.2-dev.zip", + "archive": "beta/$platformName/flutter_${platformName}_v0.2.2-beta.zip", "sha256": "6073331168cdb37a4637a5dc073d6a7ef4e466321effa2c529fa27d2253a4d4b" }, { @@ -785,7 +785,7 @@ void main() { "channel": "stable", "version": "v0.0.0", "release_date": "2018-03-20T01:47:02.851729Z", - "archive": "stable/$platformName/flutter_${platformName}_v0.0.0-dev.zip", + "archive": "stable/$platformName/flutter_${platformName}_v0.0.0-beta.zip", "sha256": "5dd34873b3a3e214a32fd30c2c319a0f46e608afb72f0d450b2d621a6d02aebd" } ]