From b6eb46ddba02ed875ead9f72368ea8b59061448f Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Thu, 4 Mar 2021 12:22:05 -0800 Subject: [PATCH 01/43] version check --- .../tool/lib/src/version_check_command.dart | 60 ++++++++++++++++++- script/tool/test/util.dart | 14 ++++- script/tool/test/version_check_test.dart | 22 +++++++ 3 files changed, 94 insertions(+), 2 deletions(-) diff --git a/script/tool/lib/src/version_check_command.dart b/script/tool/lib/src/version_check_command.dart index 2c6b92bbcb7a..c81aca32beaf 100644 --- a/script/tool/lib/src/version_check_command.dart +++ b/script/tool/lib/src/version_check_command.dart @@ -13,6 +13,7 @@ import 'package:pub_semver/pub_semver.dart'; import 'package:pubspec_parse/pubspec_parse.dart'; import 'package:yaml/yaml.dart'; +import 'common.dart'; import 'common.dart'; const String _kBaseSha = 'base_sha'; @@ -143,7 +144,8 @@ class VersionCheckCommand extends PluginCommand { @override final String description = - 'Checks if the versions of the plugins have been incremented per pub specification.\n\n' + 'Checks if the versions of the plugins have been incremented per pub specification.\n' + 'Also checks if the version in CHANGELOG matches the version in pubspec.\n\n' 'This command requires "pub" and "flutter" to be in your path.'; @override @@ -215,6 +217,62 @@ class VersionCheckCommand extends PluginCommand { } } + await for (Directory plugin in getPlugins()) { + await _checkVersionsMatch(plugin); + } + print('No version check errors found!'); } + + Future _checkVersionsMatch(Directory plugin) async { + // get version from pubspec + final String packageName = plugin.basename; + print('Checking that $packageName has matching version in CHANGELOG and pubspec'); + + final Pubspec pubspec = _tryParsePubspec(plugin); + if (pubspec.publishTo == 'none') { + print('Package $packageName is marked as unpublishable. Skipping.'); + return; + } + final Version fromPubspec = pubspec.version; + + // get version from CHANGELOG + final File changelog = plugin.childFile('CHANGELOG.md'); + final List lines = changelog.readAsLinesSync(); + final String firstLine = lines.first; + Version fromChangeLog = Version.parse(firstLine); + if (fromChangeLog == null) { + print( + 'Can not find version on the first line of CHANGELOG.md', + ); + throw ToolExit(1); + } + + if (fromPubspec != fromChangeLog) { + print( + 'versions for $packageName in CHANGELOG.md and pubspec.yaml do not match.', + ); + throw ToolExit(1); + } + } + + Pubspec _tryParsePubspec(Directory package) { + final File pubspecFile = package.childFile('pubspec.yaml'); + + try { + Pubspec pubspec = Pubspec.parse(pubspecFile.readAsStringSync()); + if (pubspec == null) { + print( + 'Failed to parse `pubspec.yaml` at ${pubspecFile.path}', + ); + throw ToolExit(1); + } + return pubspec; + } on Exception catch (exception) { + print( + 'Failed to parse `pubspec.yaml` at ${pubspecFile.path}: $exception}', + ); + throw ToolExit(1); + } + } } diff --git a/script/tool/test/util.dart b/script/tool/test/util.dart index ec0000d13f34..2c89ba3e713f 100644 --- a/script/tool/test/util.dart +++ b/script/tool/test/util.dart @@ -58,6 +58,12 @@ Directory createFakePlugin( isMacOsPlugin: isMacOsPlugin, isWindowsPlugin: isWindowsPlugin, ); + createFakeCHANGELOG(pluginDirectory, ''' + +## 0.0.1 + +* Some changes. +'''); if (withSingleExample) { final Directory exampleDir = pluginDirectory.childDirectory('example') @@ -85,6 +91,11 @@ Directory createFakePlugin( return pluginDirectory; } +void createFakeCHANGELOG(Directory parent, String texts) { + parent.childFile('CHANGELOG.md').createSync(); + parent.childFile('CHANGELOG.md').writeAsStringSync(texts); +} + /// Creates a `pubspec.yaml` file with a flutter dependency. void createFakePubspec( Directory parent, { @@ -97,6 +108,7 @@ void createFakePubspec( bool isLinuxPlugin = false, bool isMacOsPlugin = false, bool isWindowsPlugin = false, + String version = '0.0.1', }) { parent.childFile('pubspec.yaml').createSync(); String yaml = ''' @@ -152,7 +164,7 @@ dependencies: } if (includeVersion) { yaml += ''' -version: 0.0.1 +version: $version publish_to: none # Hardcoded safeguard to prevent this from somehow being published by a broken test. '''; } diff --git a/script/tool/test/version_check_test.dart b/script/tool/test/version_check_test.dart index b9ace3811bff..7f2d9e960e48 100644 --- a/script/tool/test/version_check_test.dart +++ b/script/tool/test/version_check_test.dart @@ -196,6 +196,28 @@ void main() { expect(gitDirCommands[2].join(' '), equals('show HEAD:packages/plugin_platform_interface/pubspec.yaml')); }); + + test('Throws if first line in change log is empty', () async{ + createFakePlugin('plugin'); + + final Directory pluginDirectory = + mockPackagesDir.childDirectory('plugin'); + + createFakePubspec(pluginDirectory, isFlutter: true, includeVersion: true, version: '1.0.1'); + String changelog = ''' + +## 1.0.1 + +* Some changes. +'''; + createFakeCHANGELOG(pluginDirectory, changelog); + final Future> output = runCapturingPrint( + runner, ['version-check', '--base_sha=master']); + await expectLater( + output, + throwsA(const TypeMatcher()), + ); + }); }); group("Pre 1.0", () { From 7ae7c82bc29d1c6fb046bccdfcf594f6ea013e2f Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Thu, 4 Mar 2021 12:59:55 -0800 Subject: [PATCH 02/43] tests --- .../tool/lib/src/version_check_command.dart | 11 +--- script/tool/test/util.dart | 13 ++-- script/tool/test/version_check_test.dart | 62 ++++++++++++++++--- 3 files changed, 65 insertions(+), 21 deletions(-) diff --git a/script/tool/lib/src/version_check_command.dart b/script/tool/lib/src/version_check_command.dart index c81aca32beaf..6ec39bd06091 100644 --- a/script/tool/lib/src/version_check_command.dart +++ b/script/tool/lib/src/version_check_command.dart @@ -177,9 +177,6 @@ class VersionCheckCommand extends PluginCommand { continue; } final Pubspec pubspec = Pubspec.parse(pubspecFile.readAsStringSync()); - if (pubspec.publishTo == 'none') { - continue; - } final Version masterVersion = await gitVersionFinder.getPackageVersion(pubspecPath, baseSha); @@ -230,17 +227,15 @@ class VersionCheckCommand extends PluginCommand { print('Checking that $packageName has matching version in CHANGELOG and pubspec'); final Pubspec pubspec = _tryParsePubspec(plugin); - if (pubspec.publishTo == 'none') { - print('Package $packageName is marked as unpublishable. Skipping.'); - return; - } final Version fromPubspec = pubspec.version; // get version from CHANGELOG final File changelog = plugin.childFile('CHANGELOG.md'); final List lines = changelog.readAsLinesSync(); final String firstLine = lines.first; - Version fromChangeLog = Version.parse(firstLine); + // Remove all leading mark down syntax from the version line. + final String versionString = firstLine.split(' ').last; + Version fromChangeLog = Version.parse(versionString); if (fromChangeLog == null) { print( 'Can not find version on the first line of CHANGELOG.md', diff --git a/script/tool/test/util.dart b/script/tool/test/util.dart index 2c89ba3e713f..555951b93ebf 100644 --- a/script/tool/test/util.dart +++ b/script/tool/test/util.dart @@ -37,6 +37,8 @@ Directory createFakePlugin( bool isLinuxPlugin = false, bool isMacOsPlugin = false, bool isWindowsPlugin = false, + bool includeChangeLog = false, + bool includeVersion = false, String parentDirectoryName = '', }) { assert(!(withSingleExample && withExamples.isNotEmpty), @@ -57,13 +59,14 @@ Directory createFakePlugin( isLinuxPlugin: isLinuxPlugin, isMacOsPlugin: isMacOsPlugin, isWindowsPlugin: isWindowsPlugin, + includeVersion: includeVersion, ); - createFakeCHANGELOG(pluginDirectory, ''' - + if (includeChangeLog) { + createFakeCHANGELOG(pluginDirectory, ''' ## 0.0.1 - -* Some changes. -'''); + * Some changes. + '''); + } if (withSingleExample) { final Directory exampleDir = pluginDirectory.childDirectory('example') diff --git a/script/tool/test/version_check_test.dart b/script/tool/test/version_check_test.dart index 7f2d9e960e48..802c030bfc89 100644 --- a/script/tool/test/version_check_test.dart +++ b/script/tool/test/version_check_test.dart @@ -7,6 +7,7 @@ import 'package:mockito/mockito.dart'; import "package:test/test.dart"; import "package:flutter_plugin_tools/src/version_check_command.dart"; import 'package:pub_semver/pub_semver.dart'; +import '../lib/src/common.dart'; import 'util.dart'; void testAllowedVersion( @@ -74,7 +75,7 @@ void main() { }); test('allows valid version', () async { - createFakePlugin('plugin'); + createFakePlugin('plugin', includeChangeLog: true, includeVersion: true); gitDiffResponse = "packages/plugin/pubspec.yaml"; gitShowResponses = { 'master:packages/plugin/pubspec.yaml': 'version: 1.0.0', @@ -85,7 +86,7 @@ void main() { expect( output, - orderedEquals([ + containsAllInOrder([ 'No version check errors found!', ]), ); @@ -99,7 +100,7 @@ void main() { }); test('denies invalid version', () async { - createFakePlugin('plugin'); + createFakePlugin('plugin', includeChangeLog: true, includeVersion: true); gitDiffResponse = "packages/plugin/pubspec.yaml"; gitShowResponses = { 'master:packages/plugin/pubspec.yaml': 'version: 0.0.1', @@ -122,7 +123,7 @@ void main() { }); test('gracefully handles missing pubspec.yaml', () async { - createFakePlugin('plugin'); + createFakePlugin('plugin', includeChangeLog: true, includeVersion: true); gitDiffResponse = "packages/plugin/pubspec.yaml"; mockFileSystem.currentDirectory .childDirectory('packages') @@ -144,7 +145,7 @@ void main() { }); test('allows minor changes to platform interfaces', () async { - createFakePlugin('plugin_platform_interface'); + createFakePlugin('plugin_platform_interface', includeChangeLog: true, includeVersion: true); gitDiffResponse = "packages/plugin_platform_interface/pubspec.yaml"; gitShowResponses = { 'master:packages/plugin_platform_interface/pubspec.yaml': @@ -156,7 +157,7 @@ void main() { runner, ['version-check', '--base_sha=master']); expect( output, - orderedEquals([ + containsAllInOrder([ 'No version check errors found!', ]), ); @@ -172,7 +173,7 @@ void main() { }); test('disallows breaking changes to platform interfaces', () async { - createFakePlugin('plugin_platform_interface'); + createFakePlugin('plugin_platform_interface', includeChangeLog: true, includeVersion: true); gitDiffResponse = "packages/plugin_platform_interface/pubspec.yaml"; gitShowResponses = { 'master:packages/plugin_platform_interface/pubspec.yaml': @@ -198,7 +199,7 @@ void main() { }); test('Throws if first line in change log is empty', () async{ - createFakePlugin('plugin'); + createFakePlugin('plugin', includeChangeLog: true, includeVersion: true); final Directory pluginDirectory = mockPackagesDir.childDirectory('plugin'); @@ -208,6 +209,27 @@ void main() { ## 1.0.1 +* Some changes. +'''; + createFakeCHANGELOG(pluginDirectory, changelog); + final Future> output = runCapturingPrint( + runner, ['version-check', '--base_sha=master']); + await expectLater( + output, + throwsA(const TypeMatcher()), + ); + }); + + test('Throws if versions in changelog and pubspec do not match', () async{ + createFakePlugin('plugin', includeChangeLog: true, includeVersion: true); + + final Directory pluginDirectory = + mockPackagesDir.childDirectory('plugin'); + + createFakePubspec(pluginDirectory, isFlutter: true, includeVersion: true, version: '1.0.1'); + String changelog = ''' +## 1.0.2 + * Some changes. '''; createFakeCHANGELOG(pluginDirectory, changelog); @@ -218,6 +240,30 @@ void main() { throwsA(const TypeMatcher()), ); }); + + test('Success if CHANGELOG and pubspec versions match', () async{ + createFakePlugin('plugin', includeChangeLog: true, includeVersion: true); + + final Directory pluginDirectory = + mockPackagesDir.childDirectory('plugin'); + + createFakePubspec(pluginDirectory, isFlutter: true, includeVersion: true, version: '1.0.1'); + String changelog = ''' +## 1.0.1 + +* Some changes. +'''; + createFakeCHANGELOG(pluginDirectory, changelog); + final List output = await runCapturingPrint( + runner, ['version-check', '--base_sha=master']); + await expect( + output, + containsAllInOrder([ + 'Checking that plugin has matching version in CHANGELOG and pubspec', + 'No version check errors found!' + ]), + ); + }); }); group("Pre 1.0", () { From 1918666c9759315a341b36d432ffc1488ea70d85 Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Thu, 4 Mar 2021 13:02:00 -0800 Subject: [PATCH 03/43] clea n --- script/tool/lib/src/version_check_command.dart | 1 - script/tool/test/version_check_test.dart | 1 - 2 files changed, 2 deletions(-) diff --git a/script/tool/lib/src/version_check_command.dart b/script/tool/lib/src/version_check_command.dart index 6ec39bd06091..350fa81712c7 100644 --- a/script/tool/lib/src/version_check_command.dart +++ b/script/tool/lib/src/version_check_command.dart @@ -13,7 +13,6 @@ import 'package:pub_semver/pub_semver.dart'; import 'package:pubspec_parse/pubspec_parse.dart'; import 'package:yaml/yaml.dart'; -import 'common.dart'; import 'common.dart'; const String _kBaseSha = 'base_sha'; diff --git a/script/tool/test/version_check_test.dart b/script/tool/test/version_check_test.dart index 802c030bfc89..dc2ce3c0f1fc 100644 --- a/script/tool/test/version_check_test.dart +++ b/script/tool/test/version_check_test.dart @@ -7,7 +7,6 @@ import 'package:mockito/mockito.dart'; import "package:test/test.dart"; import "package:flutter_plugin_tools/src/version_check_command.dart"; import 'package:pub_semver/pub_semver.dart'; -import '../lib/src/common.dart'; import 'util.dart'; void testAllowedVersion( From 4618e632cff9d38926013b5de74fae8b76b628c0 Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Thu, 4 Mar 2021 13:04:41 -0800 Subject: [PATCH 04/43] enable version-check --- script/incremental_build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/incremental_build.sh b/script/incremental_build.sh index bc41ebd3c70d..eec1a2be6247 100755 --- a/script/incremental_build.sh +++ b/script/incremental_build.sh @@ -57,6 +57,6 @@ else (cd "$REPO_DIR" && plugin_tools "${ACTIONS[@]}" --plugins="$CHANGED_PACKAGES" --exclude="$ALL_EXCLUDED" ${PLUGIN_SHARDING[@]}) echo "Running version check for changed packages" # TODO(egarciad): Enable this check once in master. - # (cd "$REPO_DIR" && $PUB global run flutter_plugin_tools version-check --base_sha="$(get_branch_base_sha)") + (cd "$REPO_DIR" && plugin_tools version-check --base_sha="$(get_branch_base_sha)") fi fi From d7d03efd68e11eab8677bb51e3f24fa8871aac8f Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Thu, 4 Mar 2021 13:05:29 -0800 Subject: [PATCH 05/43] remove todo --- script/incremental_build.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/script/incremental_build.sh b/script/incremental_build.sh index eec1a2be6247..742a6967faab 100755 --- a/script/incremental_build.sh +++ b/script/incremental_build.sh @@ -56,7 +56,6 @@ else echo running "${ACTIONS[@]}" (cd "$REPO_DIR" && plugin_tools "${ACTIONS[@]}" --plugins="$CHANGED_PACKAGES" --exclude="$ALL_EXCLUDED" ${PLUGIN_SHARDING[@]}) echo "Running version check for changed packages" - # TODO(egarciad): Enable this check once in master. (cd "$REPO_DIR" && plugin_tools version-check --base_sha="$(get_branch_base_sha)") fi fi From 98dd1622bd7d9d63f46e35d90c82a3ab65cf447e Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Thu, 4 Mar 2021 13:06:57 -0800 Subject: [PATCH 06/43] version check for all plugins --- script/incremental_build.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/script/incremental_build.sh b/script/incremental_build.sh index 742a6967faab..be9862f96505 100755 --- a/script/incremental_build.sh +++ b/script/incremental_build.sh @@ -52,6 +52,7 @@ else echo "No changes detected in packages." echo "Running for all packages" (cd "$REPO_DIR" && plugin_tools "${ACTIONS[@]}" --exclude="$ALL_EXCLUDED" ${PLUGIN_SHARDING[@]}) + (cd "$REPO_DIR" && plugin_tools version-check --base_sha="$(get_branch_base_sha)") else echo running "${ACTIONS[@]}" (cd "$REPO_DIR" && plugin_tools "${ACTIONS[@]}" --plugins="$CHANGED_PACKAGES" --exclude="$ALL_EXCLUDED" ${PLUGIN_SHARDING[@]}) From 8bd1bb03e728af47f7b93e62747ae681b2666ab9 Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Thu, 4 Mar 2021 13:44:30 -0800 Subject: [PATCH 07/43] check version --- .cirrus.yml | 8 ++++++-- script/check_version.sh | 15 +++++++++++++++ script/incremental_build.sh | 4 ++-- 3 files changed, 23 insertions(+), 4 deletions(-) create mode 100644 script/check_version.sh diff --git a/.cirrus.yml b/.cirrus.yml index 118802b74810..c08da0990ca2 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -22,10 +22,14 @@ task: - cd script/tool - pub get - CIRRUS_BUILD_ID=null pub run test - - name: publishable + # - name: publishable + # script: + # - flutter channel master + # - ./script/check_publish.sh + - name: version script: - flutter channel master - - ./script/check_publish.sh + - ./script/check_version.sh - name: format install_script: - wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - diff --git a/script/check_version.sh b/script/check_version.sh new file mode 100644 index 000000000000..425488d3cf0c --- /dev/null +++ b/script/check_version.sh @@ -0,0 +1,15 @@ +#!/bin/bash +set -e + +# So that users can run this script from anywhere and it will work as expected. +readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)" +readonly REPO_DIR="$(dirname "$SCRIPT_DIR")" + +source "$SCRIPT_DIR/common.sh" + +# Sets CHANGED_PACKAGE_LIST and CHANGED_PACKAGES +check_changed_packages + +if [[ "${#CHANGED_PACKAGE_LIST[@]}" != 0 ]]; then + plugin_tools version-check --base_sha="$(get_branch_base_sha)" --plugins="${CHANGED_PACKAGES}" +fi diff --git a/script/incremental_build.sh b/script/incremental_build.sh index be9862f96505..bc41ebd3c70d 100755 --- a/script/incremental_build.sh +++ b/script/incremental_build.sh @@ -52,11 +52,11 @@ else echo "No changes detected in packages." echo "Running for all packages" (cd "$REPO_DIR" && plugin_tools "${ACTIONS[@]}" --exclude="$ALL_EXCLUDED" ${PLUGIN_SHARDING[@]}) - (cd "$REPO_DIR" && plugin_tools version-check --base_sha="$(get_branch_base_sha)") else echo running "${ACTIONS[@]}" (cd "$REPO_DIR" && plugin_tools "${ACTIONS[@]}" --plugins="$CHANGED_PACKAGES" --exclude="$ALL_EXCLUDED" ${PLUGIN_SHARDING[@]}) echo "Running version check for changed packages" - (cd "$REPO_DIR" && plugin_tools version-check --base_sha="$(get_branch_base_sha)") + # TODO(egarciad): Enable this check once in master. + # (cd "$REPO_DIR" && $PUB global run flutter_plugin_tools version-check --base_sha="$(get_branch_base_sha)") fi fi From 7cac8759883f037dadf197bd74a6691903116de4 Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Thu, 4 Mar 2021 13:45:19 -0800 Subject: [PATCH 08/43] remove other tests --- .cirrus.yml | 458 ++++++++++++++++++++++++++-------------------------- 1 file changed, 229 insertions(+), 229 deletions(-) diff --git a/.cirrus.yml b/.cirrus.yml index c08da0990ca2..ef9b19cefdfc 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -30,236 +30,236 @@ task: script: - flutter channel master - ./script/check_version.sh - - name: format - install_script: - - wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - - - sudo apt-add-repository "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-7 main" - - sudo apt-get update - - sudo apt-get install -y --allow-unauthenticated clang-format-7 - format_script: ./script/incremental_build.sh format --travis --clang-format=clang-format-7 - - name: test - env: - matrix: - CHANNEL: "master" - CHANNEL: "beta" - CHANNEL: "stable" - test_script: - # TODO(jackson): Allow web plugins once supported on stable - # https://github.com/flutter/flutter/issues/42864 - - if [[ "$CHANNEL" -eq "stable" ]]; then find . | grep _web$ | xargs rm -rf; fi - - flutter channel $CHANNEL - - ./script/incremental_build.sh test - - name: analyze - env: - matrix: - CHANNEL: "master" - CHANNEL: "beta" - CHANNEL: "stable" - script: ./script/incremental_build.sh analyze - - name: build_all_plugins_apk - env: - matrix: - CHANNEL: "master" - CHANNEL: "beta" - CHANNEL: "stable" - script: - # TODO(jackson): Allow web plugins once supported on stable - # https://github.com/flutter/flutter/issues/42864 - - if [[ "$CHANNEL" -eq "stable" ]]; then find . | grep _web$ | xargs rm -rf; fi - - flutter channel $CHANNEL - - ./script/build_all_plugins_app.sh apk - - name: integration_web_smoke_test - # Tests integration example test in web. - only_if: "changesInclude('.cirrus.yml', 'packages/integration_test/**') || $CIRRUS_PR == ''" - install_script: - - flutter config --enable-web - - git clone https://github.com/flutter/web_installers.git - - cd web_installers/packages/web_drivers/ - - pub get - - dart lib/web_driver_installer.dart chromedriver --install-only - - ./chromedriver/chromedriver --port=4444 & - test_script: - - cd $INTEGRATION_TEST_PATH/example/ - - flutter drive -v --driver=test_driver/integration_test.dart --target=integration_test/example_test.dart -d web-server --release --browser-name=chrome - - name: build-apks+java-test+firebase-test-lab - env: - matrix: - PLUGIN_SHARDING: "--shardIndex 0 --shardCount 4" - PLUGIN_SHARDING: "--shardIndex 1 --shardCount 4" - PLUGIN_SHARDING: "--shardIndex 2 --shardCount 4" - PLUGIN_SHARDING: "--shardIndex 3 --shardCount 4" - matrix: - CHANNEL: "master" - CHANNEL: "beta" - CHANNEL: "stable" - MAPS_API_KEY: ENCRYPTED[596a9f6bca436694625ac50851dc5da6b4d34cba8025f7db5bc9465142e8cd44e15f69e3507787753accebfc4910d550] - GCLOUD_FIREBASE_TESTLAB_KEY: ENCRYPTED[07586610af1fdfc894e5969f70ef2458341b9b7e9c3b7c4225a663b4a48732b7208a4d91c3b7d45305a6b55fa2a37fc4] - script: - # TODO(jackson): Allow web plugins once supported on stable - # https://github.com/flutter/flutter/issues/42864 - - if [[ "$CHANNEL" -eq "stable" ]]; then find . | grep _web$ | xargs rm -rf; fi - - flutter channel $CHANNEL - # Unsetting CIRRUS_CHANGE_MESSAGE and CIRRUS_COMMIT_MESSAGE as they - # might include non-ASCII characters which makes Gradle crash. - # See: https://github.com/flutter/flutter/issues/24935 - # This is a temporary workaround until we figure how to properly configure - # a UTF8 locale on Cirrus (or until the Gradle bug is fixed). - # TODO(amirh): Set the locale to UTF8. - - echo "$CIRRUS_CHANGE_MESSAGE" > /tmp/cirrus_change_message.txt - - echo "$CIRRUS_COMMIT_MESSAGE" > /tmp/cirrus_commit_message.txt - - export CIRRUS_CHANGE_MESSAGE="" - - export CIRRUS_COMMIT_MESSAGE="" - - ./script/incremental_build.sh build-examples --apk - - ./script/incremental_build.sh java-test # must come after apk build - - if [[ -n "$GCLOUD_FIREBASE_TESTLAB_KEY" ]]; then - - echo $GCLOUD_FIREBASE_TESTLAB_KEY > ${HOME}/gcloud-service-key.json - - ./script/incremental_build.sh firebase-test-lab --device model=flame,version=29 --device model=starqlteue,version=26 - - else - - echo "This user does not have permission to run Firebase Test Lab tests." - - fi - - export CIRRUS_CHANGE_MESSAGE=`cat /tmp/cirrus_change_message.txt` - - export CIRRUS_COMMIT_MESSAGE=`cat /tmp/cirrus_commit_message.txt` +# - name: format +# install_script: +# - wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - +# - sudo apt-add-repository "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-7 main" +# - sudo apt-get update +# - sudo apt-get install -y --allow-unauthenticated clang-format-7 +# format_script: ./script/incremental_build.sh format --travis --clang-format=clang-format-7 +# - name: test +# env: +# matrix: +# CHANNEL: "master" +# CHANNEL: "beta" +# CHANNEL: "stable" +# test_script: +# # TODO(jackson): Allow web plugins once supported on stable +# # https://github.com/flutter/flutter/issues/42864 +# - if [[ "$CHANNEL" -eq "stable" ]]; then find . | grep _web$ | xargs rm -rf; fi +# - flutter channel $CHANNEL +# - ./script/incremental_build.sh test +# - name: analyze +# env: +# matrix: +# CHANNEL: "master" +# CHANNEL: "beta" +# CHANNEL: "stable" +# script: ./script/incremental_build.sh analyze +# - name: build_all_plugins_apk +# env: +# matrix: +# CHANNEL: "master" +# CHANNEL: "beta" +# CHANNEL: "stable" +# script: +# # TODO(jackson): Allow web plugins once supported on stable +# # https://github.com/flutter/flutter/issues/42864 +# - if [[ "$CHANNEL" -eq "stable" ]]; then find . | grep _web$ | xargs rm -rf; fi +# - flutter channel $CHANNEL +# - ./script/build_all_plugins_app.sh apk +# - name: integration_web_smoke_test +# # Tests integration example test in web. +# only_if: "changesInclude('.cirrus.yml', 'packages/integration_test/**') || $CIRRUS_PR == ''" +# install_script: +# - flutter config --enable-web +# - git clone https://github.com/flutter/web_installers.git +# - cd web_installers/packages/web_drivers/ +# - pub get +# - dart lib/web_driver_installer.dart chromedriver --install-only +# - ./chromedriver/chromedriver --port=4444 & +# test_script: +# - cd $INTEGRATION_TEST_PATH/example/ +# - flutter drive -v --driver=test_driver/integration_test.dart --target=integration_test/example_test.dart -d web-server --release --browser-name=chrome +# - name: build-apks+java-test+firebase-test-lab +# env: +# matrix: +# PLUGIN_SHARDING: "--shardIndex 0 --shardCount 4" +# PLUGIN_SHARDING: "--shardIndex 1 --shardCount 4" +# PLUGIN_SHARDING: "--shardIndex 2 --shardCount 4" +# PLUGIN_SHARDING: "--shardIndex 3 --shardCount 4" +# matrix: +# CHANNEL: "master" +# CHANNEL: "beta" +# CHANNEL: "stable" +# MAPS_API_KEY: ENCRYPTED[596a9f6bca436694625ac50851dc5da6b4d34cba8025f7db5bc9465142e8cd44e15f69e3507787753accebfc4910d550] +# GCLOUD_FIREBASE_TESTLAB_KEY: ENCRYPTED[07586610af1fdfc894e5969f70ef2458341b9b7e9c3b7c4225a663b4a48732b7208a4d91c3b7d45305a6b55fa2a37fc4] +# script: +# # TODO(jackson): Allow web plugins once supported on stable +# # https://github.com/flutter/flutter/issues/42864 +# - if [[ "$CHANNEL" -eq "stable" ]]; then find . | grep _web$ | xargs rm -rf; fi +# - flutter channel $CHANNEL +# # Unsetting CIRRUS_CHANGE_MESSAGE and CIRRUS_COMMIT_MESSAGE as they +# # might include non-ASCII characters which makes Gradle crash. +# # See: https://github.com/flutter/flutter/issues/24935 +# # This is a temporary workaround until we figure how to properly configure +# # a UTF8 locale on Cirrus (or until the Gradle bug is fixed). +# # TODO(amirh): Set the locale to UTF8. +# - echo "$CIRRUS_CHANGE_MESSAGE" > /tmp/cirrus_change_message.txt +# - echo "$CIRRUS_COMMIT_MESSAGE" > /tmp/cirrus_commit_message.txt +# - export CIRRUS_CHANGE_MESSAGE="" +# - export CIRRUS_COMMIT_MESSAGE="" +# - ./script/incremental_build.sh build-examples --apk +# - ./script/incremental_build.sh java-test # must come after apk build +# - if [[ -n "$GCLOUD_FIREBASE_TESTLAB_KEY" ]]; then +# - echo $GCLOUD_FIREBASE_TESTLAB_KEY > ${HOME}/gcloud-service-key.json +# - ./script/incremental_build.sh firebase-test-lab --device model=flame,version=29 --device model=starqlteue,version=26 +# - else +# - echo "This user does not have permission to run Firebase Test Lab tests." +# - fi +# - export CIRRUS_CHANGE_MESSAGE=`cat /tmp/cirrus_change_message.txt` +# - export CIRRUS_COMMIT_MESSAGE=`cat /tmp/cirrus_commit_message.txt` -task: - # don't run on release tags since it creates O(n^2) tasks where n is the number of plugins - only_if: $CIRRUS_TAG == '' - use_compute_credits: $CIRRUS_USER_COLLABORATOR == 'true' && $CIRRUS_PR == '' - container: - dockerfile: .ci/Dockerfile-LinuxDesktop - cpu: 8 - memory: 16G - env: - INTEGRATION_TEST_PATH: "./packages/integration_test" - upgrade_script: - - flutter channel stable - - flutter upgrade - - flutter channel beta - - flutter upgrade - - flutter channel master - - flutter upgrade - - git fetch origin master - matrix: - - name: build-linux+drive-examples - install_script: - - flutter config --enable-linux-desktop - build_script: - # TODO(stuartmorgan): Include stable once Linux is supported on stable. - - flutter channel master - - ./script/incremental_build.sh build-examples --linux - - xvfb-run ./script/incremental_build.sh drive-examples --linux +# task: +# # don't run on release tags since it creates O(n^2) tasks where n is the number of plugins +# only_if: $CIRRUS_TAG == '' +# use_compute_credits: $CIRRUS_USER_COLLABORATOR == 'true' && $CIRRUS_PR == '' +# container: +# dockerfile: .ci/Dockerfile-LinuxDesktop +# cpu: 8 +# memory: 16G +# env: +# INTEGRATION_TEST_PATH: "./packages/integration_test" +# upgrade_script: +# - flutter channel stable +# - flutter upgrade +# - flutter channel beta +# - flutter upgrade +# - flutter channel master +# - flutter upgrade +# - git fetch origin master +# matrix: +# - name: build-linux+drive-examples +# install_script: +# - flutter config --enable-linux-desktop +# build_script: +# # TODO(stuartmorgan): Include stable once Linux is supported on stable. +# - flutter channel master +# - ./script/incremental_build.sh build-examples --linux +# - xvfb-run ./script/incremental_build.sh drive-examples --linux -task: - # Xcode 12 task - # don't run on release tags since it creates O(n^2) tasks where n is the number of plugins - only_if: $CIRRUS_TAG == '' - use_compute_credits: $CIRRUS_USER_COLLABORATOR == 'true' - osx_instance: - image: big-sur-xcode-12.3 - upgrade_script: - - sudo gem install cocoapods - - flutter channel stable - - flutter upgrade - - flutter channel beta - - flutter upgrade - - flutter channel master - - flutter upgrade - - git fetch origin master - create_simulator_script: - - xcrun simctl list - - xcrun simctl create Flutter-iPhone com.apple.CoreSimulator.SimDeviceType.iPhone-11 com.apple.CoreSimulator.SimRuntime.iOS-14-3 | xargs xcrun simctl boot - matrix: - - name: build_all_plugins_ipa - env: - matrix: - CHANNEL: "master" - CHANNEL: "beta" - CHANNEL: "stable" - script: - # TODO(jackson): Allow web plugins once supported on stable - # https://github.com/flutter/flutter/issues/42864 - - if [[ "$CHANNEL" -eq "stable" ]]; then find . | grep _web$ | xargs rm -rf; fi - - flutter channel $CHANNEL - - ./script/build_all_plugins_app.sh ios --no-codesign - - name: build-ipas+drive-examples - env: - PATH: $PATH:/usr/local/bin - PLUGINS_TO_SKIP_XCTESTS: "battery/battery,camera/camera,connectivity/connectivity,device_info/device_info,espresso,google_maps_flutter/google_maps_flutter,google_sign_in/google_sign_in,in_app_purchase,integration_test,ios_platform_images,local_auth,package_info,path_provider/path_provider,sensors,shared_preferences/shared_preferences,url_launcher/url_launcher,video_player/video_player,webview_flutter,wifi_info_flutter/wifi_info_flutter" - matrix: - PLUGIN_SHARDING: "--shardIndex 0 --shardCount 4" - PLUGIN_SHARDING: "--shardIndex 1 --shardCount 4" - PLUGIN_SHARDING: "--shardIndex 2 --shardCount 4" - PLUGIN_SHARDING: "--shardIndex 3 --shardCount 4" - matrix: - CHANNEL: "master" - CHANNEL: "beta" - CHANNEL: "stable" - SIMCTL_CHILD_MAPS_API_KEY: ENCRYPTED[596a9f6bca436694625ac50851dc5da6b4d34cba8025f7db5bc9465142e8cd44e15f69e3507787753accebfc4910d550] - build_script: - # TODO(jackson): Allow web plugins once supported on stable - # https://github.com/flutter/flutter/issues/42864 - - if [[ "$CHANNEL" -eq "stable" ]]; then find . | grep _web$ | xargs rm -rf; fi - - flutter channel $CHANNEL - - flutter upgrade - - ./script/incremental_build.sh build-examples --ipa - - ./script/incremental_build.sh xctest --target RunnerUITests --skip $PLUGINS_TO_SKIP_XCTESTS --ios-destination "platform=iOS Simulator,name=iPhone 11,OS=14.3" - # `drive-examples` contains integration tests, which changes the UI of the application. - # This UI change sometimes affects `xctest`. - # So we run `drive-examples` after `xctest`, changing the order will result ci failure. - - ./script/incremental_build.sh drive-examples --ios +# task: +# # Xcode 12 task +# # don't run on release tags since it creates O(n^2) tasks where n is the number of plugins +# only_if: $CIRRUS_TAG == '' +# use_compute_credits: $CIRRUS_USER_COLLABORATOR == 'true' +# osx_instance: +# image: big-sur-xcode-12.3 +# upgrade_script: +# - sudo gem install cocoapods +# - flutter channel stable +# - flutter upgrade +# - flutter channel beta +# - flutter upgrade +# - flutter channel master +# - flutter upgrade +# - git fetch origin master +# create_simulator_script: +# - xcrun simctl list +# - xcrun simctl create Flutter-iPhone com.apple.CoreSimulator.SimDeviceType.iPhone-11 com.apple.CoreSimulator.SimRuntime.iOS-14-3 | xargs xcrun simctl boot +# matrix: +# - name: build_all_plugins_ipa +# env: +# matrix: +# CHANNEL: "master" +# CHANNEL: "beta" +# CHANNEL: "stable" +# script: +# # TODO(jackson): Allow web plugins once supported on stable +# # https://github.com/flutter/flutter/issues/42864 +# - if [[ "$CHANNEL" -eq "stable" ]]; then find . | grep _web$ | xargs rm -rf; fi +# - flutter channel $CHANNEL +# - ./script/build_all_plugins_app.sh ios --no-codesign +# - name: build-ipas+drive-examples +# env: +# PATH: $PATH:/usr/local/bin +# PLUGINS_TO_SKIP_XCTESTS: "battery/battery,camera/camera,connectivity/connectivity,device_info/device_info,espresso,google_maps_flutter/google_maps_flutter,google_sign_in/google_sign_in,in_app_purchase,integration_test,ios_platform_images,local_auth,package_info,path_provider/path_provider,sensors,shared_preferences/shared_preferences,url_launcher/url_launcher,video_player/video_player,webview_flutter,wifi_info_flutter/wifi_info_flutter" +# matrix: +# PLUGIN_SHARDING: "--shardIndex 0 --shardCount 4" +# PLUGIN_SHARDING: "--shardIndex 1 --shardCount 4" +# PLUGIN_SHARDING: "--shardIndex 2 --shardCount 4" +# PLUGIN_SHARDING: "--shardIndex 3 --shardCount 4" +# matrix: +# CHANNEL: "master" +# CHANNEL: "beta" +# CHANNEL: "stable" +# SIMCTL_CHILD_MAPS_API_KEY: ENCRYPTED[596a9f6bca436694625ac50851dc5da6b4d34cba8025f7db5bc9465142e8cd44e15f69e3507787753accebfc4910d550] +# build_script: +# # TODO(jackson): Allow web plugins once supported on stable +# # https://github.com/flutter/flutter/issues/42864 +# - if [[ "$CHANNEL" -eq "stable" ]]; then find . | grep _web$ | xargs rm -rf; fi +# - flutter channel $CHANNEL +# - flutter upgrade +# - ./script/incremental_build.sh build-examples --ipa +# - ./script/incremental_build.sh xctest --target RunnerUITests --skip $PLUGINS_TO_SKIP_XCTESTS --ios-destination "platform=iOS Simulator,name=iPhone 11,OS=14.3" +# # `drive-examples` contains integration tests, which changes the UI of the application. +# # This UI change sometimes affects `xctest`. +# # So we run `drive-examples` after `xctest`, changing the order will result ci failure. +# - ./script/incremental_build.sh drive-examples --ios -task: - # Xcode 11 task - # TODO(cyanglaz): merge Xcode 11 task to Xcode 12 task when all the matrix can be run in Xcode 12. - # don't run on release tags since it creates O(n^2) tasks where n is the number of plugins - only_if: $CIRRUS_TAG == '' - use_compute_credits: $CIRRUS_USER_COLLABORATOR == 'true' - osx_instance: - image: catalina-xcode-11.3.1-flutter - upgrade_script: - - sudo gem install cocoapods - - flutter channel stable - - flutter upgrade - - flutter channel master - - flutter upgrade - - git fetch origin master - create_simulator_script: - - xcrun simctl list - - xcrun simctl create Flutter-iPhone com.apple.CoreSimulator.SimDeviceType.iPhone-X com.apple.CoreSimulator.SimRuntime.iOS-13-3 | xargs xcrun simctl boot - matrix: - - name: lint_darwin_plugins - env: - matrix: - PLUGIN_SHARDING: "--shardIndex 0 --shardCount 2" - PLUGIN_SHARDING: "--shardIndex 1 --shardCount 2" - script: - # TODO(jmagman): Lint macOS podspecs but skip any that fail library validation. - - find . -name "*.podspec" | xargs grep -l "osx" | xargs rm - # Skip the dummy podspecs used to placate the tool. - - find . -name "*_web*.podspec" -o -name "*_mac*.podspec" | xargs rm - - ./script/incremental_build.sh podspecs +# task: +# # Xcode 11 task +# # TODO(cyanglaz): merge Xcode 11 task to Xcode 12 task when all the matrix can be run in Xcode 12. +# # don't run on release tags since it creates O(n^2) tasks where n is the number of plugins +# only_if: $CIRRUS_TAG == '' +# use_compute_credits: $CIRRUS_USER_COLLABORATOR == 'true' +# osx_instance: +# image: catalina-xcode-11.3.1-flutter +# upgrade_script: +# - sudo gem install cocoapods +# - flutter channel stable +# - flutter upgrade +# - flutter channel master +# - flutter upgrade +# - git fetch origin master +# create_simulator_script: +# - xcrun simctl list +# - xcrun simctl create Flutter-iPhone com.apple.CoreSimulator.SimDeviceType.iPhone-X com.apple.CoreSimulator.SimRuntime.iOS-13-3 | xargs xcrun simctl boot +# matrix: +# - name: lint_darwin_plugins +# env: +# matrix: +# PLUGIN_SHARDING: "--shardIndex 0 --shardCount 2" +# PLUGIN_SHARDING: "--shardIndex 1 --shardCount 2" +# script: +# # TODO(jmagman): Lint macOS podspecs but skip any that fail library validation. +# - find . -name "*.podspec" | xargs grep -l "osx" | xargs rm +# # Skip the dummy podspecs used to placate the tool. +# - find . -name "*_web*.podspec" -o -name "*_mac*.podspec" | xargs rm +# - ./script/incremental_build.sh podspecs -task: - # don't run on release tags since it creates O(n^2) tasks where n is the number of plugins - only_if: $CIRRUS_TAG == '' - use_compute_credits: $CIRRUS_USER_COLLABORATOR == 'true' - osx_instance: - image: big-sur-xcode-12.3 - setup_script: - - flutter config --enable-macos-desktop - upgrade_script: - - sudo gem install cocoapods - - flutter channel master - - flutter upgrade - - git fetch origin master - matrix: - - name: build_all_plugins_app - script: - - flutter channel master - - ./script/build_all_plugins_app.sh macos - - name: build-apps+drive-examples - env: - PATH: $PATH:/usr/local/bin - build_script: - - flutter channel master - - ./script/incremental_build.sh build-examples --macos --no-ipa - - ./script/incremental_build.sh drive-examples --macos +# task: +# # don't run on release tags since it creates O(n^2) tasks where n is the number of plugins +# only_if: $CIRRUS_TAG == '' +# use_compute_credits: $CIRRUS_USER_COLLABORATOR == 'true' +# osx_instance: +# image: big-sur-xcode-12.3 +# setup_script: +# - flutter config --enable-macos-desktop +# upgrade_script: +# - sudo gem install cocoapods +# - flutter channel master +# - flutter upgrade +# - git fetch origin master +# matrix: +# - name: build_all_plugins_app +# script: +# - flutter channel master +# - ./script/build_all_plugins_app.sh macos +# - name: build-apps+drive-examples +# env: +# PATH: $PATH:/usr/local/bin +# build_script: +# - flutter channel master +# - ./script/incremental_build.sh build-examples --macos --no-ipa +# - ./script/incremental_build.sh drive-examples --macos From 0fecf79fe0844da96f8520340cdf95bbfe543a4e Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Thu, 4 Mar 2021 13:47:36 -0800 Subject: [PATCH 09/43] addtional log --- script/tool/lib/src/version_check_command.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/script/tool/lib/src/version_check_command.dart b/script/tool/lib/src/version_check_command.dart index 350fa81712c7..554a60183b06 100644 --- a/script/tool/lib/src/version_check_command.dart +++ b/script/tool/lib/src/version_check_command.dart @@ -248,6 +248,7 @@ class VersionCheckCommand extends PluginCommand { ); throw ToolExit(1); } + print('${plugin.basename} passed version check'); } Pubspec _tryParsePubspec(Directory package) { From e3a1bc5f777d66f85c12097735a642548a24524e Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Thu, 4 Mar 2021 13:49:24 -0800 Subject: [PATCH 10/43] chmod --- script/check_version.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 script/check_version.sh diff --git a/script/check_version.sh b/script/check_version.sh old mode 100644 new mode 100755 From d2a505cc68f36387c0943c23f5c37604302aa6c1 Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Thu, 4 Mar 2021 13:52:15 -0800 Subject: [PATCH 11/43] try run all --- script/check_version.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/script/check_version.sh b/script/check_version.sh index 425488d3cf0c..0221df8b024b 100755 --- a/script/check_version.sh +++ b/script/check_version.sh @@ -10,6 +10,6 @@ source "$SCRIPT_DIR/common.sh" # Sets CHANGED_PACKAGE_LIST and CHANGED_PACKAGES check_changed_packages -if [[ "${#CHANGED_PACKAGE_LIST[@]}" != 0 ]]; then - plugin_tools version-check --base_sha="$(get_branch_base_sha)" --plugins="${CHANGED_PACKAGES}" -fi +plugin_tools version-check --base_sha="$(get_branch_base_sha)" +# if [[ "${#CHANGED_PACKAGE_LIST[@]}" != 0 ]]; then +# fi From f8f1ed08fd78910c55d2ff1bed31c4ce681d48ae Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Thu, 4 Mar 2021 14:02:00 -0800 Subject: [PATCH 12/43] update log --- .../tool/lib/src/version_check_command.dart | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/script/tool/lib/src/version_check_command.dart b/script/tool/lib/src/version_check_command.dart index 554a60183b06..bf84670ec46c 100644 --- a/script/tool/lib/src/version_check_command.dart +++ b/script/tool/lib/src/version_check_command.dart @@ -223,6 +223,7 @@ class VersionCheckCommand extends PluginCommand { Future _checkVersionsMatch(Directory plugin) async { // get version from pubspec final String packageName = plugin.basename; + print('================================================================'); print('Checking that $packageName has matching version in CHANGELOG and pubspec'); final Pubspec pubspec = _tryParsePubspec(plugin); @@ -236,16 +237,16 @@ class VersionCheckCommand extends PluginCommand { final String versionString = firstLine.split(' ').last; Version fromChangeLog = Version.parse(versionString); if (fromChangeLog == null) { - print( - 'Can not find version on the first line of CHANGELOG.md', - ); + final String error = 'Can not find version on the first line of CHANGELOG.md'; + final Colorize redError = Colorize(error)..red(); + print(redError); throw ToolExit(1); } if (fromPubspec != fromChangeLog) { - print( - 'versions for $packageName in CHANGELOG.md and pubspec.yaml do not match.', - ); + final String error = 'versions for $packageName in CHANGELOG.md and pubspec.yaml do not match.'; + final Colorize redError = Colorize(error)..red(); + print(redError); throw ToolExit(1); } print('${plugin.basename} passed version check'); @@ -257,16 +258,16 @@ class VersionCheckCommand extends PluginCommand { try { Pubspec pubspec = Pubspec.parse(pubspecFile.readAsStringSync()); if (pubspec == null) { - print( - 'Failed to parse `pubspec.yaml` at ${pubspecFile.path}', - ); + final String error = 'Failed to parse `pubspec.yaml` at ${pubspecFile.path}'; + final Colorize redError = Colorize(error)..red(); + print(redError); throw ToolExit(1); } return pubspec; } on Exception catch (exception) { - print( - 'Failed to parse `pubspec.yaml` at ${pubspecFile.path}: $exception}', - ); + final String error = 'Failed to parse `pubspec.yaml` at ${pubspecFile.path}: $exception}'; + final Colorize redError = Colorize(error)..red(); + print(redError); throw ToolExit(1); } } From e1f64e927bf41e0709fe676ad15adeed80ab0ea9 Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Thu, 4 Mar 2021 14:03:01 -0800 Subject: [PATCH 13/43] remove todo --- script/incremental_build.sh | 3 --- 1 file changed, 3 deletions(-) diff --git a/script/incremental_build.sh b/script/incremental_build.sh index bc41ebd3c70d..0d4d927db681 100755 --- a/script/incremental_build.sh +++ b/script/incremental_build.sh @@ -55,8 +55,5 @@ else else echo running "${ACTIONS[@]}" (cd "$REPO_DIR" && plugin_tools "${ACTIONS[@]}" --plugins="$CHANGED_PACKAGES" --exclude="$ALL_EXCLUDED" ${PLUGIN_SHARDING[@]}) - echo "Running version check for changed packages" - # TODO(egarciad): Enable this check once in master. - # (cd "$REPO_DIR" && $PUB global run flutter_plugin_tools version-check --base_sha="$(get_branch_base_sha)") fi fi From 351d46702d0298c94a667cdc6077ec367e9f347d Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Thu, 4 Mar 2021 14:03:44 -0800 Subject: [PATCH 14/43] revert .cirrus change --- .cirrus.yml | 466 ++++++++++++++++++++++++++-------------------------- 1 file changed, 233 insertions(+), 233 deletions(-) diff --git a/.cirrus.yml b/.cirrus.yml index ef9b19cefdfc..60c211f4e381 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -22,244 +22,244 @@ task: - cd script/tool - pub get - CIRRUS_BUILD_ID=null pub run test - # - name: publishable - # script: - # - flutter channel master - # - ./script/check_publish.sh + - name: publishable + script: + - flutter channel master + - ./script/check_publish.sh - name: version script: - flutter channel master - ./script/check_version.sh -# - name: format -# install_script: -# - wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - -# - sudo apt-add-repository "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-7 main" -# - sudo apt-get update -# - sudo apt-get install -y --allow-unauthenticated clang-format-7 -# format_script: ./script/incremental_build.sh format --travis --clang-format=clang-format-7 -# - name: test -# env: -# matrix: -# CHANNEL: "master" -# CHANNEL: "beta" -# CHANNEL: "stable" -# test_script: -# # TODO(jackson): Allow web plugins once supported on stable -# # https://github.com/flutter/flutter/issues/42864 -# - if [[ "$CHANNEL" -eq "stable" ]]; then find . | grep _web$ | xargs rm -rf; fi -# - flutter channel $CHANNEL -# - ./script/incremental_build.sh test -# - name: analyze -# env: -# matrix: -# CHANNEL: "master" -# CHANNEL: "beta" -# CHANNEL: "stable" -# script: ./script/incremental_build.sh analyze -# - name: build_all_plugins_apk -# env: -# matrix: -# CHANNEL: "master" -# CHANNEL: "beta" -# CHANNEL: "stable" -# script: -# # TODO(jackson): Allow web plugins once supported on stable -# # https://github.com/flutter/flutter/issues/42864 -# - if [[ "$CHANNEL" -eq "stable" ]]; then find . | grep _web$ | xargs rm -rf; fi -# - flutter channel $CHANNEL -# - ./script/build_all_plugins_app.sh apk -# - name: integration_web_smoke_test -# # Tests integration example test in web. -# only_if: "changesInclude('.cirrus.yml', 'packages/integration_test/**') || $CIRRUS_PR == ''" -# install_script: -# - flutter config --enable-web -# - git clone https://github.com/flutter/web_installers.git -# - cd web_installers/packages/web_drivers/ -# - pub get -# - dart lib/web_driver_installer.dart chromedriver --install-only -# - ./chromedriver/chromedriver --port=4444 & -# test_script: -# - cd $INTEGRATION_TEST_PATH/example/ -# - flutter drive -v --driver=test_driver/integration_test.dart --target=integration_test/example_test.dart -d web-server --release --browser-name=chrome -# - name: build-apks+java-test+firebase-test-lab -# env: -# matrix: -# PLUGIN_SHARDING: "--shardIndex 0 --shardCount 4" -# PLUGIN_SHARDING: "--shardIndex 1 --shardCount 4" -# PLUGIN_SHARDING: "--shardIndex 2 --shardCount 4" -# PLUGIN_SHARDING: "--shardIndex 3 --shardCount 4" -# matrix: -# CHANNEL: "master" -# CHANNEL: "beta" -# CHANNEL: "stable" -# MAPS_API_KEY: ENCRYPTED[596a9f6bca436694625ac50851dc5da6b4d34cba8025f7db5bc9465142e8cd44e15f69e3507787753accebfc4910d550] -# GCLOUD_FIREBASE_TESTLAB_KEY: ENCRYPTED[07586610af1fdfc894e5969f70ef2458341b9b7e9c3b7c4225a663b4a48732b7208a4d91c3b7d45305a6b55fa2a37fc4] -# script: -# # TODO(jackson): Allow web plugins once supported on stable -# # https://github.com/flutter/flutter/issues/42864 -# - if [[ "$CHANNEL" -eq "stable" ]]; then find . | grep _web$ | xargs rm -rf; fi -# - flutter channel $CHANNEL -# # Unsetting CIRRUS_CHANGE_MESSAGE and CIRRUS_COMMIT_MESSAGE as they -# # might include non-ASCII characters which makes Gradle crash. -# # See: https://github.com/flutter/flutter/issues/24935 -# # This is a temporary workaround until we figure how to properly configure -# # a UTF8 locale on Cirrus (or until the Gradle bug is fixed). -# # TODO(amirh): Set the locale to UTF8. -# - echo "$CIRRUS_CHANGE_MESSAGE" > /tmp/cirrus_change_message.txt -# - echo "$CIRRUS_COMMIT_MESSAGE" > /tmp/cirrus_commit_message.txt -# - export CIRRUS_CHANGE_MESSAGE="" -# - export CIRRUS_COMMIT_MESSAGE="" -# - ./script/incremental_build.sh build-examples --apk -# - ./script/incremental_build.sh java-test # must come after apk build -# - if [[ -n "$GCLOUD_FIREBASE_TESTLAB_KEY" ]]; then -# - echo $GCLOUD_FIREBASE_TESTLAB_KEY > ${HOME}/gcloud-service-key.json -# - ./script/incremental_build.sh firebase-test-lab --device model=flame,version=29 --device model=starqlteue,version=26 -# - else -# - echo "This user does not have permission to run Firebase Test Lab tests." -# - fi -# - export CIRRUS_CHANGE_MESSAGE=`cat /tmp/cirrus_change_message.txt` -# - export CIRRUS_COMMIT_MESSAGE=`cat /tmp/cirrus_commit_message.txt` + - name: format + install_script: + - wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - + - sudo apt-add-repository "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-7 main" + - sudo apt-get update + - sudo apt-get install -y --allow-unauthenticated clang-format-7 + format_script: ./script/incremental_build.sh format --travis --clang-format=clang-format-7 + - name: test + env: + matrix: + CHANNEL: "master" + CHANNEL: "beta" + CHANNEL: "stable" + test_script: + # TODO(jackson): Allow web plugins once supported on stable + # https://github.com/flutter/flutter/issues/42864 + - if [[ "$CHANNEL" -eq "stable" ]]; then find . | grep _web$ | xargs rm -rf; fi + - flutter channel $CHANNEL + - ./script/incremental_build.sh test + - name: analyze + env: + matrix: + CHANNEL: "master" + CHANNEL: "beta" + CHANNEL: "stable" + script: ./script/incremental_build.sh analyze + - name: build_all_plugins_apk + env: + matrix: + CHANNEL: "master" + CHANNEL: "beta" + CHANNEL: "stable" + script: + # TODO(jackson): Allow web plugins once supported on stable + # https://github.com/flutter/flutter/issues/42864 + - if [[ "$CHANNEL" -eq "stable" ]]; then find . | grep _web$ | xargs rm -rf; fi + - flutter channel $CHANNEL + - ./script/build_all_plugins_app.sh apk + - name: integration_web_smoke_test + # Tests integration example test in web. + only_if: "changesInclude('.cirrus.yml', 'packages/integration_test/**') || $CIRRUS_PR == ''" + install_script: + - flutter config --enable-web + - git clone https://github.com/flutter/web_installers.git + - cd web_installers/packages/web_drivers/ + - pub get + - dart lib/web_driver_installer.dart chromedriver --install-only + - ./chromedriver/chromedriver --port=4444 & + test_script: + - cd $INTEGRATION_TEST_PATH/example/ + - flutter drive -v --driver=test_driver/integration_test.dart --target=integration_test/example_test.dart -d web-server --release --browser-name=chrome + - name: build-apks+java-test+firebase-test-lab + env: + matrix: + PLUGIN_SHARDING: "--shardIndex 0 --shardCount 4" + PLUGIN_SHARDING: "--shardIndex 1 --shardCount 4" + PLUGIN_SHARDING: "--shardIndex 2 --shardCount 4" + PLUGIN_SHARDING: "--shardIndex 3 --shardCount 4" + matrix: + CHANNEL: "master" + CHANNEL: "beta" + CHANNEL: "stable" + MAPS_API_KEY: ENCRYPTED[596a9f6bca436694625ac50851dc5da6b4d34cba8025f7db5bc9465142e8cd44e15f69e3507787753accebfc4910d550] + GCLOUD_FIREBASE_TESTLAB_KEY: ENCRYPTED[07586610af1fdfc894e5969f70ef2458341b9b7e9c3b7c4225a663b4a48732b7208a4d91c3b7d45305a6b55fa2a37fc4] + script: + # TODO(jackson): Allow web plugins once supported on stable + # https://github.com/flutter/flutter/issues/42864 + - if [[ "$CHANNEL" -eq "stable" ]]; then find . | grep _web$ | xargs rm -rf; fi + - flutter channel $CHANNEL + # Unsetting CIRRUS_CHANGE_MESSAGE and CIRRUS_COMMIT_MESSAGE as they + # might include non-ASCII characters which makes Gradle crash. + # See: https://github.com/flutter/flutter/issues/24935 + # This is a temporary workaround until we figure how to properly configure + # a UTF8 locale on Cirrus (or until the Gradle bug is fixed). + # TODO(amirh): Set the locale to UTF8. + - echo "$CIRRUS_CHANGE_MESSAGE" > /tmp/cirrus_change_message.txt + - echo "$CIRRUS_COMMIT_MESSAGE" > /tmp/cirrus_commit_message.txt + - export CIRRUS_CHANGE_MESSAGE="" + - export CIRRUS_COMMIT_MESSAGE="" + - ./script/incremental_build.sh build-examples --apk + - ./script/incremental_build.sh java-test # must come after apk build + - if [[ -n "$GCLOUD_FIREBASE_TESTLAB_KEY" ]]; then + - echo $GCLOUD_FIREBASE_TESTLAB_KEY > ${HOME}/gcloud-service-key.json + - ./script/incremental_build.sh firebase-test-lab --device model=flame,version=29 --device model=starqlteue,version=26 + - else + - echo "This user does not have permission to run Firebase Test Lab tests." + - fi + - export CIRRUS_CHANGE_MESSAGE=`cat /tmp/cirrus_change_message.txt` + - export CIRRUS_COMMIT_MESSAGE=`cat /tmp/cirrus_commit_message.txt` -# task: -# # don't run on release tags since it creates O(n^2) tasks where n is the number of plugins -# only_if: $CIRRUS_TAG == '' -# use_compute_credits: $CIRRUS_USER_COLLABORATOR == 'true' && $CIRRUS_PR == '' -# container: -# dockerfile: .ci/Dockerfile-LinuxDesktop -# cpu: 8 -# memory: 16G -# env: -# INTEGRATION_TEST_PATH: "./packages/integration_test" -# upgrade_script: -# - flutter channel stable -# - flutter upgrade -# - flutter channel beta -# - flutter upgrade -# - flutter channel master -# - flutter upgrade -# - git fetch origin master -# matrix: -# - name: build-linux+drive-examples -# install_script: -# - flutter config --enable-linux-desktop -# build_script: -# # TODO(stuartmorgan): Include stable once Linux is supported on stable. -# - flutter channel master -# - ./script/incremental_build.sh build-examples --linux -# - xvfb-run ./script/incremental_build.sh drive-examples --linux +task: + # don't run on release tags since it creates O(n^2) tasks where n is the number of plugins + only_if: $CIRRUS_TAG == '' + use_compute_credits: $CIRRUS_USER_COLLABORATOR == 'true' && $CIRRUS_PR == '' + container: + dockerfile: .ci/Dockerfile-LinuxDesktop + cpu: 8 + memory: 16G + env: + INTEGRATION_TEST_PATH: "./packages/integration_test" + upgrade_script: + - flutter channel stable + - flutter upgrade + - flutter channel beta + - flutter upgrade + - flutter channel master + - flutter upgrade + - git fetch origin master + matrix: + - name: build-linux+drive-examples + install_script: + - flutter config --enable-linux-desktop + build_script: + # TODO(stuartmorgan): Include stable once Linux is supported on stable. + - flutter channel master + - ./script/incremental_build.sh build-examples --linux + - xvfb-run ./script/incremental_build.sh drive-examples --linux -# task: -# # Xcode 12 task -# # don't run on release tags since it creates O(n^2) tasks where n is the number of plugins -# only_if: $CIRRUS_TAG == '' -# use_compute_credits: $CIRRUS_USER_COLLABORATOR == 'true' -# osx_instance: -# image: big-sur-xcode-12.3 -# upgrade_script: -# - sudo gem install cocoapods -# - flutter channel stable -# - flutter upgrade -# - flutter channel beta -# - flutter upgrade -# - flutter channel master -# - flutter upgrade -# - git fetch origin master -# create_simulator_script: -# - xcrun simctl list -# - xcrun simctl create Flutter-iPhone com.apple.CoreSimulator.SimDeviceType.iPhone-11 com.apple.CoreSimulator.SimRuntime.iOS-14-3 | xargs xcrun simctl boot -# matrix: -# - name: build_all_plugins_ipa -# env: -# matrix: -# CHANNEL: "master" -# CHANNEL: "beta" -# CHANNEL: "stable" -# script: -# # TODO(jackson): Allow web plugins once supported on stable -# # https://github.com/flutter/flutter/issues/42864 -# - if [[ "$CHANNEL" -eq "stable" ]]; then find . | grep _web$ | xargs rm -rf; fi -# - flutter channel $CHANNEL -# - ./script/build_all_plugins_app.sh ios --no-codesign -# - name: build-ipas+drive-examples -# env: -# PATH: $PATH:/usr/local/bin -# PLUGINS_TO_SKIP_XCTESTS: "battery/battery,camera/camera,connectivity/connectivity,device_info/device_info,espresso,google_maps_flutter/google_maps_flutter,google_sign_in/google_sign_in,in_app_purchase,integration_test,ios_platform_images,local_auth,package_info,path_provider/path_provider,sensors,shared_preferences/shared_preferences,url_launcher/url_launcher,video_player/video_player,webview_flutter,wifi_info_flutter/wifi_info_flutter" -# matrix: -# PLUGIN_SHARDING: "--shardIndex 0 --shardCount 4" -# PLUGIN_SHARDING: "--shardIndex 1 --shardCount 4" -# PLUGIN_SHARDING: "--shardIndex 2 --shardCount 4" -# PLUGIN_SHARDING: "--shardIndex 3 --shardCount 4" -# matrix: -# CHANNEL: "master" -# CHANNEL: "beta" -# CHANNEL: "stable" -# SIMCTL_CHILD_MAPS_API_KEY: ENCRYPTED[596a9f6bca436694625ac50851dc5da6b4d34cba8025f7db5bc9465142e8cd44e15f69e3507787753accebfc4910d550] -# build_script: -# # TODO(jackson): Allow web plugins once supported on stable -# # https://github.com/flutter/flutter/issues/42864 -# - if [[ "$CHANNEL" -eq "stable" ]]; then find . | grep _web$ | xargs rm -rf; fi -# - flutter channel $CHANNEL -# - flutter upgrade -# - ./script/incremental_build.sh build-examples --ipa -# - ./script/incremental_build.sh xctest --target RunnerUITests --skip $PLUGINS_TO_SKIP_XCTESTS --ios-destination "platform=iOS Simulator,name=iPhone 11,OS=14.3" -# # `drive-examples` contains integration tests, which changes the UI of the application. -# # This UI change sometimes affects `xctest`. -# # So we run `drive-examples` after `xctest`, changing the order will result ci failure. -# - ./script/incremental_build.sh drive-examples --ios +task: + # Xcode 12 task + # don't run on release tags since it creates O(n^2) tasks where n is the number of plugins + only_if: $CIRRUS_TAG == '' + use_compute_credits: $CIRRUS_USER_COLLABORATOR == 'true' + osx_instance: + image: big-sur-xcode-12.3 + upgrade_script: + - sudo gem install cocoapods + - flutter channel stable + - flutter upgrade + - flutter channel beta + - flutter upgrade + - flutter channel master + - flutter upgrade + - git fetch origin master + create_simulator_script: + - xcrun simctl list + - xcrun simctl create Flutter-iPhone com.apple.CoreSimulator.SimDeviceType.iPhone-11 com.apple.CoreSimulator.SimRuntime.iOS-14-3 | xargs xcrun simctl boot + matrix: + - name: build_all_plugins_ipa + env: + matrix: + CHANNEL: "master" + CHANNEL: "beta" + CHANNEL: "stable" + script: + # TODO(jackson): Allow web plugins once supported on stable + # https://github.com/flutter/flutter/issues/42864 + - if [[ "$CHANNEL" -eq "stable" ]]; then find . | grep _web$ | xargs rm -rf; fi + - flutter channel $CHANNEL + - ./script/build_all_plugins_app.sh ios --no-codesign + - name: build-ipas+drive-examples + env: + PATH: $PATH:/usr/local/bin + PLUGINS_TO_SKIP_XCTESTS: "battery/battery,camera/camera,connectivity/connectivity,device_info/device_info,espresso,google_maps_flutter/google_maps_flutter,google_sign_in/google_sign_in,in_app_purchase,integration_test,ios_platform_images,local_auth,package_info,path_provider/path_provider,sensors,shared_preferences/shared_preferences,url_launcher/url_launcher,video_player/video_player,webview_flutter,wifi_info_flutter/wifi_info_flutter" + matrix: + PLUGIN_SHARDING: "--shardIndex 0 --shardCount 4" + PLUGIN_SHARDING: "--shardIndex 1 --shardCount 4" + PLUGIN_SHARDING: "--shardIndex 2 --shardCount 4" + PLUGIN_SHARDING: "--shardIndex 3 --shardCount 4" + matrix: + CHANNEL: "master" + CHANNEL: "beta" + CHANNEL: "stable" + SIMCTL_CHILD_MAPS_API_KEY: ENCRYPTED[596a9f6bca436694625ac50851dc5da6b4d34cba8025f7db5bc9465142e8cd44e15f69e3507787753accebfc4910d550] + build_script: + # TODO(jackson): Allow web plugins once supported on stable + # https://github.com/flutter/flutter/issues/42864 + - if [[ "$CHANNEL" -eq "stable" ]]; then find . | grep _web$ | xargs rm -rf; fi + - flutter channel $CHANNEL + - flutter upgrade + - ./script/incremental_build.sh build-examples --ipa + - ./script/incremental_build.sh xctest --target RunnerUITests --skip $PLUGINS_TO_SKIP_XCTESTS --ios-destination "platform=iOS Simulator,name=iPhone 11,OS=14.3" + # `drive-examples` contains integration tests, which changes the UI of the application. + # This UI change sometimes affects `xctest`. + # So we run `drive-examples` after `xctest`, changing the order will result ci failure. + - ./script/incremental_build.sh drive-examples --ios -# task: -# # Xcode 11 task -# # TODO(cyanglaz): merge Xcode 11 task to Xcode 12 task when all the matrix can be run in Xcode 12. -# # don't run on release tags since it creates O(n^2) tasks where n is the number of plugins -# only_if: $CIRRUS_TAG == '' -# use_compute_credits: $CIRRUS_USER_COLLABORATOR == 'true' -# osx_instance: -# image: catalina-xcode-11.3.1-flutter -# upgrade_script: -# - sudo gem install cocoapods -# - flutter channel stable -# - flutter upgrade -# - flutter channel master -# - flutter upgrade -# - git fetch origin master -# create_simulator_script: -# - xcrun simctl list -# - xcrun simctl create Flutter-iPhone com.apple.CoreSimulator.SimDeviceType.iPhone-X com.apple.CoreSimulator.SimRuntime.iOS-13-3 | xargs xcrun simctl boot -# matrix: -# - name: lint_darwin_plugins -# env: -# matrix: -# PLUGIN_SHARDING: "--shardIndex 0 --shardCount 2" -# PLUGIN_SHARDING: "--shardIndex 1 --shardCount 2" -# script: -# # TODO(jmagman): Lint macOS podspecs but skip any that fail library validation. -# - find . -name "*.podspec" | xargs grep -l "osx" | xargs rm -# # Skip the dummy podspecs used to placate the tool. -# - find . -name "*_web*.podspec" -o -name "*_mac*.podspec" | xargs rm -# - ./script/incremental_build.sh podspecs +task: + # Xcode 11 task + # TODO(cyanglaz): merge Xcode 11 task to Xcode 12 task when all the matrix can be run in Xcode 12. + # don't run on release tags since it creates O(n^2) tasks where n is the number of plugins + only_if: $CIRRUS_TAG == '' + use_compute_credits: $CIRRUS_USER_COLLABORATOR == 'true' + osx_instance: + image: catalina-xcode-11.3.1-flutter + upgrade_script: + - sudo gem install cocoapods + - flutter channel stable + - flutter upgrade + - flutter channel master + - flutter upgrade + - git fetch origin master + create_simulator_script: + - xcrun simctl list + - xcrun simctl create Flutter-iPhone com.apple.CoreSimulator.SimDeviceType.iPhone-X com.apple.CoreSimulator.SimRuntime.iOS-13-3 | xargs xcrun simctl boot + matrix: + - name: lint_darwin_plugins + env: + matrix: + PLUGIN_SHARDING: "--shardIndex 0 --shardCount 2" + PLUGIN_SHARDING: "--shardIndex 1 --shardCount 2" + script: + # TODO(jmagman): Lint macOS podspecs but skip any that fail library validation. + - find . -name "*.podspec" | xargs grep -l "osx" | xargs rm + # Skip the dummy podspecs used to placate the tool. + - find . -name "*_web*.podspec" -o -name "*_mac*.podspec" | xargs rm + - ./script/incremental_build.sh podspecs -# task: -# # don't run on release tags since it creates O(n^2) tasks where n is the number of plugins -# only_if: $CIRRUS_TAG == '' -# use_compute_credits: $CIRRUS_USER_COLLABORATOR == 'true' -# osx_instance: -# image: big-sur-xcode-12.3 -# setup_script: -# - flutter config --enable-macos-desktop -# upgrade_script: -# - sudo gem install cocoapods -# - flutter channel master -# - flutter upgrade -# - git fetch origin master -# matrix: -# - name: build_all_plugins_app -# script: -# - flutter channel master -# - ./script/build_all_plugins_app.sh macos -# - name: build-apps+drive-examples -# env: -# PATH: $PATH:/usr/local/bin -# build_script: -# - flutter channel master -# - ./script/incremental_build.sh build-examples --macos --no-ipa -# - ./script/incremental_build.sh drive-examples --macos +task: + # don't run on release tags since it creates O(n^2) tasks where n is the number of plugins + only_if: $CIRRUS_TAG == '' + use_compute_credits: $CIRRUS_USER_COLLABORATOR == 'true' + osx_instance: + image: big-sur-xcode-12.3 + setup_script: + - flutter config --enable-macos-desktop + upgrade_script: + - sudo gem install cocoapods + - flutter channel master + - flutter upgrade + - git fetch origin master + matrix: + - name: build_all_plugins_app + script: + - flutter channel master + - ./script/build_all_plugins_app.sh macos + - name: build-apps+drive-examples + env: + PATH: $PATH:/usr/local/bin + build_script: + - flutter channel master + - ./script/incremental_build.sh build-examples --macos --no-ipa + - ./script/incremental_build.sh drive-examples --macos From 071ccfcccda0393ec46e3808032e6cdb05a501fd Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Fri, 5 Mar 2021 09:16:26 -0800 Subject: [PATCH 15/43] refactor throw tool exit --- script/tool/lib/src/common.dart | 9 +++++++ .../tool/lib/src/version_check_command.dart | 26 +++++-------------- 2 files changed, 16 insertions(+), 19 deletions(-) diff --git a/script/tool/lib/src/common.dart b/script/tool/lib/src/common.dart index 08622df281b4..698350037aa5 100644 --- a/script/tool/lib/src/common.dart +++ b/script/tool/lib/src/common.dart @@ -7,7 +7,9 @@ import 'dart:io' as io; import 'dart:math'; import 'package:args/command_runner.dart'; +import 'package:colorize/colorize.dart'; import 'package:file/file.dart'; +import 'package:meta/meta.dart'; import 'package:path/path.dart' as p; import 'package:yaml/yaml.dart'; @@ -140,6 +142,13 @@ bool isLinuxPlugin(FileSystemEntity entity, FileSystem fileSystem) { return pluginSupportsPlatform(kLinux, entity, fileSystem); } +/// Throws a [ToolExit] with `exitCode` and log the `errorMessage` in red. +void ThrowsToolExit({@required String errorMessage, int exitCode = 1}) { + final Colorize redError = Colorize(errorMessage)..red(); + print(redError); + throw ToolExit(exitCode); +} + /// Error thrown when a command needs to exit with a non-zero exit code. class ToolExit extends Error { ToolExit(this.exitCode); diff --git a/script/tool/lib/src/version_check_command.dart b/script/tool/lib/src/version_check_command.dart index bf84670ec46c..230bc86a9314 100644 --- a/script/tool/lib/src/version_check_command.dart +++ b/script/tool/lib/src/version_check_command.dart @@ -6,7 +6,6 @@ import 'dart:async'; import 'dart:io' as io; import 'package:meta/meta.dart'; -import 'package:colorize/colorize.dart'; import 'package:file/file.dart'; import 'package:git/git.dart'; import 'package:pub_semver/pub_semver.dart'; @@ -192,9 +191,7 @@ class VersionCheckCommand extends PluginCommand { final String error = '$pubspecPath incorrectly updated version.\n' 'HEAD: $headVersion, master: $masterVersion.\n' 'Allowed versions: $allowedNextVersions'; - final Colorize redError = Colorize(error)..red(); - print(redError); - throw ToolExit(1); + ThrowsToolExit(errorMessage: error); } bool isPlatformInterface = pubspec.name.endsWith("_platform_interface"); @@ -203,9 +200,7 @@ class VersionCheckCommand extends PluginCommand { NextVersionType.BREAKING_MAJOR) { final String error = '$pubspecPath breaking change detected.\n' 'Breaking changes to platform interfaces are strongly discouraged.\n'; - final Colorize redError = Colorize(error)..red(); - print(redError); - throw ToolExit(1); + ThrowsToolExit(errorMessage: error); } } on io.ProcessException { print('Unable to find pubspec in master for $pubspecPath.' @@ -238,20 +233,17 @@ class VersionCheckCommand extends PluginCommand { Version fromChangeLog = Version.parse(versionString); if (fromChangeLog == null) { final String error = 'Can not find version on the first line of CHANGELOG.md'; - final Colorize redError = Colorize(error)..red(); - print(redError); - throw ToolExit(1); + ThrowsToolExit(errorMessage: error); } if (fromPubspec != fromChangeLog) { final String error = 'versions for $packageName in CHANGELOG.md and pubspec.yaml do not match.'; - final Colorize redError = Colorize(error)..red(); - print(redError); - throw ToolExit(1); + ThrowsToolExit(errorMessage: error); } print('${plugin.basename} passed version check'); } + // ignore: missing_return Pubspec _tryParsePubspec(Directory package) { final File pubspecFile = package.childFile('pubspec.yaml'); @@ -259,16 +251,12 @@ class VersionCheckCommand extends PluginCommand { Pubspec pubspec = Pubspec.parse(pubspecFile.readAsStringSync()); if (pubspec == null) { final String error = 'Failed to parse `pubspec.yaml` at ${pubspecFile.path}'; - final Colorize redError = Colorize(error)..red(); - print(redError); - throw ToolExit(1); + ThrowsToolExit(errorMessage: error); } return pubspec; } on Exception catch (exception) { final String error = 'Failed to parse `pubspec.yaml` at ${pubspecFile.path}: $exception}'; - final Colorize redError = Colorize(error)..red(); - print(redError); - throw ToolExit(1); + ThrowsToolExit(errorMessage: error); } } } From 025a910ddf18e202c1183c89146ccd66f67562f0 Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Mon, 8 Mar 2021 10:22:25 -0800 Subject: [PATCH 16/43] review 1 --- .cirrus.yml | 5 +- script/tool/lib/src/common.dart | 2 +- .../tool/lib/src/version_check_command.dart | 37 ++++++++----- script/tool/test/util.dart | 2 +- script/tool/test/version_check_test.dart | 55 ++++++++++++++++++- 5 files changed, 81 insertions(+), 20 deletions(-) diff --git a/.cirrus.yml b/.cirrus.yml index 60c211f4e381..243f081bbe3a 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -23,13 +23,10 @@ task: - pub get - CIRRUS_BUILD_ID=null pub run test - name: publishable - script: - - flutter channel master - - ./script/check_publish.sh - - name: version script: - flutter channel master - ./script/check_version.sh + - ./script/check_publish.sh - name: format install_script: - wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - diff --git a/script/tool/lib/src/common.dart b/script/tool/lib/src/common.dart index 698350037aa5..ce0fdc782883 100644 --- a/script/tool/lib/src/common.dart +++ b/script/tool/lib/src/common.dart @@ -143,7 +143,7 @@ bool isLinuxPlugin(FileSystemEntity entity, FileSystem fileSystem) { } /// Throws a [ToolExit] with `exitCode` and log the `errorMessage` in red. -void ThrowsToolExit({@required String errorMessage, int exitCode = 1}) { +void PrintErrorAndExit({@required String errorMessage, int exitCode = 1}) { final Colorize redError = Colorize(errorMessage)..red(); print(redError); throw ToolExit(exitCode); diff --git a/script/tool/lib/src/version_check_command.dart b/script/tool/lib/src/version_check_command.dart index 230bc86a9314..8c4a50275241 100644 --- a/script/tool/lib/src/version_check_command.dart +++ b/script/tool/lib/src/version_check_command.dart @@ -175,6 +175,9 @@ class VersionCheckCommand extends PluginCommand { continue; } final Pubspec pubspec = Pubspec.parse(pubspecFile.readAsStringSync()); + if (pubspec.publishTo == 'none') { + continue; + } final Version masterVersion = await gitVersionFinder.getPackageVersion(pubspecPath, baseSha); @@ -191,7 +194,7 @@ class VersionCheckCommand extends PluginCommand { final String error = '$pubspecPath incorrectly updated version.\n' 'HEAD: $headVersion, master: $masterVersion.\n' 'Allowed versions: $allowedNextVersions'; - ThrowsToolExit(errorMessage: error); + PrintErrorAndExit(errorMessage: error); } bool isPlatformInterface = pubspec.name.endsWith("_platform_interface"); @@ -200,7 +203,7 @@ class VersionCheckCommand extends PluginCommand { NextVersionType.BREAKING_MAJOR) { final String error = '$pubspecPath breaking change detected.\n' 'Breaking changes to platform interfaces are strongly discouraged.\n'; - ThrowsToolExit(errorMessage: error); + PrintErrorAndExit(errorMessage: error); } } on io.ProcessException { print('Unable to find pubspec in master for $pubspecPath.' @@ -218,13 +221,17 @@ class VersionCheckCommand extends PluginCommand { Future _checkVersionsMatch(Directory plugin) async { // get version from pubspec final String packageName = plugin.basename; - print('================================================================'); - print('Checking that $packageName has matching version in CHANGELOG and pubspec'); + print('-----------------------------------------'); + print('Checking the first version listed in CHANGELOG.MD matches the version in pubspec.yaml for $packageName.'); final Pubspec pubspec = _tryParsePubspec(plugin); + if (pubspec == null) { + final String error = 'Cannot parse version from pubspec.yaml'; + PrintErrorAndExit(errorMessage: error); + } final Version fromPubspec = pubspec.version; - // get version from CHANGELOG + // get first version from CHANGELOG final File changelog = plugin.childFile('CHANGELOG.md'); final List lines = changelog.readAsLinesSync(); final String firstLine = lines.first; @@ -232,18 +239,21 @@ class VersionCheckCommand extends PluginCommand { final String versionString = firstLine.split(' ').last; Version fromChangeLog = Version.parse(versionString); if (fromChangeLog == null) { - final String error = 'Can not find version on the first line of CHANGELOG.md'; - ThrowsToolExit(errorMessage: error); + final String error = 'Cannot find version on the first line of CHANGELOG.md'; + PrintErrorAndExit(errorMessage: error); } if (fromPubspec != fromChangeLog) { - final String error = 'versions for $packageName in CHANGELOG.md and pubspec.yaml do not match.'; - ThrowsToolExit(errorMessage: error); + final String error = ''' +versions for $packageName in CHANGELOG.md and pubspec.yaml do not match. +The version in pubspec.yaml is $fromPubspec. +The first version listed in CHANGELOG.md is $fromChangeLog. +'''; + PrintErrorAndExit(errorMessage: error); } - print('${plugin.basename} passed version check'); + print('${packageName} passed version check'); } - // ignore: missing_return Pubspec _tryParsePubspec(Directory package) { final File pubspecFile = package.childFile('pubspec.yaml'); @@ -251,12 +261,13 @@ class VersionCheckCommand extends PluginCommand { Pubspec pubspec = Pubspec.parse(pubspecFile.readAsStringSync()); if (pubspec == null) { final String error = 'Failed to parse `pubspec.yaml` at ${pubspecFile.path}'; - ThrowsToolExit(errorMessage: error); + PrintErrorAndExit(errorMessage: error); } return pubspec; } on Exception catch (exception) { final String error = 'Failed to parse `pubspec.yaml` at ${pubspecFile.path}: $exception}'; - ThrowsToolExit(errorMessage: error); + PrintErrorAndExit(errorMessage: error); } + return null; } } diff --git a/script/tool/test/util.dart b/script/tool/test/util.dart index 555951b93ebf..1538d9b554e8 100644 --- a/script/tool/test/util.dart +++ b/script/tool/test/util.dart @@ -168,7 +168,7 @@ dependencies: if (includeVersion) { yaml += ''' version: $version -publish_to: none # Hardcoded safeguard to prevent this from somehow being published by a broken test. +publish_to: http://no_pub_server.com # Hardcoded safeguard to prevent this from somehow being published by a broken test. '''; } parent.childFile('pubspec.yaml').writeAsStringSync(yaml); diff --git a/script/tool/test/version_check_test.dart b/script/tool/test/version_check_test.dart index dc2ce3c0f1fc..b5b7d3923884 100644 --- a/script/tool/test/version_check_test.dart +++ b/script/tool/test/version_check_test.dart @@ -2,6 +2,7 @@ import 'dart:async'; import 'dart:io'; import 'package:args/command_runner.dart'; +import 'package:flutter_plugin_tools/src/common.dart'; import 'package:git/git.dart'; import 'package:mockito/mockito.dart'; import "package:test/test.dart"; @@ -238,6 +239,19 @@ void main() { output, throwsA(const TypeMatcher()), ); + try { + List outputValue = await output; + await expectLater( + outputValue, + containsAllInOrder([ + ''' + versions for plugin in CHANGELOG.md and pubspec.yaml do not match. + The version in pubspec.yaml is 1.0.1. + The first version listed in CHANGELOG.md is 1.0.2. + ''', + ]), + ); + } on ToolExit catch (_) {} }); test('Success if CHANGELOG and pubspec versions match', () async{ @@ -258,11 +272,50 @@ void main() { await expect( output, containsAllInOrder([ - 'Checking that plugin has matching version in CHANGELOG and pubspec', + 'Checking the first version listed in CHANGELOG.MD matches the version in pubspec.yaml for plugin.', + 'plugin passed version check', 'No version check errors found!' ]), ); }); + + test('Fail if pubspec version only matches an older version listed in CHANGELOG', () async{ + createFakePlugin('plugin', includeChangeLog: true, includeVersion: true); + + final Directory pluginDirectory = + mockPackagesDir.childDirectory('plugin'); + + createFakePubspec(pluginDirectory, isFlutter: true, includeVersion: true, version: '1.0.0'); + String changelog = ''' +## 1.0.1 + +* Some changes. + +## 1.0.0 + +* Some other changes. +'''; + createFakeCHANGELOG(pluginDirectory, changelog); + Future> output = runCapturingPrint( + runner, ['version-check', '--base_sha=master']); + await expectLater( + output, + throwsA(const TypeMatcher()), + ); + try { + List outputValue = await output; + await expectLater( + outputValue, + containsAllInOrder([ + ''' + versions for plugin in CHANGELOG.md and pubspec.yaml do not match. + The version in pubspec.yaml is 1.0.0. + The first version listed in CHANGELOG.md is 1.0.1. + ''', + ]), + ); + } on ToolExit catch (_) {} + }); }); group("Pre 1.0", () { From 3e9e74e6f8e1aac7ca09d5e3b4e876e4ed6ff123 Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Mon, 8 Mar 2021 10:26:14 -0800 Subject: [PATCH 17/43] format --- .../tool/lib/src/version_check_command.dart | 12 +++++--- script/tool/test/version_check_test.dart | 28 ++++++++++++------- 2 files changed, 26 insertions(+), 14 deletions(-) diff --git a/script/tool/lib/src/version_check_command.dart b/script/tool/lib/src/version_check_command.dart index 8c4a50275241..7ab37a558044 100644 --- a/script/tool/lib/src/version_check_command.dart +++ b/script/tool/lib/src/version_check_command.dart @@ -222,7 +222,8 @@ class VersionCheckCommand extends PluginCommand { // get version from pubspec final String packageName = plugin.basename; print('-----------------------------------------'); - print('Checking the first version listed in CHANGELOG.MD matches the version in pubspec.yaml for $packageName.'); + print( + 'Checking the first version listed in CHANGELOG.MD matches the version in pubspec.yaml for $packageName.'); final Pubspec pubspec = _tryParsePubspec(plugin); if (pubspec == null) { @@ -239,7 +240,8 @@ class VersionCheckCommand extends PluginCommand { final String versionString = firstLine.split(' ').last; Version fromChangeLog = Version.parse(versionString); if (fromChangeLog == null) { - final String error = 'Cannot find version on the first line of CHANGELOG.md'; + final String error = + 'Cannot find version on the first line of CHANGELOG.md'; PrintErrorAndExit(errorMessage: error); } @@ -260,12 +262,14 @@ The first version listed in CHANGELOG.md is $fromChangeLog. try { Pubspec pubspec = Pubspec.parse(pubspecFile.readAsStringSync()); if (pubspec == null) { - final String error = 'Failed to parse `pubspec.yaml` at ${pubspecFile.path}'; + final String error = + 'Failed to parse `pubspec.yaml` at ${pubspecFile.path}'; PrintErrorAndExit(errorMessage: error); } return pubspec; } on Exception catch (exception) { - final String error = 'Failed to parse `pubspec.yaml` at ${pubspecFile.path}: $exception}'; + final String error = + 'Failed to parse `pubspec.yaml` at ${pubspecFile.path}: $exception}'; PrintErrorAndExit(errorMessage: error); } return null; diff --git a/script/tool/test/version_check_test.dart b/script/tool/test/version_check_test.dart index b5b7d3923884..ae32f3ac831e 100644 --- a/script/tool/test/version_check_test.dart +++ b/script/tool/test/version_check_test.dart @@ -145,7 +145,8 @@ void main() { }); test('allows minor changes to platform interfaces', () async { - createFakePlugin('plugin_platform_interface', includeChangeLog: true, includeVersion: true); + createFakePlugin('plugin_platform_interface', + includeChangeLog: true, includeVersion: true); gitDiffResponse = "packages/plugin_platform_interface/pubspec.yaml"; gitShowResponses = { 'master:packages/plugin_platform_interface/pubspec.yaml': @@ -173,7 +174,8 @@ void main() { }); test('disallows breaking changes to platform interfaces', () async { - createFakePlugin('plugin_platform_interface', includeChangeLog: true, includeVersion: true); + createFakePlugin('plugin_platform_interface', + includeChangeLog: true, includeVersion: true); gitDiffResponse = "packages/plugin_platform_interface/pubspec.yaml"; gitShowResponses = { 'master:packages/plugin_platform_interface/pubspec.yaml': @@ -198,13 +200,14 @@ void main() { equals('show HEAD:packages/plugin_platform_interface/pubspec.yaml')); }); - test('Throws if first line in change log is empty', () async{ + test('Throws if first line in change log is empty', () async { createFakePlugin('plugin', includeChangeLog: true, includeVersion: true); final Directory pluginDirectory = mockPackagesDir.childDirectory('plugin'); - createFakePubspec(pluginDirectory, isFlutter: true, includeVersion: true, version: '1.0.1'); + createFakePubspec(pluginDirectory, + isFlutter: true, includeVersion: true, version: '1.0.1'); String changelog = ''' ## 1.0.1 @@ -220,13 +223,14 @@ void main() { ); }); - test('Throws if versions in changelog and pubspec do not match', () async{ + test('Throws if versions in changelog and pubspec do not match', () async { createFakePlugin('plugin', includeChangeLog: true, includeVersion: true); final Directory pluginDirectory = mockPackagesDir.childDirectory('plugin'); - createFakePubspec(pluginDirectory, isFlutter: true, includeVersion: true, version: '1.0.1'); + createFakePubspec(pluginDirectory, + isFlutter: true, includeVersion: true, version: '1.0.1'); String changelog = ''' ## 1.0.2 @@ -254,13 +258,14 @@ void main() { } on ToolExit catch (_) {} }); - test('Success if CHANGELOG and pubspec versions match', () async{ + test('Success if CHANGELOG and pubspec versions match', () async { createFakePlugin('plugin', includeChangeLog: true, includeVersion: true); final Directory pluginDirectory = mockPackagesDir.childDirectory('plugin'); - createFakePubspec(pluginDirectory, isFlutter: true, includeVersion: true, version: '1.0.1'); + createFakePubspec(pluginDirectory, + isFlutter: true, includeVersion: true, version: '1.0.1'); String changelog = ''' ## 1.0.1 @@ -279,13 +284,16 @@ void main() { ); }); - test('Fail if pubspec version only matches an older version listed in CHANGELOG', () async{ + test( + 'Fail if pubspec version only matches an older version listed in CHANGELOG', + () async { createFakePlugin('plugin', includeChangeLog: true, includeVersion: true); final Directory pluginDirectory = mockPackagesDir.childDirectory('plugin'); - createFakePubspec(pluginDirectory, isFlutter: true, includeVersion: true, version: '1.0.0'); + createFakePubspec(pluginDirectory, + isFlutter: true, includeVersion: true, version: '1.0.0'); String changelog = ''' ## 1.0.1 From 94566ee13efd2b1564d24c311c7ed5c224433882 Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Mon, 8 Mar 2021 10:49:57 -0800 Subject: [PATCH 18/43] allow empty lines --- script/tool/lib/src/version_check_command.dart | 14 ++++++++++++-- script/tool/test/version_check_test.dart | 15 +++++++++++---- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/script/tool/lib/src/version_check_command.dart b/script/tool/lib/src/version_check_command.dart index 7ab37a558044..3a04972752ec 100644 --- a/script/tool/lib/src/version_check_command.dart +++ b/script/tool/lib/src/version_check_command.dart @@ -235,9 +235,19 @@ class VersionCheckCommand extends PluginCommand { // get first version from CHANGELOG final File changelog = plugin.childFile('CHANGELOG.md'); final List lines = changelog.readAsLinesSync(); - final String firstLine = lines.first; + String firstLineWithText; + final Iterator iterator = lines.iterator; + while (iterator.moveNext()) { + final String currentStriptEmptySpaces = + (iterator.current as String).replaceAll(' ', ''); + if (currentStriptEmptySpaces != null && + currentStriptEmptySpaces.isNotEmpty) { + firstLineWithText = iterator.current; + break; + } + } // Remove all leading mark down syntax from the version line. - final String versionString = firstLine.split(' ').last; + final String versionString = firstLineWithText.split(' ').last; Version fromChangeLog = Version.parse(versionString); if (fromChangeLog == null) { final String error = diff --git a/script/tool/test/version_check_test.dart b/script/tool/test/version_check_test.dart index ae32f3ac831e..48a96bbb60fa 100644 --- a/script/tool/test/version_check_test.dart +++ b/script/tool/test/version_check_test.dart @@ -200,7 +200,8 @@ void main() { equals('show HEAD:packages/plugin_platform_interface/pubspec.yaml')); }); - test('Throws if first line in change log is empty', () async { + test('Allow empty lines in front of the first version in CHANGELOG', + () async { createFakePlugin('plugin', includeChangeLog: true, includeVersion: true); final Directory pluginDirectory = @@ -209,17 +210,23 @@ void main() { createFakePubspec(pluginDirectory, isFlutter: true, includeVersion: true, version: '1.0.1'); String changelog = ''' + + ## 1.0.1 * Some changes. '''; createFakeCHANGELOG(pluginDirectory, changelog); - final Future> output = runCapturingPrint( + final List output = await runCapturingPrint( runner, ['version-check', '--base_sha=master']); - await expectLater( + await expect( output, - throwsA(const TypeMatcher()), + containsAllInOrder([ + 'Checking the first version listed in CHANGELOG.MD matches the version in pubspec.yaml for plugin.', + 'plugin passed version check', + 'No version check errors found!' + ]), ); }); From 75c6e46f0ae75c6edbe72ec9236aa9a7172bdda9 Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Mon, 8 Mar 2021 13:25:19 -0800 Subject: [PATCH 19/43] get changed plugins --- .../device_info/example/lib/main.dart | 1 + script/tool/lib/src/common.dart | 59 +++++++++++++++ .../lib/src/get_changed_package_command.dart | 75 +++++++++++++++++++ script/tool/lib/src/main.dart | 4 +- .../tool/lib/src/version_check_command.dart | 28 ------- 5 files changed, 138 insertions(+), 29 deletions(-) create mode 100644 script/tool/lib/src/get_changed_package_command.dart diff --git a/packages/device_info/device_info/example/lib/main.dart b/packages/device_info/device_info/example/lib/main.dart index 805de1417f15..e5d8d6408649 100644 --- a/packages/device_info/device_info/example/lib/main.dart +++ b/packages/device_info/device_info/example/lib/main.dart @@ -4,6 +4,7 @@ // ignore_for_file: public_member_api_docs + import 'dart:async'; import 'dart:io'; diff --git a/script/tool/lib/src/common.dart b/script/tool/lib/src/common.dart index ce0fdc782883..86579e791e96 100644 --- a/script/tool/lib/src/common.dart +++ b/script/tool/lib/src/common.dart @@ -9,8 +9,10 @@ import 'dart:math'; import 'package:args/command_runner.dart'; import 'package:colorize/colorize.dart'; import 'package:file/file.dart'; +import 'package:git/git.dart'; import 'package:meta/meta.dart'; import 'package:path/path.dart' as p; +import 'package:pub_semver/pub_semver.dart'; import 'package:yaml/yaml.dart'; typedef void Print(Object object); @@ -475,3 +477,60 @@ class ProcessRunner { return 'ERROR: Unable to execute "$executable ${args.join(' ')}"$workdir.'; } } + +/// Finding diffs based on `baseGitDir` and `baseSha`. +class GitVersionFinder { + + /// Constructor + GitVersionFinder(this.baseGitDir, this.baseSha) { + } + + /// The top level directory of the git repo. + /// + /// That is where the .git/ folder exists. + final GitDir baseGitDir; + + /// The base sha used to get diff. + final String baseSha; + + static bool _isPubspec(String file) { + return file.trim().endsWith('pubspec.yaml'); + } + + /// Get a list of all the pubspec.yaml file that is changed. + Future> getChangedPubSpecs() async { + return (await getChangedFiles()).where(_isPubspec); + } + + /// Get a list of all the changed files. + Future> getChangedFiles() async { + final io.ProcessResult changedFilesCommand = await baseGitDir + .runCommand(['diff', '--name-only', '${await _getBaseSha()}', 'HEAD']); + final List changedFiles = + changedFilesCommand.stdout.toString().split('\n'); + return changedFiles.toList(); + } + + /// Get the package version specified in the pubspec file in `pubspecPath` and at the revision of `gitRef`. + Future getPackageVersion(String pubspecPath, String gitRef) async { + final io.ProcessResult gitShow = + await baseGitDir.runCommand(['show', '$gitRef:$pubspecPath']); + final String fileContent = gitShow.stdout; + final String versionString = loadYaml(fileContent)['version']; + return versionString == null ? null : Version.parse(versionString); + } + + Future _getBaseSha() async { + if (baseSha != null && baseSha.isNotEmpty) { + return baseSha; + } + + io.ProcessResult baseShaFromMergeBase = + await baseGitDir.runCommand(['merge-base', '--fork-point', 'FETCH_HEAD', 'HEAD'], throwOnError: false); + if (baseShaFromMergeBase == null || baseShaFromMergeBase.stderr != null || baseShaFromMergeBase.stdout == null) { + baseShaFromMergeBase = + await baseGitDir.runCommand(['merge-base', 'FETCH_HEAD', 'HEAD']); + } + return (baseShaFromMergeBase.stdout as String).replaceAll('\n', ''); + } +} diff --git a/script/tool/lib/src/get_changed_package_command.dart b/script/tool/lib/src/get_changed_package_command.dart new file mode 100644 index 000000000000..0c87319359c0 --- /dev/null +++ b/script/tool/lib/src/get_changed_package_command.dart @@ -0,0 +1,75 @@ +// Copyright 2017 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'dart:async'; + +import 'package:file/file.dart'; +import 'package:git/git.dart'; + +import 'common.dart'; + +const String _kBaseSha = 'base_sha'; + +/// Get the changed packages based on base_sha. +/// +/// Outputs the final result in a comma separated format. +/// e.g. plugin1,plugin2... +class GetChangedPackageCommand extends PluginCommand { + + /// Constructor of the command. + /// + /// An optional `gitDir` can be specified if the `gitDir` used is not the top level dir. + GetChangedPackageCommand( + Directory packagesDir, + FileSystem fileSystem, { + ProcessRunner processRunner = const ProcessRunner(), + this.gitDir, + }) : super(packagesDir, fileSystem, processRunner: processRunner) { + argParser.addOption(_kBaseSha); + } + + /// The git directory to use. By default it uses the parent directory. + /// + /// This can be mocked for testing. + final GitDir gitDir; + + @override + final String name = 'get-changed-packages'; + + @override + final String description = + 'Determines a list of changed packages based on the diff between base_sha and HEAD.\n' + 'The changed packages are returned through stdout and are separated by commas. (plugin1,plugin2..)'; + + @override + Future run() async { + checkSharding(); + + final String rootDir = packagesDir.parent.absolute.path; + String baseSha = argResults[_kBaseSha]; + + GitDir baseGitDir = gitDir; + if (baseGitDir == null) { + if (!await GitDir.isGitDir(rootDir)) { + print('$rootDir is not a valid Git repository.'); + throw ToolExit(2); + } + baseGitDir = await GitDir.fromExisting(rootDir); + } + + final GitVersionFinder gitVersionFinder = + GitVersionFinder(baseGitDir, baseSha); + + final List allChangedFiles = await gitVersionFinder.getChangedFiles(); + final Set plugins = {}; + allChangedFiles.forEach((String path) { + final List pathComponents = path.split('/'); + final int packagesIndex = pathComponents.indexWhere((String element) => element == 'package'); + if (packagesIndex != -1) { + plugins.add(pathComponents[packagesIndex+1]); + } + }); + print(plugins.join(',')); + } +} diff --git a/script/tool/lib/src/main.dart b/script/tool/lib/src/main.dart index fa81597237d7..613e163507dd 100644 --- a/script/tool/lib/src/main.dart +++ b/script/tool/lib/src/main.dart @@ -17,6 +17,7 @@ import 'common.dart'; import 'create_all_plugins_app_command.dart'; import 'drive_examples_command.dart'; import 'firebase_test_lab_command.dart'; +import 'get_changed_package_command.dart'; import 'format_command.dart'; import 'java_test_command.dart'; import 'lint_podspecs_command.dart'; @@ -56,7 +57,8 @@ void main(List args) { ..addCommand(PublishPluginCommand(packagesDir, fileSystem)) ..addCommand(TestCommand(packagesDir, fileSystem)) ..addCommand(VersionCheckCommand(packagesDir, fileSystem)) - ..addCommand(XCTestCommand(packagesDir, fileSystem)); + ..addCommand(XCTestCommand(packagesDir, fileSystem)) + ..addCommand(GetChangedPackageCommand(packagesDir, fileSystem)); commandRunner.run(args).catchError((Object e) { final ToolExit toolExit = e; diff --git a/script/tool/lib/src/version_check_command.dart b/script/tool/lib/src/version_check_command.dart index 3a04972752ec..e6c29477ab94 100644 --- a/script/tool/lib/src/version_check_command.dart +++ b/script/tool/lib/src/version_check_command.dart @@ -10,39 +10,11 @@ import 'package:file/file.dart'; import 'package:git/git.dart'; import 'package:pub_semver/pub_semver.dart'; import 'package:pubspec_parse/pubspec_parse.dart'; -import 'package:yaml/yaml.dart'; import 'common.dart'; const String _kBaseSha = 'base_sha'; -class GitVersionFinder { - GitVersionFinder(this.baseGitDir, this.baseSha); - - final GitDir baseGitDir; - final String baseSha; - - static bool isPubspec(String file) { - return file.trim().endsWith('pubspec.yaml'); - } - - Future> getChangedPubSpecs() async { - final io.ProcessResult changedFilesCommand = await baseGitDir - .runCommand(['diff', '--name-only', '$baseSha', 'HEAD']); - final List changedFiles = - changedFilesCommand.stdout.toString().split('\n'); - return changedFiles.where(isPubspec).toList(); - } - - Future getPackageVersion(String pubspecPath, String gitRef) async { - final io.ProcessResult gitShow = - await baseGitDir.runCommand(['show', '$gitRef:$pubspecPath']); - final String fileContent = gitShow.stdout; - final String versionString = loadYaml(fileContent)['version']; - return versionString == null ? null : Version.parse(versionString); - } -} - enum NextVersionType { BREAKING_MAJOR, MAJOR_NULLSAFETY_PRE_RELEASE, From 697b4bfce999218fca6d1ecb2aa85437d4327165 Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Mon, 8 Mar 2021 13:29:45 -0800 Subject: [PATCH 20/43] fix typo --- script/tool/lib/src/get_changed_package_command.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/tool/lib/src/get_changed_package_command.dart b/script/tool/lib/src/get_changed_package_command.dart index 0c87319359c0..ff8a1ff960eb 100644 --- a/script/tool/lib/src/get_changed_package_command.dart +++ b/script/tool/lib/src/get_changed_package_command.dart @@ -65,7 +65,7 @@ class GetChangedPackageCommand extends PluginCommand { final Set plugins = {}; allChangedFiles.forEach((String path) { final List pathComponents = path.split('/'); - final int packagesIndex = pathComponents.indexWhere((String element) => element == 'package'); + final int packagesIndex = pathComponents.indexWhere((String element) => element == 'packages'); if (packagesIndex != -1) { plugins.add(pathComponents[packagesIndex+1]); } From 744b7d1c191a09dd536f979156004e7defa05cf5 Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Mon, 8 Mar 2021 14:43:46 -0800 Subject: [PATCH 21/43] rename file and bug fixes --- script/tool/lib/src/common.dart | 5 +- ...dart => get_changed_packages_command.dart} | 0 script/tool/lib/src/main.dart | 4 +- .../get_changed_packages_command_test.dart | 63 +++++++++++++++++++ 4 files changed, 67 insertions(+), 5 deletions(-) rename script/tool/lib/src/{get_changed_package_command.dart => get_changed_packages_command.dart} (100%) create mode 100644 script/tool/test/get_changed_packages_command_test.dart diff --git a/script/tool/lib/src/common.dart b/script/tool/lib/src/common.dart index 86579e791e96..95f53c0fd650 100644 --- a/script/tool/lib/src/common.dart +++ b/script/tool/lib/src/common.dart @@ -482,8 +482,7 @@ class ProcessRunner { class GitVersionFinder { /// Constructor - GitVersionFinder(this.baseGitDir, this.baseSha) { - } + GitVersionFinder(this.baseGitDir, this.baseSha); /// The top level directory of the git repo. /// @@ -499,7 +498,7 @@ class GitVersionFinder { /// Get a list of all the pubspec.yaml file that is changed. Future> getChangedPubSpecs() async { - return (await getChangedFiles()).where(_isPubspec); + return (await getChangedFiles()).where(_isPubspec).toList(); } /// Get a list of all the changed files. diff --git a/script/tool/lib/src/get_changed_package_command.dart b/script/tool/lib/src/get_changed_packages_command.dart similarity index 100% rename from script/tool/lib/src/get_changed_package_command.dart rename to script/tool/lib/src/get_changed_packages_command.dart diff --git a/script/tool/lib/src/main.dart b/script/tool/lib/src/main.dart index 613e163507dd..8043ddcbbaa9 100644 --- a/script/tool/lib/src/main.dart +++ b/script/tool/lib/src/main.dart @@ -17,7 +17,7 @@ import 'common.dart'; import 'create_all_plugins_app_command.dart'; import 'drive_examples_command.dart'; import 'firebase_test_lab_command.dart'; -import 'get_changed_package_command.dart'; +import 'get_changed_packages_command.dart'; import 'format_command.dart'; import 'java_test_command.dart'; import 'lint_podspecs_command.dart'; @@ -58,7 +58,7 @@ void main(List args) { ..addCommand(TestCommand(packagesDir, fileSystem)) ..addCommand(VersionCheckCommand(packagesDir, fileSystem)) ..addCommand(XCTestCommand(packagesDir, fileSystem)) - ..addCommand(GetChangedPackageCommand(packagesDir, fileSystem)); + ..addCommand(GetChangedPackagesCommand(packagesDir, fileSystem)); commandRunner.run(args).catchError((Object e) { final ToolExit toolExit = e; diff --git a/script/tool/test/get_changed_packages_command_test.dart b/script/tool/test/get_changed_packages_command_test.dart new file mode 100644 index 000000000000..e2ddf7c9fd01 --- /dev/null +++ b/script/tool/test/get_changed_packages_command_test.dart @@ -0,0 +1,63 @@ +// Copyright 2017 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'dart:async'; +import 'dart:io'; + +import 'package:args/command_runner.dart'; +import 'package:git/git.dart'; +import 'package:mockito/mockito.dart'; +import "package:test/test.dart"; +import "package:flutter_plugin_tools/src/get_changed_packages_command.dart"; +import 'util.dart'; + +class MockGitDir extends Mock implements GitDir {} + +class MockProcessResult extends Mock implements ProcessResult {} + +void main() { + group('$GetChangedPackagesCommand', () { + CommandRunner runner; + RecordingProcessRunner processRunner; + List> gitDirCommands; + String gitDiffResponse; + + setUp(() { + gitDirCommands = >[]; + gitDiffResponse = ''; + final MockGitDir gitDir = MockGitDir(); + when(gitDir.runCommand(any)).thenAnswer((Invocation invocation) { + gitDirCommands.add(invocation.positionalArguments[0]); + final MockProcessResult mockProcessResult = MockProcessResult(); + if (invocation.positionalArguments[0][0] == 'diff') { + when(mockProcessResult.stdout).thenReturn(gitDiffResponse); + } + return Future.value(mockProcessResult); + }); + initializeFakePackages(); + processRunner = RecordingProcessRunner(); + final GetChangedPackagesCommand command = GetChangedPackagesCommand( + mockPackagesDir, mockFileSystem, + processRunner: processRunner, gitDir: gitDir); + + runner = CommandRunner( + 'get_changed_packages_command', 'Test for $GetChangedPackagesCommand'); + runner.addCommand(command); + }); + + tearDown(() { + cleanupPackages(); + }); + + test('No plugins changed', () async { + gitDiffResponse = ".cirrus"; + final List output = await runCapturingPrint( + runner, ['get-changed-packages', '--base_sha=master']); + + expect( + output, isEmpty + ); + }); + }); +} From 30b8677307d7e2b4e49e5f8fe219bd67f209178b Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Mon, 8 Mar 2021 15:20:09 -0800 Subject: [PATCH 22/43] auto get base sha and tests --- script/tool/lib/src/common.dart | 28 +++--- .../lib/src/get_changed_packages_command.dart | 17 ++-- script/tool/test/common_test.dart | 90 +++++++++++++++++++ .../get_changed_packages_command_test.dart | 65 ++++++++++++-- 4 files changed, 177 insertions(+), 23 deletions(-) diff --git a/script/tool/lib/src/common.dart b/script/tool/lib/src/common.dart index 95f53c0fd650..77fa1088b696 100644 --- a/script/tool/lib/src/common.dart +++ b/script/tool/lib/src/common.dart @@ -480,7 +480,6 @@ class ProcessRunner { /// Finding diffs based on `baseGitDir` and `baseSha`. class GitVersionFinder { - /// Constructor GitVersionFinder(this.baseGitDir, this.baseSha); @@ -503,10 +502,16 @@ class GitVersionFinder { /// Get a list of all the changed files. Future> getChangedFiles() async { - final io.ProcessResult changedFilesCommand = await baseGitDir - .runCommand(['diff', '--name-only', '${await _getBaseSha()}', 'HEAD']); - final List changedFiles = - changedFilesCommand.stdout.toString().split('\n'); + final io.ProcessResult changedFilesCommand = await baseGitDir.runCommand( + ['diff', '--name-only', '${await _getBaseSha()}', 'HEAD']); + if (changedFilesCommand.stdout.toString() == null || + changedFilesCommand.stdout.toString().isEmpty) { + return []; + } + final List changedFiles = changedFilesCommand.stdout + .toString() + .split('\n') + ..removeWhere((element) => element.isEmpty); return changedFiles.toList(); } @@ -524,11 +529,14 @@ class GitVersionFinder { return baseSha; } - io.ProcessResult baseShaFromMergeBase = - await baseGitDir.runCommand(['merge-base', '--fork-point', 'FETCH_HEAD', 'HEAD'], throwOnError: false); - if (baseShaFromMergeBase == null || baseShaFromMergeBase.stderr != null || baseShaFromMergeBase.stdout == null) { - baseShaFromMergeBase = - await baseGitDir.runCommand(['merge-base', 'FETCH_HEAD', 'HEAD']); + io.ProcessResult baseShaFromMergeBase = await baseGitDir.runCommand( + ['merge-base', '--fork-point', 'FETCH_HEAD', 'HEAD'], + throwOnError: false); + if (baseShaFromMergeBase == null || + baseShaFromMergeBase.stderr != null || + baseShaFromMergeBase.stdout == null) { + baseShaFromMergeBase = await baseGitDir + .runCommand(['merge-base', 'FETCH_HEAD', 'HEAD']); } return (baseShaFromMergeBase.stdout as String).replaceAll('\n', ''); } diff --git a/script/tool/lib/src/get_changed_packages_command.dart b/script/tool/lib/src/get_changed_packages_command.dart index ff8a1ff960eb..8fe88b04dcd6 100644 --- a/script/tool/lib/src/get_changed_packages_command.dart +++ b/script/tool/lib/src/get_changed_packages_command.dart @@ -15,12 +15,11 @@ const String _kBaseSha = 'base_sha'; /// /// Outputs the final result in a comma separated format. /// e.g. plugin1,plugin2... -class GetChangedPackageCommand extends PluginCommand { - +class GetChangedPackagesCommand extends PluginCommand { /// Constructor of the command. /// /// An optional `gitDir` can be specified if the `gitDir` used is not the top level dir. - GetChangedPackageCommand( + GetChangedPackagesCommand( Directory packagesDir, FileSystem fileSystem, { ProcessRunner processRunner = const ProcessRunner(), @@ -61,15 +60,19 @@ class GetChangedPackageCommand extends PluginCommand { final GitVersionFinder gitVersionFinder = GitVersionFinder(baseGitDir, baseSha); - final List allChangedFiles = await gitVersionFinder.getChangedFiles(); + final List allChangedFiles = + await gitVersionFinder.getChangedFiles(); final Set plugins = {}; allChangedFiles.forEach((String path) { final List pathComponents = path.split('/'); - final int packagesIndex = pathComponents.indexWhere((String element) => element == 'packages'); + final int packagesIndex = + pathComponents.indexWhere((String element) => element == 'packages'); if (packagesIndex != -1) { - plugins.add(pathComponents[packagesIndex+1]); + plugins.add(pathComponents[packagesIndex + 1]); } }); - print(plugins.join(',')); + if (plugins.isNotEmpty) { + print(plugins.join(',')); + } } } diff --git a/script/tool/test/common_test.dart b/script/tool/test/common_test.dart index b3504c2358d9..6a58e4a06acd 100644 --- a/script/tool/test/common_test.dart +++ b/script/tool/test/common_test.dart @@ -1,6 +1,10 @@ +import 'dart:io'; + import 'package:args/command_runner.dart'; import 'package:file/file.dart'; import 'package:flutter_plugin_tools/src/common.dart'; +import 'package:git/git.dart'; +import 'package:mockito/mockito.dart'; import 'package:test/test.dart'; import 'util.dart'; @@ -73,6 +77,88 @@ void main() { ]); expect(plugins, unorderedEquals([plugin2.path])); }); + + group('$GitVersionFinder', () { + List> gitDirCommands; + String gitDiffResponse; + String mergeBaseResponse; + MockGitDir gitDir; + + setUp(() { + gitDirCommands = >[]; + gitDiffResponse = ''; + gitDir = MockGitDir(); + when(gitDir.runCommand(any)).thenAnswer((Invocation invocation) { + gitDirCommands.add(invocation.positionalArguments[0]); + final MockProcessResult mockProcessResult = MockProcessResult(); + if (invocation.positionalArguments[0][0] == 'diff') { + when(mockProcessResult.stdout).thenReturn(gitDiffResponse); + } else if (invocation.positionalArguments[0][0] == 'merge-base') { + when(mockProcessResult.stdout).thenReturn(mergeBaseResponse); + } + return Future.value(mockProcessResult); + }); + initializeFakePackages(); + processRunner = RecordingProcessRunner(); + }); + + tearDown(() { + cleanupPackages(); + }); + + test('No git diff should result no files changed', () async { + final GitVersionFinder finder = GitVersionFinder(gitDir, 'some base sha'); + List changedFiles = await finder.getChangedFiles(); + + expect(changedFiles, isEmpty); + }); + + test('get correct files changed based on git diff', () async { + gitDiffResponse = ''' +file1/file1.cc +file2/file2.cc +'''; + final GitVersionFinder finder = GitVersionFinder(gitDir, 'some base sha'); + List changedFiles = await finder.getChangedFiles(); + + expect( + changedFiles, equals(['file1/file1.cc', 'file2/file2.cc'])); + }); + + test('get correct pubspec change based on git diff', () async { + gitDiffResponse = ''' +file1/pubspec.yaml +file2/file2.cc +'''; + final GitVersionFinder finder = GitVersionFinder(gitDir, 'some base sha'); + List changedFiles = await finder.getChangedPubSpecs(); + + expect(changedFiles, equals(['file1/pubspec.yaml'])); + }); + + test('use correct base sha if not specified', () async { + mergeBaseResponse = 'shaqwiueroaaidf12312jnadf123nd'; + gitDiffResponse = ''' +file1/pubspec.yaml +file2/file2.cc +'''; + final GitVersionFinder finder = GitVersionFinder(gitDir, null); + await finder.getChangedFiles(); + verify(gitDir + .runCommand(['diff', '--name-only', mergeBaseResponse, 'HEAD'])); + }); + + test('use correct base sha if specified', () async { + final String customBaseSha = 'aklsjdcaskf12312'; + gitDiffResponse = ''' +file1/pubspec.yaml +file2/file2.cc +'''; + final GitVersionFinder finder = GitVersionFinder(gitDir, customBaseSha); + await finder.getChangedFiles(); + verify(gitDir.runCommand(['diff', '--name-only', customBaseSha, 'HEAD'])); + }); + }); } class SamplePluginCommand extends PluginCommand { @@ -98,3 +184,7 @@ class SamplePluginCommand extends PluginCommand { } } } + +class MockGitDir extends Mock implements GitDir {} + +class MockProcessResult extends Mock implements ProcessResult {} diff --git a/script/tool/test/get_changed_packages_command_test.dart b/script/tool/test/get_changed_packages_command_test.dart index e2ddf7c9fd01..4c60f02a5416 100644 --- a/script/tool/test/get_changed_packages_command_test.dart +++ b/script/tool/test/get_changed_packages_command_test.dart @@ -41,8 +41,8 @@ void main() { mockPackagesDir, mockFileSystem, processRunner: processRunner, gitDir: gitDir); - runner = CommandRunner( - 'get_changed_packages_command', 'Test for $GetChangedPackagesCommand'); + runner = CommandRunner('get_changed_packages_command', + 'Test for $GetChangedPackagesCommand'); runner.addCommand(command); }); @@ -50,14 +50,67 @@ void main() { cleanupPackages(); }); - test('No plugins changed', () async { + test('No files changed should have empty output', () async { + final List output = await runCapturingPrint( + runner, ['get-changed-packages', '--base_sha=master']); + + expect(output, isEmpty); + }); + + test('Some none plugin files changed have empty output', () async { gitDiffResponse = ".cirrus"; final List output = await runCapturingPrint( runner, ['get-changed-packages', '--base_sha=master']); - expect( - output, isEmpty - ); + expect(output, isEmpty); + }); + + test('plugin code changed should output the plugin', () async { + gitDiffResponse = "packages/plugin1/plugin1.dart"; + final List output = await runCapturingPrint( + runner, ['get-changed-packages', '--base_sha=master']); + + expect(output, equals(['plugin1'])); + }); + + test( + 'multiple files in one plugin changed should output the same plugin once', + () async { + gitDiffResponse = ''' +packages/plugin1/plugin1.dart +packages/plugin1/ios/plugin1.m +'''; + final List output = await runCapturingPrint( + runner, ['get-changed-packages', '--base_sha=master']); + + expect(output, equals(['plugin1'])); + }); + + test( + 'multiple plugins changed should output those plugins with , separated', + () async { + gitDiffResponse = ''' +packages/plugin1/plugin1.dart +packages/plugin2/ios/plugin1.m +'''; + final List output = await runCapturingPrint( + runner, ['get-changed-packages', '--base_sha=master']); + + expect(output, equals(['plugin1,plugin2'])); + }); + + test( + 'multiple plugins inside the same plugin group changed should output the plugin group name', + () async { + gitDiffResponse = ''' +packages/plugin1/plugin1/plugin1.dart +packages/plugin1/plugin1_platform_interface/plugin1_platform_interface.dart +packages/plugin1/plugin1_web/plugin1_web.dart +'''; + final List output = await runCapturingPrint( + runner, ['get-changed-packages', '--base_sha=master']); + + expect(output, equals(['plugin1'])); }); }); } From 3e0ccc62e5ef00fffbfd02b99a07438cf2175037 Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Mon, 8 Mar 2021 15:41:21 -0800 Subject: [PATCH 23/43] remove sh script and add the script to cirrus --- .cirrus.yml | 7 ++++++- script/check_version.sh | 15 --------------- 2 files changed, 6 insertions(+), 16 deletions(-) delete mode 100755 script/check_version.sh diff --git a/.cirrus.yml b/.cirrus.yml index 243f081bbe3a..ad496317cfb4 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -25,7 +25,12 @@ task: - name: publishable script: - flutter channel master - - ./script/check_version.sh + - if [[$BRANCH != "master"]];then + - CHANGED_PLUGINS=$(dart run ./script/tool/lib/src/main.dart get-changed-packages) + - dart run ./script/tool/lib/src/main.dart check-version --plugins=$CHANGED_PLUGINS + - else + - dart run ./script/tool/lib/src/main.dart check-version + - fi - ./script/check_publish.sh - name: format install_script: diff --git a/script/check_version.sh b/script/check_version.sh deleted file mode 100755 index 0221df8b024b..000000000000 --- a/script/check_version.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash -set -e - -# So that users can run this script from anywhere and it will work as expected. -readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)" -readonly REPO_DIR="$(dirname "$SCRIPT_DIR")" - -source "$SCRIPT_DIR/common.sh" - -# Sets CHANGED_PACKAGE_LIST and CHANGED_PACKAGES -check_changed_packages - -plugin_tools version-check --base_sha="$(get_branch_base_sha)" -# if [[ "${#CHANGED_PACKAGE_LIST[@]}" != 0 ]]; then -# fi From 848b67fa6ab219158a95e1a1e921d0995511d26c Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Mon, 8 Mar 2021 15:43:09 -0800 Subject: [PATCH 24/43] add log to cirrus --- .cirrus.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.cirrus.yml b/.cirrus.yml index ad496317cfb4..e1176e77022c 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -27,8 +27,10 @@ task: - flutter channel master - if [[$BRANCH != "master"]];then - CHANGED_PLUGINS=$(dart run ./script/tool/lib/src/main.dart get-changed-packages) + - echo "Running check-version on changed pacakges $CHANGED_PLUGINS" - dart run ./script/tool/lib/src/main.dart check-version --plugins=$CHANGED_PLUGINS - else + - echo "Running check-version on all packages" - dart run ./script/tool/lib/src/main.dart check-version - fi - ./script/check_publish.sh From d1e3428de0bcaec101ca0d0114d44e5e9bf1b1fe Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Mon, 8 Mar 2021 16:00:04 -0800 Subject: [PATCH 25/43] make plugin_tools command a var --- .cirrus.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.cirrus.yml b/.cirrus.yml index e1176e77022c..b8ef4e0ce87b 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -8,6 +8,7 @@ task: memory: 16G env: INTEGRATION_TEST_PATH: "./packages/integration_test" + PLUGIN_TOOLS: "dart run ./script/tool/lib/src/main.dart" upgrade_script: - flutter channel stable - flutter upgrade @@ -16,6 +17,8 @@ task: - flutter channel master - flutter upgrade - git fetch origin master + - cd script/tool + - pub get matrix: - name: plugin_tools_tests script: @@ -26,12 +29,12 @@ task: script: - flutter channel master - if [[$BRANCH != "master"]];then - - CHANGED_PLUGINS=$(dart run ./script/tool/lib/src/main.dart get-changed-packages) + - CHANGED_PLUGINS=$($PLUGIN_TOOLS get-changed-packages) - echo "Running check-version on changed pacakges $CHANGED_PLUGINS" - - dart run ./script/tool/lib/src/main.dart check-version --plugins=$CHANGED_PLUGINS + - $PLUGIN_TOOLS check-version --plugins=$CHANGED_PLUGINS - else - echo "Running check-version on all packages" - - dart run ./script/tool/lib/src/main.dart check-version + - $PLUGIN_TOOLS check-version - fi - ./script/check_publish.sh - name: format From 87e97a632ad62e4f7acc7f18483b4a4aeb91f34b Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Mon, 8 Mar 2021 17:14:24 -0800 Subject: [PATCH 26/43] fix command name --- .cirrus.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.cirrus.yml b/.cirrus.yml index b8ef4e0ce87b..f892cc357f33 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -30,11 +30,11 @@ task: - flutter channel master - if [[$BRANCH != "master"]];then - CHANGED_PLUGINS=$($PLUGIN_TOOLS get-changed-packages) - - echo "Running check-version on changed pacakges $CHANGED_PLUGINS" - - $PLUGIN_TOOLS check-version --plugins=$CHANGED_PLUGINS + - echo "Running version-check on changed pacakges $CHANGED_PLUGINS" + - $PLUGIN_TOOLS version-check --plugins=$CHANGED_PLUGINS - else - - echo "Running check-version on all packages" - - $PLUGIN_TOOLS check-version + - echo "Running version-check on all packages" + - $PLUGIN_TOOLS version-check - fi - ./script/check_publish.sh - name: format From cdabfdcbfc9724456a27aeb357eb183dc071c336 Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Mon, 8 Mar 2021 22:38:43 -0800 Subject: [PATCH 27/43] get branch name --- .cirrus.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.cirrus.yml b/.cirrus.yml index f892cc357f33..9c64cd5e730d 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -9,6 +9,7 @@ task: env: INTEGRATION_TEST_PATH: "./packages/integration_test" PLUGIN_TOOLS: "dart run ./script/tool/lib/src/main.dart" + BRANCH: ${BRANCH_NAME:-"$(git rev-parse --abbrev-ref HEAD)"}" upgrade_script: - flutter channel stable - flutter upgrade From 680665ba9a4a705b60a77cfb6a99c85a2acfc465 Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Mon, 8 Mar 2021 22:39:01 -0800 Subject: [PATCH 28/43] rename to BRANCH --- .cirrus.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.cirrus.yml b/.cirrus.yml index 9c64cd5e730d..a521ee1a231d 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -9,7 +9,7 @@ task: env: INTEGRATION_TEST_PATH: "./packages/integration_test" PLUGIN_TOOLS: "dart run ./script/tool/lib/src/main.dart" - BRANCH: ${BRANCH_NAME:-"$(git rev-parse --abbrev-ref HEAD)"}" + BRANCH: ${BRANCH:-"$(git rev-parse --abbrev-ref HEAD)"}" upgrade_script: - flutter channel stable - flutter upgrade From 4ed9e7aac4280d2107c49dbe91555bc6e2fb029b Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Mon, 8 Mar 2021 23:29:11 -0800 Subject: [PATCH 29/43] fix typo --- .cirrus.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.cirrus.yml b/.cirrus.yml index a521ee1a231d..227b3d982457 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -9,7 +9,7 @@ task: env: INTEGRATION_TEST_PATH: "./packages/integration_test" PLUGIN_TOOLS: "dart run ./script/tool/lib/src/main.dart" - BRANCH: ${BRANCH:-"$(git rev-parse --abbrev-ref HEAD)"}" + BRANCH: “${BRANCH:-"$(git rev-parse --abbrev-ref HEAD)"}" upgrade_script: - flutter channel stable - flutter upgrade From 1ff63da4d2ca9c15e69872091208e2d9ad123ff4 Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Mon, 8 Mar 2021 23:47:37 -0800 Subject: [PATCH 30/43] fix typo --- .cirrus.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.cirrus.yml b/.cirrus.yml index 227b3d982457..2e65861b10e7 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -9,7 +9,7 @@ task: env: INTEGRATION_TEST_PATH: "./packages/integration_test" PLUGIN_TOOLS: "dart run ./script/tool/lib/src/main.dart" - BRANCH: “${BRANCH:-"$(git rev-parse --abbrev-ref HEAD)"}" + BRANCH: "${BRANCH:-"$(git rev-parse --abbrev-ref HEAD)"}" upgrade_script: - flutter channel stable - flutter upgrade @@ -29,6 +29,7 @@ task: - name: publishable script: - flutter channel master + - echo $BRANCH - if [[$BRANCH != "master"]];then - CHANGED_PLUGINS=$($PLUGIN_TOOLS get-changed-packages) - echo "Running version-check on changed pacakges $CHANGED_PLUGINS" From 6469c21df61ceb29dde426b1428d8f423cbddd08 Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Tue, 9 Mar 2021 12:29:35 -0800 Subject: [PATCH 31/43] add run-on-changed-packages option --- .cirrus.yml | 3 +- script/tool/lib/src/common.dart | 75 +++++++++- .../lib/src/get_changed_packages_command.dart | 78 ---------- .../tool/lib/src/lint_podspecs_command.dart | 2 +- script/tool/lib/src/main.dart | 4 +- .../tool/lib/src/version_check_command.dart | 31 +--- script/tool/test/common_test.dart | 137 +++++++++++++++++- .../get_changed_packages_command_test.dart | 116 --------------- script/tool/test/version_check_test.dart | 19 +-- 9 files changed, 226 insertions(+), 239 deletions(-) delete mode 100644 script/tool/lib/src/get_changed_packages_command.dart delete mode 100644 script/tool/test/get_changed_packages_command_test.dart diff --git a/.cirrus.yml b/.cirrus.yml index 2e65861b10e7..ff8d1b3e1d11 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -31,9 +31,8 @@ task: - flutter channel master - echo $BRANCH - if [[$BRANCH != "master"]];then - - CHANGED_PLUGINS=$($PLUGIN_TOOLS get-changed-packages) - echo "Running version-check on changed pacakges $CHANGED_PLUGINS" - - $PLUGIN_TOOLS version-check --plugins=$CHANGED_PLUGINS + - $PLUGIN_TOOLS version-check --run-on-changed-packages - else - echo "Running version-check on all packages" - $PLUGIN_TOOLS version-check diff --git a/script/tool/lib/src/common.dart b/script/tool/lib/src/common.dart index 77fa1088b696..436615924968 100644 --- a/script/tool/lib/src/common.dart +++ b/script/tool/lib/src/common.dart @@ -15,7 +15,7 @@ import 'package:path/path.dart' as p; import 'package:pub_semver/pub_semver.dart'; import 'package:yaml/yaml.dart'; -typedef void Print(Object object); +typedef Print = void Function(Object object); /// Key for windows platform. const String kWindows = 'windows'; @@ -163,6 +163,7 @@ abstract class PluginCommand extends Command { this.packagesDir, this.fileSystem, { this.processRunner = const ProcessRunner(), + this.gitDir, }) { argParser.addMultiOption( _pluginsArg, @@ -190,12 +191,23 @@ abstract class PluginCommand extends Command { help: 'Exclude packages from this command.', defaultsTo: [], ); + argParser.addFlag(_runOnChangedPackagesArg, + help: 'Run the command on changed packages/plugins.\n' + 'If the $_pluginsArg is specified, this flag is ignored.\n' + 'The packages excluded with $_excludeArg is also excluded even if changed.\n' + 'See $_kBaseSha if a custom base is needed to determine the diff.'); + argParser.addOption(_kBaseSha, + help: 'The base sha used to determine git diff. \n' + 'This is useful when $_runOnChangedPackagesArg is specified.\n' + 'If not specified, merge-base is used as base sha.'); } static const String _pluginsArg = 'plugins'; static const String _shardIndexArg = 'shardIndex'; static const String _shardCountArg = 'shardCount'; static const String _excludeArg = 'exclude'; + static const String _runOnChangedPackagesArg = 'run-on-changed-packages'; + static const String _kBaseSha = 'base-sha'; /// The directory containing the plugin packages. final Directory packagesDir; @@ -210,6 +222,11 @@ abstract class PluginCommand extends Command { /// This can be overridden for testing. final ProcessRunner processRunner; + /// The git directory to use. By default it uses the parent directory. + /// + /// This can be mocked for testing. + final GitDir gitDir; + int _shardIndex; int _shardCount; @@ -284,9 +301,13 @@ abstract class PluginCommand extends Command { /// "client library" package, which declares the API for the plugin, as /// well as one or more platform-specific implementations. Stream _getAllPlugins() async* { - final Set plugins = Set.from(argResults[_pluginsArg]); + Set plugins = Set.from(argResults[_pluginsArg]); final Set excludedPlugins = Set.from(argResults[_excludeArg]); + final bool runOnChangedPackages = argResults[_runOnChangedPackagesArg]; + if (plugins.isEmpty && runOnChangedPackages) { + plugins = await _getChangedPackages(); + } await for (FileSystemEntity entity in packagesDir.list(followLinks: false)) { @@ -374,6 +395,50 @@ abstract class PluginCommand extends Command { (FileSystemEntity entity) => isFlutterPackage(entity, fileSystem)) .cast(); } + + /// Retrieve an instance of [GitVersionFinder] based on `_kBaseSha` and [gitDir]. + /// + /// Throws tool exit if [gitDir] nor root directory is a git directory. + Future retrieveVersionFinder() async { + final String rootDir = packagesDir.parent.absolute.path; + String baseSha = argResults[_kBaseSha]; + + GitDir baseGitDir = gitDir; + if (baseGitDir == null) { + if (!await GitDir.isGitDir(rootDir)) { + PrintErrorAndExit( + errorMessage: '$rootDir is not a valid Git repository.', + exitCode: 2); + } + baseGitDir = await GitDir.fromExisting(rootDir); + } + + final GitVersionFinder gitVersionFinder = + GitVersionFinder(baseGitDir, baseSha); + return gitVersionFinder; + } + + Future> _getChangedPackages() async { + final GitVersionFinder gitVersionFinder = await retrieveVersionFinder(); + + final List allChangedFiles = + await gitVersionFinder.getChangedFiles(); + final Set packages = {}; + allChangedFiles.forEach((String path) { + final List pathComponents = path.split('/'); + final int packagesIndex = + pathComponents.indexWhere((String element) => element == 'packages'); + if (packagesIndex != -1) { + packages.add(pathComponents[packagesIndex + 1]); + } + }); + if (packages.isNotEmpty) { + final String changedPackages = packages.join(','); + print(changedPackages); + } + print('No changed packages.'); + return packages; + } } /// A class used to run processes. @@ -502,8 +567,10 @@ class GitVersionFinder { /// Get a list of all the changed files. Future> getChangedFiles() async { - final io.ProcessResult changedFilesCommand = await baseGitDir.runCommand( - ['diff', '--name-only', '${await _getBaseSha()}', 'HEAD']); + final String baseSha = await _getBaseSha(); + final io.ProcessResult changedFilesCommand = await baseGitDir + .runCommand(['diff', '--name-only', '$baseSha', 'HEAD']); + print('Determine diff with base sha: $baseSha'); if (changedFilesCommand.stdout.toString() == null || changedFilesCommand.stdout.toString().isEmpty) { return []; diff --git a/script/tool/lib/src/get_changed_packages_command.dart b/script/tool/lib/src/get_changed_packages_command.dart deleted file mode 100644 index 8fe88b04dcd6..000000000000 --- a/script/tool/lib/src/get_changed_packages_command.dart +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright 2017 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:async'; - -import 'package:file/file.dart'; -import 'package:git/git.dart'; - -import 'common.dart'; - -const String _kBaseSha = 'base_sha'; - -/// Get the changed packages based on base_sha. -/// -/// Outputs the final result in a comma separated format. -/// e.g. plugin1,plugin2... -class GetChangedPackagesCommand extends PluginCommand { - /// Constructor of the command. - /// - /// An optional `gitDir` can be specified if the `gitDir` used is not the top level dir. - GetChangedPackagesCommand( - Directory packagesDir, - FileSystem fileSystem, { - ProcessRunner processRunner = const ProcessRunner(), - this.gitDir, - }) : super(packagesDir, fileSystem, processRunner: processRunner) { - argParser.addOption(_kBaseSha); - } - - /// The git directory to use. By default it uses the parent directory. - /// - /// This can be mocked for testing. - final GitDir gitDir; - - @override - final String name = 'get-changed-packages'; - - @override - final String description = - 'Determines a list of changed packages based on the diff between base_sha and HEAD.\n' - 'The changed packages are returned through stdout and are separated by commas. (plugin1,plugin2..)'; - - @override - Future run() async { - checkSharding(); - - final String rootDir = packagesDir.parent.absolute.path; - String baseSha = argResults[_kBaseSha]; - - GitDir baseGitDir = gitDir; - if (baseGitDir == null) { - if (!await GitDir.isGitDir(rootDir)) { - print('$rootDir is not a valid Git repository.'); - throw ToolExit(2); - } - baseGitDir = await GitDir.fromExisting(rootDir); - } - - final GitVersionFinder gitVersionFinder = - GitVersionFinder(baseGitDir, baseSha); - - final List allChangedFiles = - await gitVersionFinder.getChangedFiles(); - final Set plugins = {}; - allChangedFiles.forEach((String path) { - final List pathComponents = path.split('/'); - final int packagesIndex = - pathComponents.indexWhere((String element) => element == 'packages'); - if (packagesIndex != -1) { - plugins.add(pathComponents[packagesIndex + 1]); - } - }); - if (plugins.isNotEmpty) { - print(plugins.join(',')); - } - } -} diff --git a/script/tool/lib/src/lint_podspecs_command.dart b/script/tool/lib/src/lint_podspecs_command.dart index 68fd4b61dd66..46ca9e4196e9 100644 --- a/script/tool/lib/src/lint_podspecs_command.dart +++ b/script/tool/lib/src/lint_podspecs_command.dart @@ -12,7 +12,7 @@ import 'package:platform/platform.dart'; import 'common.dart'; -typedef void Print(Object object); +typedef Print = void Function(Object object); /// Lint the CocoaPod podspecs, run the static analyzer on iOS/macOS plugin /// platform code, and run unit tests. diff --git a/script/tool/lib/src/main.dart b/script/tool/lib/src/main.dart index 8043ddcbbaa9..fa81597237d7 100644 --- a/script/tool/lib/src/main.dart +++ b/script/tool/lib/src/main.dart @@ -17,7 +17,6 @@ import 'common.dart'; import 'create_all_plugins_app_command.dart'; import 'drive_examples_command.dart'; import 'firebase_test_lab_command.dart'; -import 'get_changed_packages_command.dart'; import 'format_command.dart'; import 'java_test_command.dart'; import 'lint_podspecs_command.dart'; @@ -57,8 +56,7 @@ void main(List args) { ..addCommand(PublishPluginCommand(packagesDir, fileSystem)) ..addCommand(TestCommand(packagesDir, fileSystem)) ..addCommand(VersionCheckCommand(packagesDir, fileSystem)) - ..addCommand(XCTestCommand(packagesDir, fileSystem)) - ..addCommand(GetChangedPackagesCommand(packagesDir, fileSystem)); + ..addCommand(XCTestCommand(packagesDir, fileSystem)); commandRunner.run(args).catchError((Object e) { final ToolExit toolExit = e; diff --git a/script/tool/lib/src/version_check_command.dart b/script/tool/lib/src/version_check_command.dart index e6c29477ab94..e281bd648c63 100644 --- a/script/tool/lib/src/version_check_command.dart +++ b/script/tool/lib/src/version_check_command.dart @@ -13,7 +13,7 @@ import 'package:pubspec_parse/pubspec_parse.dart'; import 'common.dart'; -const String _kBaseSha = 'base_sha'; +const String _kBaseSha = 'base-sha'; enum NextVersionType { BREAKING_MAJOR, @@ -99,15 +99,9 @@ class VersionCheckCommand extends PluginCommand { Directory packagesDir, FileSystem fileSystem, { ProcessRunner processRunner = const ProcessRunner(), - this.gitDir, - }) : super(packagesDir, fileSystem, processRunner: processRunner) { - argParser.addOption(_kBaseSha); - } - - /// The git directory to use. By default it uses the parent directory. - /// - /// This can be mocked for testing. - final GitDir gitDir; + GitDir gitDir, + }) : super(packagesDir, fileSystem, + processRunner: processRunner, gitDir: gitDir); @override final String name = 'version-check'; @@ -121,25 +115,12 @@ class VersionCheckCommand extends PluginCommand { @override Future run() async { checkSharding(); - - final String rootDir = packagesDir.parent.absolute.path; - final String baseSha = argResults[_kBaseSha]; - - GitDir baseGitDir = gitDir; - if (baseGitDir == null) { - if (!await GitDir.isGitDir(rootDir)) { - print('$rootDir is not a valid Git repository.'); - throw ToolExit(2); - } - baseGitDir = await GitDir.fromExisting(rootDir); - } - - final GitVersionFinder gitVersionFinder = - GitVersionFinder(baseGitDir, baseSha); + final GitVersionFinder gitVersionFinder = await retrieveVersionFinder(); final List changedPubspecs = await gitVersionFinder.getChangedPubSpecs(); + final String baseSha = argResults[_kBaseSha]; for (final String pubspecPath in changedPubspecs) { try { final File pubspecFile = fileSystem.file(pubspecPath); diff --git a/script/tool/test/common_test.dart b/script/tool/test/common_test.dart index 6a58e4a06acd..0fb3ce74c373 100644 --- a/script/tool/test/common_test.dart +++ b/script/tool/test/common_test.dart @@ -13,8 +13,21 @@ void main() { RecordingProcessRunner processRunner; CommandRunner runner; List plugins; + List> gitDirCommands; + String gitDiffResponse; setUp(() { + gitDirCommands = >[]; + gitDiffResponse = ''; + final MockGitDir gitDir = MockGitDir(); + when(gitDir.runCommand(any)).thenAnswer((Invocation invocation) { + gitDirCommands.add(invocation.positionalArguments[0]); + final MockProcessResult mockProcessResult = MockProcessResult(); + if (invocation.positionalArguments[0][0] == 'diff') { + when(mockProcessResult.stdout).thenReturn(gitDiffResponse); + } + return Future.value(mockProcessResult); + }); initializeFakePackages(); processRunner = RecordingProcessRunner(); plugins = []; @@ -23,6 +36,7 @@ void main() { mockPackagesDir, mockFileSystem, processRunner: processRunner, + gitDir: gitDir, ); runner = CommandRunner('common_command', 'Test for common functionality'); @@ -78,6 +92,125 @@ void main() { expect(plugins, unorderedEquals([plugin2.path])); }); + group('test run-on-changed-packages', () { + test('all plugins should be tested if there are no changes.', () async { + final Directory plugin1 = createFakePlugin('plugin1'); + final Directory plugin2 = createFakePlugin('plugin2'); + await runner.run( + ['sample', '--base-sha=master', '--run-on-changed-packages']); + + expect(plugins, unorderedEquals([plugin1.path, plugin2.path])); + }); + + test('all plugins should be tested if there are no plugin related changes.', + () async { + gitDiffResponse = ".cirrus"; + final Directory plugin1 = createFakePlugin('plugin1'); + final Directory plugin2 = createFakePlugin('plugin2'); + await runner.run( + ['sample', '--base-sha=master', '--run-on-changed-packages']); + + expect(plugins, unorderedEquals([plugin1.path, plugin2.path])); + }); + + test('Only changed plugin should be tested.', () async { + gitDiffResponse = "packages/plugin1/plugin1.dart"; + final Directory plugin1 = createFakePlugin('plugin1'); + createFakePlugin('plugin2'); + await runner.run( + ['sample', '--base-sha=master', '--run-on-changed-packages']); + + expect(plugins, unorderedEquals([plugin1.path])); + }); + + test('multiple files in one plugin should also test the plugin', () async { + gitDiffResponse = ''' +packages/plugin1/plugin1.dart +packages/plugin1/ios/plugin1.m +'''; + final Directory plugin1 = createFakePlugin('plugin1'); + createFakePlugin('plugin2'); + await runner.run( + ['sample', '--base-sha=master', '--run-on-changed-packages']); + + expect(plugins, unorderedEquals([plugin1.path])); + }); + + test('multiple plugins changed should test all the changed plugins', + () async { + gitDiffResponse = ''' +packages/plugin1/plugin1.dart +packages/plugin2/ios/plugin2.m +'''; + final Directory plugin1 = createFakePlugin('plugin1'); + final Directory plugin2 = createFakePlugin('plugin2'); + createFakePlugin('plugin3'); + await runner.run( + ['sample', '--base-sha=master', '--run-on-changed-packages']); + + expect(plugins, unorderedEquals([plugin1.path, plugin2.path])); + }); + + test( + 'multiple plugins inside the same plugin group changed should output the plugin group name', + () async { + gitDiffResponse = ''' +packages/plugin1/plugin1/plugin1.dart +packages/plugin1/plugin1_platform_interface/plugin1_platform_interface.dart +packages/plugin1/plugin1_web/plugin1_web.dart +'''; + final Directory plugin1 = + createFakePlugin('plugin1', parentDirectoryName: 'plugin1'); + createFakePlugin('plugin2'); + createFakePlugin('plugin3'); + await runner.run( + ['sample', '--base-sha=master', '--run-on-changed-packages']); + + expect(plugins, unorderedEquals([plugin1.path])); + }); + + test('--plugins flag overrides the behavior of --run-on-changed-packages', + () async { + gitDiffResponse = ''' +packages/plugin1/plugin1.dart +packages/plugin2/ios/plugin2.m +packages/plugin3/plugin3.dart +'''; + final Directory plugin1 = + createFakePlugin('plugin1', parentDirectoryName: 'plugin1'); + final Directory plugin2 = createFakePlugin('plugin2'); + createFakePlugin('plugin3'); + await runner.run([ + 'sample', + '--plugins=plugin1,plugin2', + '--base-sha=master', + '--run-on-changed-packages' + ]); + + expect(plugins, unorderedEquals([plugin1.path, plugin2.path])); + }); + + test('--exclude flag works with --run-on-changed-packages', () async { + gitDiffResponse = ''' +packages/plugin1/plugin1.dart +packages/plugin2/ios/plugin2.m +packages/plugin3/plugin3.dart +'''; + final Directory plugin1 = + createFakePlugin('plugin1', parentDirectoryName: 'plugin1'); + createFakePlugin('plugin2'); + createFakePlugin('plugin3'); + await runner.run([ + 'sample', + '--exclude=plugin2,plugin3', + '--base-sha=master', + '--run-on-changed-packages' + ]); + + expect(plugins, unorderedEquals([plugin1.path])); + }); + }); + group('$GitVersionFinder', () { List> gitDirCommands; String gitDiffResponse; @@ -167,7 +300,9 @@ class SamplePluginCommand extends PluginCommand { Directory packagesDir, FileSystem fileSystem, { ProcessRunner processRunner = const ProcessRunner(), - }) : super(packagesDir, fileSystem, processRunner: processRunner); + GitDir gitDir, + }) : super(packagesDir, fileSystem, + processRunner: processRunner, gitDir: gitDir); List plugins_; diff --git a/script/tool/test/get_changed_packages_command_test.dart b/script/tool/test/get_changed_packages_command_test.dart deleted file mode 100644 index 4c60f02a5416..000000000000 --- a/script/tool/test/get_changed_packages_command_test.dart +++ /dev/null @@ -1,116 +0,0 @@ -// Copyright 2017 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:async'; -import 'dart:io'; - -import 'package:args/command_runner.dart'; -import 'package:git/git.dart'; -import 'package:mockito/mockito.dart'; -import "package:test/test.dart"; -import "package:flutter_plugin_tools/src/get_changed_packages_command.dart"; -import 'util.dart'; - -class MockGitDir extends Mock implements GitDir {} - -class MockProcessResult extends Mock implements ProcessResult {} - -void main() { - group('$GetChangedPackagesCommand', () { - CommandRunner runner; - RecordingProcessRunner processRunner; - List> gitDirCommands; - String gitDiffResponse; - - setUp(() { - gitDirCommands = >[]; - gitDiffResponse = ''; - final MockGitDir gitDir = MockGitDir(); - when(gitDir.runCommand(any)).thenAnswer((Invocation invocation) { - gitDirCommands.add(invocation.positionalArguments[0]); - final MockProcessResult mockProcessResult = MockProcessResult(); - if (invocation.positionalArguments[0][0] == 'diff') { - when(mockProcessResult.stdout).thenReturn(gitDiffResponse); - } - return Future.value(mockProcessResult); - }); - initializeFakePackages(); - processRunner = RecordingProcessRunner(); - final GetChangedPackagesCommand command = GetChangedPackagesCommand( - mockPackagesDir, mockFileSystem, - processRunner: processRunner, gitDir: gitDir); - - runner = CommandRunner('get_changed_packages_command', - 'Test for $GetChangedPackagesCommand'); - runner.addCommand(command); - }); - - tearDown(() { - cleanupPackages(); - }); - - test('No files changed should have empty output', () async { - final List output = await runCapturingPrint( - runner, ['get-changed-packages', '--base_sha=master']); - - expect(output, isEmpty); - }); - - test('Some none plugin files changed have empty output', () async { - gitDiffResponse = ".cirrus"; - final List output = await runCapturingPrint( - runner, ['get-changed-packages', '--base_sha=master']); - - expect(output, isEmpty); - }); - - test('plugin code changed should output the plugin', () async { - gitDiffResponse = "packages/plugin1/plugin1.dart"; - final List output = await runCapturingPrint( - runner, ['get-changed-packages', '--base_sha=master']); - - expect(output, equals(['plugin1'])); - }); - - test( - 'multiple files in one plugin changed should output the same plugin once', - () async { - gitDiffResponse = ''' -packages/plugin1/plugin1.dart -packages/plugin1/ios/plugin1.m -'''; - final List output = await runCapturingPrint( - runner, ['get-changed-packages', '--base_sha=master']); - - expect(output, equals(['plugin1'])); - }); - - test( - 'multiple plugins changed should output those plugins with , separated', - () async { - gitDiffResponse = ''' -packages/plugin1/plugin1.dart -packages/plugin2/ios/plugin1.m -'''; - final List output = await runCapturingPrint( - runner, ['get-changed-packages', '--base_sha=master']); - - expect(output, equals(['plugin1,plugin2'])); - }); - - test( - 'multiple plugins inside the same plugin group changed should output the plugin group name', - () async { - gitDiffResponse = ''' -packages/plugin1/plugin1/plugin1.dart -packages/plugin1/plugin1_platform_interface/plugin1_platform_interface.dart -packages/plugin1/plugin1_web/plugin1_web.dart -'''; - final List output = await runCapturingPrint( - runner, ['get-changed-packages', '--base_sha=master']); - - expect(output, equals(['plugin1'])); - }); - }); -} diff --git a/script/tool/test/version_check_test.dart b/script/tool/test/version_check_test.dart index 48a96bbb60fa..ac0d378c2a26 100644 --- a/script/tool/test/version_check_test.dart +++ b/script/tool/test/version_check_test.dart @@ -82,7 +82,7 @@ void main() { 'HEAD:packages/plugin/pubspec.yaml': 'version: 2.0.0', }; final List output = await runCapturingPrint( - runner, ['version-check', '--base_sha=master']); + runner, ['version-check', '--base-sha=master']); expect( output, @@ -107,7 +107,7 @@ void main() { 'HEAD:packages/plugin/pubspec.yaml': 'version: 0.2.0', }; final Future> result = runCapturingPrint( - runner, ['version-check', '--base_sha=master']); + runner, ['version-check', '--base-sha=master']); await expectLater( result, @@ -131,11 +131,12 @@ void main() { .childFile('pubspec.yaml') .deleteSync(); final List output = await runCapturingPrint( - runner, ['version-check', '--base_sha=master']); + runner, ['version-check', '--base-sha=master']); expect( output, orderedEquals([ + 'Determine diff with base sha: master', 'No version check errors found!', ]), ); @@ -155,7 +156,7 @@ void main() { 'version: 1.1.0', }; final List output = await runCapturingPrint( - runner, ['version-check', '--base_sha=master']); + runner, ['version-check', '--base-sha=master']); expect( output, containsAllInOrder([ @@ -184,7 +185,7 @@ void main() { 'version: 2.0.0', }; final Future> output = runCapturingPrint( - runner, ['version-check', '--base_sha=master']); + runner, ['version-check', '--base-sha=master']); await expectLater( output, throwsA(const TypeMatcher()), @@ -219,7 +220,7 @@ void main() { '''; createFakeCHANGELOG(pluginDirectory, changelog); final List output = await runCapturingPrint( - runner, ['version-check', '--base_sha=master']); + runner, ['version-check', '--base-sha=master']); await expect( output, containsAllInOrder([ @@ -245,7 +246,7 @@ void main() { '''; createFakeCHANGELOG(pluginDirectory, changelog); final Future> output = runCapturingPrint( - runner, ['version-check', '--base_sha=master']); + runner, ['version-check', '--base-sha=master']); await expectLater( output, throwsA(const TypeMatcher()), @@ -280,7 +281,7 @@ void main() { '''; createFakeCHANGELOG(pluginDirectory, changelog); final List output = await runCapturingPrint( - runner, ['version-check', '--base_sha=master']); + runner, ['version-check', '--base-sha=master']); await expect( output, containsAllInOrder([ @@ -312,7 +313,7 @@ void main() { '''; createFakeCHANGELOG(pluginDirectory, changelog); Future> output = runCapturingPrint( - runner, ['version-check', '--base_sha=master']); + runner, ['version-check', '--base-sha=master']); await expectLater( output, throwsA(const TypeMatcher()), From 19253b65689723cec87ec6a998b11cd2ba51759e Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Tue, 9 Mar 2021 12:31:58 -0800 Subject: [PATCH 32/43] fix cirrus --- .cirrus.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.cirrus.yml b/.cirrus.yml index ff8d1b3e1d11..fdac4472915d 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -9,7 +9,7 @@ task: env: INTEGRATION_TEST_PATH: "./packages/integration_test" PLUGIN_TOOLS: "dart run ./script/tool/lib/src/main.dart" - BRANCH: "${BRANCH:-"$(git rev-parse --abbrev-ref HEAD)"}" + BRANCH: "${BRANCH:-'$(git rev-parse --abbrev-ref HEAD)'}" upgrade_script: - flutter channel stable - flutter upgrade From 6c47afa1c829fa5940913da117cd54c516130fe9 Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Tue, 9 Mar 2021 12:32:52 -0800 Subject: [PATCH 33/43] fix typo --- .cirrus.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.cirrus.yml b/.cirrus.yml index fdac4472915d..e98eded66704 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -31,7 +31,7 @@ task: - flutter channel master - echo $BRANCH - if [[$BRANCH != "master"]];then - - echo "Running version-check on changed pacakges $CHANGED_PLUGINS" + - echo "Running version-check on changed pacakges" - $PLUGIN_TOOLS version-check --run-on-changed-packages - else - echo "Running version-check on all packages" From 0bd32d285356053d56d35fa5ec14ef402b8e3bdd Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Tue, 9 Mar 2021 12:35:15 -0800 Subject: [PATCH 34/43] revert unwanted changes --- script/tool/lib/src/common.dart | 2 +- script/tool/lib/src/lint_podspecs_command.dart | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/script/tool/lib/src/common.dart b/script/tool/lib/src/common.dart index 436615924968..7884a9a6e183 100644 --- a/script/tool/lib/src/common.dart +++ b/script/tool/lib/src/common.dart @@ -15,7 +15,7 @@ import 'package:path/path.dart' as p; import 'package:pub_semver/pub_semver.dart'; import 'package:yaml/yaml.dart'; -typedef Print = void Function(Object object); +typedef void Print(Object object); /// Key for windows platform. const String kWindows = 'windows'; diff --git a/script/tool/lib/src/lint_podspecs_command.dart b/script/tool/lib/src/lint_podspecs_command.dart index 46ca9e4196e9..68fd4b61dd66 100644 --- a/script/tool/lib/src/lint_podspecs_command.dart +++ b/script/tool/lib/src/lint_podspecs_command.dart @@ -12,7 +12,7 @@ import 'package:platform/platform.dart'; import 'common.dart'; -typedef Print = void Function(Object object); +typedef void Print(Object object); /// Lint the CocoaPod podspecs, run the static analyzer on iOS/macOS plugin /// platform code, and run unit tests. From 02de4273c3db39ee95ab4a973fb5eed0df787ab3 Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Tue, 9 Mar 2021 13:01:14 -0800 Subject: [PATCH 35/43] set branch --- .cirrus.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.cirrus.yml b/.cirrus.yml index e98eded66704..762214bc4d36 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -9,7 +9,6 @@ task: env: INTEGRATION_TEST_PATH: "./packages/integration_test" PLUGIN_TOOLS: "dart run ./script/tool/lib/src/main.dart" - BRANCH: "${BRANCH:-'$(git rev-parse --abbrev-ref HEAD)'}" upgrade_script: - flutter channel stable - flutter upgrade @@ -29,7 +28,7 @@ task: - name: publishable script: - flutter channel master - - echo $BRANCH + - BRANCH=${BRANCH:-'$(git rev-parse --abbrev-ref HEAD)'} - if [[$BRANCH != "master"]];then - echo "Running version-check on changed pacakges" - $PLUGIN_TOOLS version-check --run-on-changed-packages From f1314f6904bfd02d34526ecb7cd41cd06648f720 Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Tue, 9 Mar 2021 13:09:34 -0800 Subject: [PATCH 36/43] add export --- .cirrus.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.cirrus.yml b/.cirrus.yml index 762214bc4d36..d7bdaf471c70 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -28,7 +28,7 @@ task: - name: publishable script: - flutter channel master - - BRANCH=${BRANCH:-'$(git rev-parse --abbrev-ref HEAD)'} + - export BRANCH=${BRANCH:-'$(git rev-parse --abbrev-ref HEAD)'} - if [[$BRANCH != "master"]];then - echo "Running version-check on changed pacakges" - $PLUGIN_TOOLS version-check --run-on-changed-packages From e2c3a8e724ca0d8758e7ac06cd7673d29da07b60 Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Tue, 9 Mar 2021 15:49:32 -0800 Subject: [PATCH 37/43] review --- .cirrus.yml | 12 ++++------ script/tool/lib/src/common.dart | 13 +++++------ .../tool/lib/src/version_check_command.dart | 23 ++++++++----------- 3 files changed, 21 insertions(+), 27 deletions(-) diff --git a/.cirrus.yml b/.cirrus.yml index d7bdaf471c70..b4c1518aeef3 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -22,19 +22,17 @@ task: matrix: - name: plugin_tools_tests script: - - cd script/tool - - pub get - CIRRUS_BUILD_ID=null pub run test - name: publishable script: + - BRANCH_NAME="$(git rev-parse --abbrev-ref HEAD)" - flutter channel master - - export BRANCH=${BRANCH:-'$(git rev-parse --abbrev-ref HEAD)'} - - if [[$BRANCH != "master"]];then - - echo "Running version-check on changed pacakges" - - $PLUGIN_TOOLS version-check --run-on-changed-packages - - else + - if [[ "$BRANCH_NAME" -eq "master" ]]; then - echo "Running version-check on all packages" - $PLUGIN_TOOLS version-check + - else + - echo "Running version-check on changed pacakges" + - $PLUGIN_TOOLS version-check --run-on-changed-packages - fi - ./script/check_publish.sh - name: format diff --git a/script/tool/lib/src/common.dart b/script/tool/lib/src/common.dart index 7884a9a6e183..ce4f37873b07 100644 --- a/script/tool/lib/src/common.dart +++ b/script/tool/lib/src/common.dart @@ -145,7 +145,7 @@ bool isLinuxPlugin(FileSystemEntity entity, FileSystem fileSystem) { } /// Throws a [ToolExit] with `exitCode` and log the `errorMessage` in red. -void PrintErrorAndExit({@required String errorMessage, int exitCode = 1}) { +void printErrorAndExit({@required String errorMessage, int exitCode = 1}) { final Colorize redError = Colorize(errorMessage)..red(); print(redError); throw ToolExit(exitCode); @@ -406,7 +406,7 @@ abstract class PluginCommand extends Command { GitDir baseGitDir = gitDir; if (baseGitDir == null) { if (!await GitDir.isGitDir(rootDir)) { - PrintErrorAndExit( + printErrorAndExit( errorMessage: '$rootDir is not a valid Git repository.', exitCode: 2); } @@ -571,12 +571,11 @@ class GitVersionFinder { final io.ProcessResult changedFilesCommand = await baseGitDir .runCommand(['diff', '--name-only', '$baseSha', 'HEAD']); print('Determine diff with base sha: $baseSha'); - if (changedFilesCommand.stdout.toString() == null || - changedFilesCommand.stdout.toString().isEmpty) { + final String changedFilesStdout = changedFilesCommand.stdout.toString() ?? ''; + if (changedFilesStdout.isEmpty) { return []; } - final List changedFiles = changedFilesCommand.stdout - .toString() + final List changedFiles = changedFilesStdout .split('\n') ..removeWhere((element) => element.isEmpty); return changedFiles.toList(); @@ -605,6 +604,6 @@ class GitVersionFinder { baseShaFromMergeBase = await baseGitDir .runCommand(['merge-base', 'FETCH_HEAD', 'HEAD']); } - return (baseShaFromMergeBase.stdout as String).replaceAll('\n', ''); + return (baseShaFromMergeBase.stdout as String).trim(); } } diff --git a/script/tool/lib/src/version_check_command.dart b/script/tool/lib/src/version_check_command.dart index e281bd648c63..111239f0399a 100644 --- a/script/tool/lib/src/version_check_command.dart +++ b/script/tool/lib/src/version_check_command.dart @@ -109,7 +109,7 @@ class VersionCheckCommand extends PluginCommand { @override final String description = 'Checks if the versions of the plugins have been incremented per pub specification.\n' - 'Also checks if the version in CHANGELOG matches the version in pubspec.\n\n' + 'Also checks if the latest version in CHANGELOG matches the version in pubspec.\n\n' 'This command requires "pub" and "flutter" to be in your path.'; @override @@ -147,7 +147,7 @@ class VersionCheckCommand extends PluginCommand { final String error = '$pubspecPath incorrectly updated version.\n' 'HEAD: $headVersion, master: $masterVersion.\n' 'Allowed versions: $allowedNextVersions'; - PrintErrorAndExit(errorMessage: error); + printErrorAndExit(errorMessage: error); } bool isPlatformInterface = pubspec.name.endsWith("_platform_interface"); @@ -156,7 +156,7 @@ class VersionCheckCommand extends PluginCommand { NextVersionType.BREAKING_MAJOR) { final String error = '$pubspecPath breaking change detected.\n' 'Breaking changes to platform interfaces are strongly discouraged.\n'; - PrintErrorAndExit(errorMessage: error); + printErrorAndExit(errorMessage: error); } } on io.ProcessException { print('Unable to find pubspec in master for $pubspecPath.' @@ -181,7 +181,7 @@ class VersionCheckCommand extends PluginCommand { final Pubspec pubspec = _tryParsePubspec(plugin); if (pubspec == null) { final String error = 'Cannot parse version from pubspec.yaml'; - PrintErrorAndExit(errorMessage: error); + printErrorAndExit(errorMessage: error); } final Version fromPubspec = pubspec.version; @@ -191,10 +191,7 @@ class VersionCheckCommand extends PluginCommand { String firstLineWithText; final Iterator iterator = lines.iterator; while (iterator.moveNext()) { - final String currentStriptEmptySpaces = - (iterator.current as String).replaceAll(' ', ''); - if (currentStriptEmptySpaces != null && - currentStriptEmptySpaces.isNotEmpty) { + if ((iterator.current as String).trim().isNotEmpty) { firstLineWithText = iterator.current; break; } @@ -204,8 +201,8 @@ class VersionCheckCommand extends PluginCommand { Version fromChangeLog = Version.parse(versionString); if (fromChangeLog == null) { final String error = - 'Cannot find version on the first line of CHANGELOG.md'; - PrintErrorAndExit(errorMessage: error); + 'Cannot find version on the first line of ${plugin.path}/CHANGELOG.md'; + printErrorAndExit(errorMessage: error); } if (fromPubspec != fromChangeLog) { @@ -214,7 +211,7 @@ versions for $packageName in CHANGELOG.md and pubspec.yaml do not match. The version in pubspec.yaml is $fromPubspec. The first version listed in CHANGELOG.md is $fromChangeLog. '''; - PrintErrorAndExit(errorMessage: error); + printErrorAndExit(errorMessage: error); } print('${packageName} passed version check'); } @@ -227,13 +224,13 @@ The first version listed in CHANGELOG.md is $fromChangeLog. if (pubspec == null) { final String error = 'Failed to parse `pubspec.yaml` at ${pubspecFile.path}'; - PrintErrorAndExit(errorMessage: error); + printErrorAndExit(errorMessage: error); } return pubspec; } on Exception catch (exception) { final String error = 'Failed to parse `pubspec.yaml` at ${pubspecFile.path}: $exception}'; - PrintErrorAndExit(errorMessage: error); + printErrorAndExit(errorMessage: error); } return null; } From 7ece242b87cba3bb36b41b6731fa585b3ea927ae Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Tue, 9 Mar 2021 16:12:07 -0800 Subject: [PATCH 38/43] fix directory --- .cirrus.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.cirrus.yml b/.cirrus.yml index b4c1518aeef3..16d4eccb3204 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -22,6 +22,7 @@ task: matrix: - name: plugin_tools_tests script: + - cd script/tool - CIRRUS_BUILD_ID=null pub run test - name: publishable script: From 6cd6f8499f1e2ab547169f5b598c779b1a3ef011 Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Tue, 9 Mar 2021 16:39:41 -0800 Subject: [PATCH 39/43] use cirrus branch --- .cirrus.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.cirrus.yml b/.cirrus.yml index 16d4eccb3204..6ec36095f1ce 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -26,9 +26,8 @@ task: - CIRRUS_BUILD_ID=null pub run test - name: publishable script: - - BRANCH_NAME="$(git rev-parse --abbrev-ref HEAD)" - flutter channel master - - if [[ "$BRANCH_NAME" -eq "master" ]]; then + - if [[ "$CIRRUS_BRANCH" == "master" ]]; then - echo "Running version-check on all packages" - $PLUGIN_TOOLS version-check - else From bc83daff129b18feb5d6f3c98edacf1155493757 Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Tue, 9 Mar 2021 16:47:59 -0800 Subject: [PATCH 40/43] remove testing echo --- .cirrus.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.cirrus.yml b/.cirrus.yml index 6ec36095f1ce..c1763a665345 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -28,10 +28,8 @@ task: script: - flutter channel master - if [[ "$CIRRUS_BRANCH" == "master" ]]; then - - echo "Running version-check on all packages" - $PLUGIN_TOOLS version-check - else - - echo "Running version-check on changed pacakges" - $PLUGIN_TOOLS version-check --run-on-changed-packages - fi - ./script/check_publish.sh From 9cfc0b95cebd7e78551c79744d23251cd408568d Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Wed, 10 Mar 2021 11:04:54 -0800 Subject: [PATCH 41/43] revert device_info change --- packages/device_info/device_info/example/lib/main.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/device_info/device_info/example/lib/main.dart b/packages/device_info/device_info/example/lib/main.dart index e5d8d6408649..805de1417f15 100644 --- a/packages/device_info/device_info/example/lib/main.dart +++ b/packages/device_info/device_info/example/lib/main.dart @@ -4,7 +4,6 @@ // ignore_for_file: public_member_api_docs - import 'dart:async'; import 'dart:io'; From 1ff004663abc4a04324c2006b8a9fa6e8c719a35 Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Wed, 10 Mar 2021 13:11:06 -0800 Subject: [PATCH 42/43] fix merge error --- .cirrus.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.cirrus.yml b/.cirrus.yml index ef85ebf2f11a..0e103a09a121 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -6,6 +6,7 @@ root_task_template: &ROOT_TASK_TEMPLATE env: INTEGRATION_TEST_PATH: "./packages/integration_test" CHANNEL: "master" # Default to master when not explicitly set by a task. + PLUGIN_TOOLS: "dart run ./script/tool/lib/src/main.dart" setup_script: - flutter channel $CHANNEL - flutter upgrade From fa5240e5785eb2bea87d76f49b453a388e4ad6cd Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Wed, 10 Mar 2021 13:12:24 -0800 Subject: [PATCH 43/43] remove unnecessary channel swtich --- .cirrus.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.cirrus.yml b/.cirrus.yml index 0e103a09a121..8f61fabc4f2a 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -30,7 +30,6 @@ task: - CIRRUS_BUILD_ID=null pub run test - name: publishable script: - - flutter channel master - if [[ "$CIRRUS_BRANCH" == "master" ]]; then - $PLUGIN_TOOLS version-check - else