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

Commit

Permalink
[ci] Remove repo tooling (#7172)
Browse files Browse the repository at this point in the history
* Remove tooling

* Remove CI testing of tooling

* Switch invocations to published version

* Update tool_runner.sh

* Update Cirrus

* Fix global run command

* Update stale comment

* Re-add a minimal stub

* Roll forward
  • Loading branch information
stuartmorgan authored Feb 14, 2023
1 parent 7a7e43e commit 677b43a
Show file tree
Hide file tree
Showing 86 changed files with 44 additions and 27,661 deletions.
9 changes: 0 additions & 9 deletions .ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -281,15 +281,6 @@ targets:
{"dependency": "vs_build", "version": "version:vs2019"}
]
- name: Windows plugin_tools_tests
recipe: plugins/plugins
timeout: 30
properties:
add_recipes_cq: "true"
target_file: plugin_tools_tests.yaml
channel: master
version_file: flutter_master.version

- name: Linux ci_yaml plugins roller
recipe: infra/ci_yaml
timeout: 30
Expand Down
2 changes: 1 addition & 1 deletion .ci/scripts/build_examples_win32.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

dart ./script/tool/bin/flutter_plugin_tools.dart build-examples --windows \
dart pub global run flutter_plugin_tools build-examples --windows \
--packages-for-branch --log-timing
2 changes: 1 addition & 1 deletion .ci/scripts/create_all_plugins_app.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

dart ./script/tool/bin/flutter_plugin_tools.dart create-all-packages-app \
dart pub global run flutter_plugin_tools create-all-packages-app \
--output-dir=. --exclude script/configs/exclude_all_packages_app.yaml
2 changes: 1 addition & 1 deletion .ci/scripts/drive_examples_win32.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

dart ./script/tool/bin/flutter_plugin_tools.dart drive-examples --windows \
dart pub global run flutter_plugin_tools drive-examples --windows \
--exclude=script/configs/exclude_integration_win32.yaml --packages-for-branch --log-timing
2 changes: 1 addition & 1 deletion .ci/scripts/native_test_win32.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

dart ./script/tool/bin/flutter_plugin_tools.dart native-test --windows \
dart pub global run flutter_plugin_tools native-test --windows \
--no-integration --packages-for-branch --log-timing
7 changes: 0 additions & 7 deletions .ci/scripts/plugin_tools_tests.sh

This file was deleted.

5 changes: 3 additions & 2 deletions .ci/scripts/prepare_tool.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
# To set FETCH_HEAD for "git merge-base" to work
git fetch origin main

cd script/tool
dart pub get
# Pinned version of the plugin tools, to avoid breakage in this repository
# when pushing updates from flutter/packages.
dart pub global activate flutter_plugin_tools 0.13.4+3
5 changes: 0 additions & 5 deletions .ci/targets/plugin_tools_tests.yaml

This file was deleted.

