Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

[ci] Run analyze with minimum resolved packages #6207

Merged
merged 4 commits into from
Aug 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,14 @@ task:
# Only analyze lib/; non-client code doesn't need to work on
# all supported legacy version.
- ./script/tool_runner.sh analyze --lib-only --skip-if-not-supporting-flutter-version="$CHANNEL" --custom-analysis=script/configs/custom_analysis.yaml
# Does a sanity check that plugins pass analysis with the lowest possible
# versions of all dependencies. This is to catch cases where we add use of
# new APIs but forget to update minimum versions of dependencies to when
# those APIs are introduced.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome! This check seems useful.

- name: downgraded_analyze
depends_on: analyze
analyze_script:
- ./script/tool_runner.sh analyze --downgrade
- name: readme_excerpts
env:
CIRRUS_CLONE_SUBMODULES: true
Expand Down
5 changes: 5 additions & 0 deletions packages/image_picker/image_picker_android/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 0.8.5+2

* Updates `image_picker_platform_interface` constraint to the correct minimum
version.

## 0.8.5+1

* Switches to an internal method channel implementation.
Expand Down
4 changes: 2 additions & 2 deletions packages/image_picker/image_picker_android/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: image_picker_android
description: Android implementation of the image_picker plugin.
repository: https://github.com/flutter/plugins/tree/main/packages/image_picker/image_picker_android
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+image_picker%22
version: 0.8.5+1
version: 0.8.5+2

environment:
sdk: ">=2.14.0 <3.0.0"
Expand All @@ -21,7 +21,7 @@ dependencies:
flutter:
sdk: flutter
flutter_plugin_android_lifecycle: ^2.0.1
image_picker_platform_interface: ^2.3.0
image_picker_platform_interface: ^2.5.0

dev_dependencies:
flutter_test:
Expand Down
5 changes: 5 additions & 0 deletions packages/local_auth/local_auth_android/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 1.0.10

* Updates `local_auth_platform_interface` constraint to the correct minimum
version.

## 1.0.9

* Updates androidx.fragment version to 1.5.1.
Expand Down
4 changes: 2 additions & 2 deletions packages/local_auth/local_auth_android/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: local_auth_android
description: Android implementation of the local_auth plugin.
repository: https://github.com/flutter/plugins/tree/main/packages/local_auth/local_auth_android
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+local_auth%22
version: 1.0.9
version: 1.0.10

environment:
sdk: ">=2.14.0 <3.0.0"
Expand All @@ -22,7 +22,7 @@ dependencies:
sdk: flutter
flutter_plugin_android_lifecycle: ^2.0.1
intl: ^0.17.0
local_auth_platform_interface: ^1.0.0
local_auth_platform_interface: ^1.0.1

dev_dependencies:
flutter_test:
Expand Down
5 changes: 5 additions & 0 deletions packages/local_auth/local_auth_ios/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 1.0.8

* Updates `local_auth_platform_interface` constraint to the correct minimum
version.

## 1.0.7

* Updates references to the obsolete master branch.
Expand Down
4 changes: 2 additions & 2 deletions packages/local_auth/local_auth_ios/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: local_auth_ios
description: iOS implementation of the local_auth plugin.
repository: https://github.com/flutter/plugins/tree/main/packages/local_auth/local_auth_ios
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+local_auth%22
version: 1.0.7
version: 1.0.8

environment:
sdk: ">=2.14.0 <3.0.0"
Expand All @@ -20,7 +20,7 @@ dependencies:
flutter:
sdk: flutter
intl: ^0.17.0
local_auth_platform_interface: ^1.0.0
local_auth_platform_interface: ^1.0.1

dev_dependencies:
flutter_test:
Expand Down
5 changes: 5 additions & 0 deletions packages/local_auth/local_auth_windows/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 1.0.2

* Updates `local_auth_platform_interface` constraint to the correct minimum
version.

## 1.0.1

* Updates references to the obsolete master branch.
Expand Down
4 changes: 2 additions & 2 deletions packages/local_auth/local_auth_windows/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: local_auth_windows
description: Windows implementation of the local_auth plugin.
repository: https://github.com/flutter/plugins/tree/main/packages/local_auth/local_auth_windows
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+local_auth%22
version: 1.0.1
version: 1.0.2

environment:
sdk: ">=2.14.0 <3.0.0"
Expand All @@ -19,7 +19,7 @@ flutter:
dependencies:
flutter:
sdk: flutter
local_auth_platform_interface: ^1.0.0
local_auth_platform_interface: ^1.0.1

dev_dependencies:
flutter_test:
Expand Down
5 changes: 5 additions & 0 deletions packages/url_launcher/url_launcher_web/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 2.0.13

* Updates `url_launcher_platform_interface` constraint to the correct minimum
version.

## 2.0.12

* Fixes call to `setState` after dispose on the `Link` widget.
Expand Down
4 changes: 2 additions & 2 deletions packages/url_launcher/url_launcher_web/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: url_launcher_web
description: Web platform implementation of url_launcher
repository: https://github.com/flutter/plugins/tree/main/packages/url_launcher/url_launcher_web
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+url_launcher%22
version: 2.0.12
version: 2.0.13

environment:
sdk: ">=2.12.0 <3.0.0"
Expand All @@ -21,7 +21,7 @@ dependencies:
sdk: flutter
flutter_web_plugins:
sdk: flutter
url_launcher_platform_interface: ^2.0.0
url_launcher_platform_interface: ^2.0.3

dev_dependencies:
flutter_test:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 2.9.3

