From 8bee0834e4be79879f15222cce8fa9642cfefb2b Mon Sep 17 00:00:00 2001 From: godofredoc <54371434+godofredoc@users.noreply.github.com> Date: Thu, 27 May 2021 19:04:02 -0700 Subject: [PATCH] Remove logic to save artifacts to old gcs location. (#83526) --- dev/bots/prepare_package.dart | 49 +++++++++++-------------- dev/bots/test/prepare_package_test.dart | 35 ++++-------------- 2 files changed, 28 insertions(+), 56 deletions(-) diff --git a/dev/bots/prepare_package.dart b/dev/bots/prepare_package.dart index 1ac56f68ba6..7f5b4985095 100644 --- a/dev/bots/prepare_package.dart +++ b/dev/bots/prepare_package.dart @@ -20,13 +20,10 @@ const String chromiumRepo = 'https://chromium.googlesource.com/external/github.c const String githubRepo = 'https://github.com/flutter/flutter.git'; const String mingitForWindowsUrl = 'https://storage.googleapis.com/flutter_infra_release/mingit/' '603511c649b00bbef0a6122a827ac419b656bc19/mingit.zip'; -const String oldGsBase = 'gs://flutter_infra'; const String releaseFolder = '/releases'; -const String oldGsReleaseFolder = '$oldGsBase$releaseFolder'; -const String oldBaseUrl = 'https://storage.googleapis.com/flutter_infra'; -const String newGsBase = 'gs://flutter_infra_release'; -const String newGsReleaseFolder = '$newGsBase$releaseFolder'; -const String newBaseUrl = 'https://storage.googleapis.com/flutter_infra_release'; +const String gsBase = 'gs://flutter_infra_release'; +const String gsReleaseFolder = '$gsBase$releaseFolder'; +const String baseUrl = 'https://storage.googleapis.com/flutter_infra_release'; const int shortCacheSeconds = 60; /// Exception class for when a process fails to run, so we can catch @@ -540,7 +537,7 @@ class ArchivePublisher { this.platform = const LocalPlatform(), }) : assert(revision.length == 40), platformName = platform.operatingSystem.toLowerCase(), - metadataGsPath = '$newGsReleaseFolder/${getMetadataFilename(platform)}', + metadataGsPath = '$gsReleaseFolder/${getMetadataFilename(platform)}', _processRunner = ProcessRunner( processManager: processManager, subprocessOutput: subprocessOutput, @@ -577,28 +574,24 @@ class ArchivePublisher { /// This method will throw if the target archive already exists on cloud /// storage. Future publishArchive([bool forceUpload = false]) async { - for (final bool isNew in [false, true]) { - final String releaseFolder = isNew ? newGsReleaseFolder : oldGsReleaseFolder; - final String destGsPath = '$releaseFolder/$destinationArchivePath'; - if (!forceUpload) { - if (await _cloudPathExists(destGsPath) && !dryRun) { - throw PreparePackageException( - 'File $destGsPath already exists on cloud storage!', - ); - } + final String destGsPath = '$gsReleaseFolder/$destinationArchivePath'; + if (!forceUpload) { + if (await _cloudPathExists(destGsPath) && !dryRun) { + throw PreparePackageException( + 'File $destGsPath already exists on cloud storage!', + ); } - await _cloudCopy( - src: outputFile.absolute.path, - dest: destGsPath, - ); - assert(tempDir.existsSync()); - await _updateMetadata('$releaseFolder/${getMetadataFilename(platform)}', newBucket: isNew); } + await _cloudCopy( + src: outputFile.absolute.path, + dest: destGsPath, + ); + assert(tempDir.existsSync()); + await _updateMetadata('$gsReleaseFolder/${getMetadataFilename(platform)}'); } - Future> _addRelease(Map jsonData, {bool newBucket=true}) async { - final String tmpBaseUrl = newBucket ? newBaseUrl : oldBaseUrl; - jsonData['base_url'] = '$tmpBaseUrl$releaseFolder'; + Future> _addRelease(Map jsonData) async { + jsonData['base_url'] = '$baseUrl$releaseFolder'; if (!jsonData.containsKey('current_release')) { jsonData['current_release'] = {}; } @@ -630,7 +623,7 @@ class ArchivePublisher { return jsonData; } - Future _updateMetadata(String gsPath, {bool newBucket=true}) async { + Future _updateMetadata(String gsPath) async { // We can't just cat the metadata from the server with 'gsutil cat', because // Windows wants to echo the commands that execute in gsutil.bat to the // stdout when we do that. So, we copy the file locally and then read it @@ -652,7 +645,7 @@ class ArchivePublisher { throw PreparePackageException('Unable to parse JSON metadata received from cloud: $e'); } - jsonData = await _addRelease(jsonData, newBucket: newBucket); + jsonData = await _addRelease(jsonData); const JsonEncoder encoder = JsonEncoder.withIndent(' '); metadataFile.writeAsStringSync(encoder.convert(jsonData)); @@ -776,7 +769,7 @@ Future main(List rawArguments) async { defaultsTo: false, help: 'If set, will publish the archive to Google Cloud Storage upon ' 'successful creation of the archive. Will publish under this ' - 'directory: $newBaseUrl$releaseFolder', + 'directory: $baseUrl$releaseFolder', ); argParser.addFlag( 'force', diff --git a/dev/bots/test/prepare_package_test.dart b/dev/bots/test/prepare_package_test.dart index ae2f954eade..b8937b0fc34 100644 --- a/dev/bots/test/prepare_package_test.dart +++ b/dev/bots/test/prepare_package_test.dart @@ -294,8 +294,7 @@ void main() { final String releasesName = 'releases_$platformName.json'; final String archiveName = platform.isLinux ? 'archive.tar.xz' : 'archive.zip'; final String archiveMime = platform.isLinux ? 'application/x-gtar' : 'application/zip'; - final String gsArchivePath = 'gs://flutter_infra/releases/stable/$platformName/$archiveName'; - final String newGsArchivePath = 'gs://flutter_infra_release/releases/stable/$platformName/$archiveName'; + final String gsArchivePath = 'gs://flutter_infra_release/releases/stable/$platformName/$archiveName'; setUp(() async { processManager = FakeProcessManager.list([]); @@ -309,11 +308,10 @@ void main() { test('calls the right processes', () async { final String archivePath = path.join(tempDir.absolute.path, archiveName); final String jsonPath = path.join(tempDir.absolute.path, releasesName); - final String gsJsonPath = 'gs://flutter_infra/releases/$releasesName'; - final String newGsJsonPath = 'gs://flutter_infra_release/releases/$releasesName'; + final String gsJsonPath = 'gs://flutter_infra_release/releases/$releasesName'; final String releasesJson = ''' { - "base_url": "https://storage.googleapis.com/flutter_infra/releases", + "base_url": "https://storage.googleapis.com/flutter_infra_release/releases", "current_release": { "beta": "3ea4d06340a97a1e9d7cae97567c64e0569dcaa2", "dev": "5a58b36e36b8d7aace89d3950e6deb307956a6a0" @@ -356,12 +354,6 @@ void main() { '$gsutilCall -- cp $gsJsonPath $jsonPath': null, '$gsutilCall -- rm $gsJsonPath': null, '$gsutilCall -- -h Content-Type:application/json -h Cache-Control:max-age=60 cp $jsonPath $gsJsonPath': null, - '$gsutilCall -- stat $newGsArchivePath': [ProcessResult(0, 1, '', '')], - '$gsutilCall -- rm $newGsArchivePath': null, - '$gsutilCall -- -h Content-Type:$archiveMime cp $archivePath $newGsArchivePath': null, - '$gsutilCall -- cp $newGsJsonPath $jsonPath': null, - '$gsutilCall -- rm $newGsJsonPath': null, - '$gsutilCall -- -h Content-Type:application/json -h Cache-Control:max-age=60 cp $jsonPath $newGsJsonPath': null, }; processManager.addCommands(convertResults(calls)); final File outputFile = File(path.join(tempDir.absolute.path, archiveName)); @@ -412,11 +404,10 @@ void main() { test('updates base_url from old bucket to new bucket', () async { final String archivePath = path.join(tempDir.absolute.path, archiveName); final String jsonPath = path.join(tempDir.absolute.path, releasesName); - final String gsJsonPath = 'gs://flutter_infra/releases/$releasesName'; - final String newGsJsonPath = 'gs://flutter_infra_release/releases/$releasesName'; + final String gsJsonPath = 'gs://flutter_infra_release/releases/$releasesName'; final String releasesJson = ''' { - "base_url": "https://storage.googleapis.com/flutter_infra/releases", + "base_url": "https://storage.googleapis.com/flutter_infra_release/releases", "current_release": { "beta": "3ea4d06340a97a1e9d7cae97567c64e0569dcaa2", "dev": "5a58b36e36b8d7aace89d3950e6deb307956a6a0" @@ -459,12 +450,6 @@ void main() { '$gsutilCall -- cp $gsJsonPath $jsonPath': null, '$gsutilCall -- rm $gsJsonPath': null, '$gsutilCall -- -h Content-Type:application/json -h Cache-Control:max-age=60 cp $jsonPath $gsJsonPath': null, - '$gsutilCall -- stat $newGsArchivePath': [ProcessResult(0, 1, '', '')], - '$gsutilCall -- rm $newGsArchivePath': null, - '$gsutilCall -- -h Content-Type:$archiveMime cp $archivePath $newGsArchivePath': null, - '$gsutilCall -- cp $newGsJsonPath $jsonPath': null, - '$gsutilCall -- rm $newGsJsonPath': null, - '$gsutilCall -- -h Content-Type:application/json -h Cache-Control:max-age=60 cp $jsonPath $newGsJsonPath': null, }; processManager.addCommands(convertResults(calls)); final File outputFile = File(path.join(tempDir.absolute.path, archiveName)); @@ -529,11 +514,10 @@ void main() { ); final String archivePath = path.join(tempDir.absolute.path, archiveName); final String jsonPath = path.join(tempDir.absolute.path, releasesName); - final String gsJsonPath = 'gs://flutter_infra/releases/$releasesName'; - final String newGsJsonPath = 'gs://flutter_infra_release/releases/$releasesName'; + final String gsJsonPath = 'gs://flutter_infra_release/releases/$releasesName'; final String releasesJson = ''' { - "base_url": "https://storage.googleapis.com/flutter_infra/releases", + "base_url": "https://storage.googleapis.com/flutter_infra_release/releases", "current_release": { "beta": "3ea4d06340a97a1e9d7cae97567c64e0569dcaa2", "dev": "5a58b36e36b8d7aace89d3950e6deb307956a6a0" @@ -574,11 +558,6 @@ void main() { '$gsutilCall -- cp $gsJsonPath $jsonPath': null, '$gsutilCall -- rm $gsJsonPath': null, '$gsutilCall -- -h Content-Type:application/json -h Cache-Control:max-age=60 cp $jsonPath $gsJsonPath': null, - '$gsutilCall -- rm $newGsArchivePath': null, - '$gsutilCall -- -h Content-Type:$archiveMime cp $archivePath $newGsArchivePath': null, - '$gsutilCall -- cp $newGsJsonPath $jsonPath': null, - '$gsutilCall -- rm $newGsJsonPath': null, - '$gsutilCall -- -h Content-Type:application/json -h Cache-Control:max-age=60 cp $jsonPath $newGsJsonPath': null, }; processManager.addCommands(convertResults(calls)); assert(tempDir.existsSync());