9 changes: 1 addition & 8 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ gcp_credentials: ENCRYPTED[!3a93d98d7c95a41f5033834ef30e50928fc5d81239dc632b153c
only_if: $CIRRUS_TAG == '' && ($CIRRUS_PR != '' || $CIRRUS_BRANCH == 'main')
env:
CHANNEL: "master" # Default to master when not explicitly set by a task.
PLUGIN_TOOL_COMMAND: "dart ./script/tool/bin/flutter_plugin_tools.dart"
PLUGIN_TOOL_COMMAND: "dart pub global run flutter_plugin_tools"

install_chrome_linux_template: &INSTALL_CHROME_LINUX
env:
Expand Down Expand Up @@ -77,10 +77,6 @@ task:
namespace: default
matrix:
### Platform-agnostic tasks ###
- name: Linux plugin_tools_tests
script:
- cd script/tool
- dart pub run test
# Repository rules and best-practice enforcement.
# Only channel-agnostic tests should go here since it is only run once
# (on Flutter master).
Expand Down Expand Up @@ -124,9 +120,6 @@ task:
matrix:
CHANNEL: "master"
CHANNEL: "stable"
analyze_tool_script:
- cd script/tool
- dart analyze --fatal-infos
analyze_script:
# DO NOT change the custom-analysis argument here without changing the Dart repo.
# See the comment in script/configs/custom_analysis.yaml for details.
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ jobs:
with:
fetch-depth: 0 # Fetch all history so the tool can get all the tags to determine version.
- name: Set up tools
run: dart pub get
working-directory: ${{ github.workspace }}/script/tool
run: dart pub global activate flutter_plugin_tools 0.13.4+3

# This workflow should be the last to run. So wait for all the other tests to succeed.
- name: Wait on all tests
Expand All @@ -50,5 +49,5 @@ jobs:
run: |
git config --global user.name ${{ secrets.USER_NAME }}
git config --global user.email ${{ secrets.USER_EMAIL }}
dart ./script/tool/lib/src/main.dart publish --all-changed --base-sha=HEAD~ --skip-confirmation --remote=origin
dart pub global run flutter_plugin_tools publish --all-changed --base-sha=HEAD~ --skip-confirmation --remote=origin
env: {PUB_CREDENTIALS: "${{ secrets.PUB_CREDENTIALS }}"}
196 changes: 9 additions & 187 deletions script/tool/README.md
Original file line number Diff line number Diff line change
@@ -1,191 +1,13 @@
# Flutter Plugin Tools
# Removed

This is a set of utilities used in the flutter/plugins and flutter/packages
repositories. It is no longer explictily maintained as a general-purpose tool
for multi-package repositories, so your mileage may vary if using it in other
repositories.
See https://github.com/flutter/packages/blob/main/script/tool/README.md for the
current location of this tooling.

Note: The commands in tools are designed to run at the root of the repository or `<repository-root>/packages/`.
## Temporary shim

## Getting Started
This is a temporary, minimal version of the tools sufficient to keep the
following scripts running until the repository merge is complete and they are
updated to use flutter/packages instead:

In flutter/plugins, the tool is run from source. In flutter/packages, the
[published version](https://pub.dev/packages/flutter_plugin_tools) is used
instead. (It is marked as Discontinued since it is no longer maintained as
a general-purpose tool, but updates are still published for use in
flutter/packages.)

The commands in tools require the Flutter-bundled version of Dart to be the first `dart` loaded in the path.

### Extra Setup

When updating sample code excerpts (`update-excerpts`) for the README.md files,
there is some [extra setup for
submodules](#update-readmemd-from-example-sources) that is necessary.

### From Source (flutter/plugins only)

Set up:

```sh
cd ./script/tool && dart pub get && cd ../../
```

Run:

```sh
dart run ./script/tool/bin/flutter_plugin_tools.dart <args>
```

### Published Version

Set up:

```sh
dart pub global activate flutter_plugin_tools
```

Run:

```sh
dart pub global run flutter_plugin_tools <args>
```

## Commands

Run with `--help` for a full list of commands and arguments, but the
following shows a number of common commands being run for a specific package.

All examples assume running from source; see above for running the
published version instead.

Most commands take a `--packages` argument to control which package(s) the
command is targetting. An package name can be any of:
- The name of a package (e.g., `path_provider_android`).
- The name of a federated plugin (e.g., `path_provider`), in which case all
packages that make up that plugin will be targetted.
- A combination federated_plugin_name/package_name (e.g.,
`path_provider/path_provider` for the app-facing package).

### Format Code

```sh
cd <repository root>
dart run ./script/tool/bin/flutter_plugin_tools.dart format --packages package_name
```

### Run the Dart Static Analyzer

```sh
cd <repository root>
dart run ./script/tool/bin/flutter_plugin_tools.dart analyze --packages package_name
```

### Run Dart Unit Tests

```sh
cd <repository root>
dart run ./script/tool/bin/flutter_plugin_tools.dart test --packages package_name
```

### Run Dart Integration Tests

```sh
cd <repository root>
dart run ./script/tool/bin/flutter_plugin_tools.dart build-examples --apk --packages package_name
dart run ./script/tool/bin/flutter_plugin_tools.dart drive-examples --android --packages package_name
```

Replace `--apk`/`--android` with the platform you want to test against
(omit it to get a list of valid options).

### Run Native Tests

`native-test` takes one or more platform flags to run tests for. By default it
runs both unit tests and (on platforms that support it) integration tests, but
`--no-unit` or `--no-integration` can be used to run just one type.

Examples:

```sh
cd <repository root>
# Run just unit tests for iOS and Android:
dart run ./script/tool/bin/flutter_plugin_tools.dart native-test --ios --android --no-integration --packages package_name
# Run all tests for macOS:
dart run ./script/tool/bin/flutter_plugin_tools.dart native-test --macos --packages package_name
# Run all tests for Windows:
dart run ./script/tool/bin/flutter_plugin_tools.dart native-test --windows --packages package_name
```

### Update README.md from Example Sources

`update-excerpts` requires sources that are in a submodule. If you didn't clone
with submodules, you will need to `git submodule update --init --recursive`
before running this command.

```sh
cd <repository root>
dart run ./script/tool/bin/flutter_plugin_tools.dart update-excerpts --packages package_name
```

### Update CHANGELOG and Version

`update-release-info` will automatically update the version and `CHANGELOG.md`
following standard repository style and practice. It can be used for
single-package updates to handle the details of getting the `CHANGELOG.md`
format correct, but is especially useful for bulk updates across multiple packages.

For instance, if you add a new analysis option that requires production
code changes across many packages:

```sh
cd <repository root>
dart run ./script/tool/bin/flutter_plugin_tools.dart update-release-info \
--version=minimal \
--changelog="Fixes violations of new analysis option some_new_option."
```

The `minimal` option for `--version` will skip unchanged packages, and treat
each changed package as either `bugfix` or `next` depending on the files that
have changed in that package, so it is often the best choice for a bulk change.

For cases where you know the change time, `minor` or `bugfix` will make the
corresponding version bump, or `next` will update only `CHANGELOG.md` without
changing the version.

### Publish a Release

**Releases are automated for `flutter/plugins` and `flutter/packages`.**

The manual procedure described here is _deprecated_, and should only be used when
the automated process fails. Please, read
[Releasing a Plugin or Package](https://github.com/flutter/flutter/wiki/Releasing-a-Plugin-or-Package)
on the Flutter Wiki first.

```sh
cd <path_to_plugins>
git checkout <commit_hash_to_publish>
dart run ./script/tool/bin/flutter_plugin_tools.dart publish --packages <package>
```

By default the tool tries to push tags to the `upstream` remote, but some
additional settings can be configured. Run `dart run ./script/tool/bin/flutter_plugin_tools.dart
publish --help` for more usage information.

The tool wraps `pub publish` for pushing the package to pub, and then will
automatically use git to try to create and push tags. It has some additional
safety checking around `pub publish` too. By default `pub publish` publishes
_everything_, including untracked or uncommitted files in version control.
`publish` will first check the status of the local
directory and refuse to publish if there are any mismatched files with version
control present.

## Updating the Tool

For flutter/plugins, just changing the source here is all that's needed.

For changes that are relevant to flutter/packages, you will also need to:
- Update the tool's pubspec.yaml and CHANGELOG
- Publish the tool
- Update the pinned version in
[flutter/packages](https://github.com/flutter/packages/blob/main/.cirrus.yml)
- [dart-lang analysis](https://github.com/dart-lang/sdk/blob/main/tools/bots/flutter/analyze_flutter_plugins.sh)
- [flutter/flutter analysis](https://github.com/flutter/flutter/blob/master/dev/bots/test.dart)
26 changes: 3 additions & 23 deletions script/tool/lib/src/analyze_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,9 @@ 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';

late String _dartBinaryPath;
Expand Down Expand Up @@ -111,26 +103,14 @@ class AnalyzeCommand extends PackageLoopingCommand {

@override
Future<PackageResult> runForPackage(RepositoryPackage package) async {
final bool libOnly = getBoolArg(_libOnlyFlag);

if (libOnly && !package.libDirectory.existsSync()) {
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'
// automatically runs `pub get` in examples as part of handling the parent
// directory.
final List<RepositoryPackage> packagesToGet = <RepositoryPackage>[
package,
if (!libOnly) ...await getSubpackages(package).toList(),
...await getSubpackages(package).toList(),
];
for (final RepositoryPackage packageToGet in packagesToGet) {
if (packageToGet.directory.basename != 'example' ||
Expand All @@ -146,8 +126,8 @@ class AnalyzeCommand extends PackageLoopingCommand {
if (_hasUnexpecetdAnalysisOptions(package)) {
return PackageResult.fail(<String>['Unexpected local analysis options']);
}
final int exitCode = await processRunner.runAndStream(_dartBinaryPath,
<String>['analyze', '--fatal-infos', if (libOnly) 'lib'],
final int exitCode = await processRunner.runAndStream(
_dartBinaryPath, <String>['analyze', '--fatal-infos'],
workingDir: package.directory);
if (exitCode != 0) {
return PackageResult.fail();
Expand Down
Loading

0 comments on commit 677b43a

Please sign in to comment.