* Updates `webview_flutter_platform_interface` constraint to the correct minimum
version.

## 2.9.2

* Fixes crash when an Objective-C object in `FWFInstanceManager` is released, but the dealloc
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: webview_flutter_wkwebview
description: A Flutter plugin that provides a WebView widget based on Apple's WKWebView control.
repository: https://github.com/flutter/plugins/tree/main/packages/webview_flutter/webview_flutter_wkwebview
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+webview%22
version: 2.9.2
version: 2.9.3

environment:
sdk: ">=2.17.0 <3.0.0"
Expand All @@ -19,7 +19,7 @@ dependencies:
flutter:
sdk: flutter
path: ^1.8.0
webview_flutter_platform_interface: ^1.8.0
webview_flutter_platform_interface: ^1.9.0

dev_dependencies:
build_runner: ^2.1.5
Expand Down
7 changes: 6 additions & 1 deletion script/tool/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
## 0.9.1

* Adds a `--downgrade` flag to `analyze` for analyzing with the oldest possible
versions of packages.

## 0.9.0

* Replaces PR-description-based version/changelog/breaking change check
overrides in `version-check` with label-based overrides using a new
`pr-labels` flag, since we don't actually have reliable access to the
PR description in checks.

## 0.8.10

- Adds a new `remove-dev-dependencies` command to remove `dev_dependencies`
Expand Down
22 changes: 18 additions & 4 deletions script/tool/lib/src/analyze_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,16 @@ class AnalyzeCommand extends PackageLoopingCommand {
valueHelp: 'dart-sdk',
help: 'An optional path to a Dart SDK; this is used to override the '
'SDK used to provide analysis.');
argParser.addFlag(_downgradeFlag,
help: 'Runs "flutter pub downgrade" before analysis to verify that '
'the minimum constraints are sufficiently new for APIs used.');
argParser.addFlag(_libOnlyFlag,
help: 'Only analyze the lib/ directory of the main package, not the '
'entire package.');
}

static const String _customAnalysisFlag = 'custom-analysis';
static const String _downgradeFlag = 'downgrade';
static const String _libOnlyFlag = 'lib-only';
static const String _analysisSdk = 'analysis-sdk';

Expand Down Expand Up @@ -113,6 +117,12 @@ class AnalyzeCommand extends PackageLoopingCommand {
return PackageResult.skip('No lib/ directory.');
}

if (getBoolArg(_downgradeFlag)) {
if (!await _runPubCommand(package, 'downgrade')) {
return PackageResult.fail(<String>['Unable to downgrade dependencies']);
}
}

// Analysis runs over the package and all subpackages (unless only lib/ is
// being analyzed), so all of them need `flutter pub get` run before
// analyzing. `example` packages can be skipped since 'flutter packages get'
Expand All @@ -127,10 +137,7 @@ class AnalyzeCommand extends PackageLoopingCommand {
!RepositoryPackage(packageToGet.directory.parent)
.pubspecFile
.existsSync()) {
final int exitCode = await processRunner.runAndStream(
flutterCommand, <String>['pub', 'get'],
workingDir: packageToGet.directory);
if (exitCode != 0) {
if (!await _runPubCommand(packageToGet, 'get')) {
return PackageResult.fail(<String>['Unable to get dependencies']);
}
}
Expand All @@ -147,4 +154,11 @@ class AnalyzeCommand extends PackageLoopingCommand {
}
return PackageResult.success();
}

Future<bool> _runPubCommand(RepositoryPackage package, String command) async {
final int exitCode = await processRunner.runAndStream(
flutterCommand, <String>['pub', command],
workingDir: package.directory);
return exitCode == 0;
}
}
2 changes: 1 addition & 1 deletion script/tool/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: flutter_plugin_tools
description: Productivity utils for flutter/plugins and flutter/packages
repository: https://github.com/flutter/plugins/tree/main/script/tool
version: 0.9.0
version: 0.9.1

dependencies:
args: ^2.1.0
Expand Down
49 changes: 49 additions & 0 deletions script/tool/test/analyze_command_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,33 @@ void main() {
);
});

test('downgrades first when requested', () async {
final RepositoryPackage plugin = createFakePlugin('a', packagesDir);

await runCapturingPrint(runner, <String>['analyze', '--downgrade']);

expect(
processRunner.recordedCalls,
orderedEquals(<ProcessCall>[
ProcessCall(
'flutter',
const <String>['pub', 'downgrade'],
plugin.path,
),
ProcessCall(
'flutter',
const <String>['pub', 'get'],
plugin.path,
),
ProcessCall(
'dart',
const <String>['analyze', '--fatal-infos'],
plugin.path,
),
]),
);
});

group('verifies analysis settings', () {
test('fails analysis_options.yaml', () async {
createFakePlugin('foo', packagesDir,
Expand Down Expand Up @@ -312,6 +339,28 @@ void main() {
);
});

test('fails if "pub downgrade" fails', () async {
createFakePlugin('foo', packagesDir);

processRunner.mockProcessesForExecutable['flutter'] = <io.Process>[
MockProcess(exitCode: 1) // flutter pub downgrade
];

Error? commandError;
final List<String> output = await runCapturingPrint(
runner, <String>['analyze', '--downgrade'], errorHandler: (Error e) {
commandError = e;
});

expect(commandError, isA<ToolExit>());
expect(
output,
containsAllInOrder(<Matcher>[
contains('Unable to downgrade dependencies'),
]),
);
});

test('fails if "analyze" fails', () async {
createFakePlugin('foo', packagesDir);

Expand Down