[wiki migration] Ecosystem team pages (#148589)

This puts the wiki pages owned by the Ecosystem team into the docs/ecosystem directory as planned in [flutter.dev/go/migrate-flutter-wiki-spreadsheet](https://docs.google.com/spreadsheets/d/1x65189ZBdNiLRygpUYoU08pwvXD4M-Z157c6pm8deGI/edit?usp=sharing) 

It also adds the ecosystem team labels to the label bot for future PRs.

Changes to the content were only updating cross links. The remaining wiki links will be updated after the rest of the pages are relocated, the original wiki links still work in the meantime.

Part of https://github.com/flutter/flutter/issues/145009
This commit is contained in:
Kate Lovett
2024-05-20 12:44:39 -05:00
committed by GitHub
parent e43fb59095
commit 49bc6bd54f
13 changed files with 25 additions and 14 deletions

View File

@@ -0,0 +1,16 @@
_**TL;DR** To facilitate a smooth ecosystem migration, a package author may ask dependent packages to migrate to a 1.0.0 version with a `>=0.x.y+z <2.0.0` constraint rather than a `^1.0.0`._
API stability* is an important milestone in a package’s lifetime and bumping the version to 1.0.0 is an exciting way to celebrate this moment.
This is what the [Semantic Versioning Specification](https://semver.org/#spec-item-4) (2.0.0) is saying about pre 1.0.0 versions:
> Major version zero (0.y.z) is for initial development. Anything MAY change at any time. The public API SHOULD NOT be considered stable.
Pub on the other hand treats pre 1.0.0 versions semantically (see [pub_semver corner cases](https://pub.dev/packages/pub_semver)), shifting the numbers by one position.
Often, at the time a package author is ready to announce API stability their package is versioned 0.x.y+z. Bumping a package version from 0.x.y+z to 1.0.0 is a major version bump in the Dart ecosystem. Migrations across a major version bump are slower, and may result in some period of ecosystem fragmentation (when some dependent packages are only willing to take ^0.x.y+z and some require ^1.0.0).
To go through an ecosystem migration to 1.0.0 in a smoother way, users of the newly API-stable package (particularly dependent packages) are encouraged to update their constraints to `>=0.a.b+c <2.0.0` instead of `^1.0.0`, this reduces friction during the transition period while some dependents have updated to post 1.0.0 and some have not.
&ast; While an API can never be guaranteed to be stable, version 1.0.0 is the milestone in which the package author is feeling comfortable to let others depend on the current API, and does not have concrete plans to change it in a breaking way.

View File

@@ -0,0 +1,47 @@
This provides an overview of the structure of the flutter/packages repository.
# Packages
Most packages are located in `packages`. A few which are derived heavily from third-party code are instead in `third_party/packages/`.
## Plugins
Plugins in flutter/packages uses the federated plugin model. If you are not familiar with federated plugins, start with reading [the federated plugin overview](https://flutter.dev/docs/development/packages-and-plugins/developing-packages#federated-plugins) to understand the terms below.
All plugins are located in the `packages/` directory. Almost all plugins have the following layout:
- `some_plugin/` - A directory containing the individual packages of the federated plugin:
- `some_plugin/` - The app-facing package
- `some_plugin_platform_interface/` - The platform interface
- `some_plugin_android/`, `some_plugin_ios/`, `some_plugin_web/`, `some_plugin_windows/`, `some_plugin_macos/`, and/or `some_plugin_linux/` - The individual platform implementations, as applicable
- In some special cases, implementation packages have different names; examples include `webview_flutter_wkwebview` and `in_app_purchase_storekit`. These would normally be named `_ios`, but have more generic names because they include (or expected to include in the future) macOS implementations. Sharing a package allows sharing the code, as the OS APIs are largely the same across the two platforms.
This layout reflects the goal of having all multi-platform plugins in flutter/packages being fully federated. (While this is not strictly necessary, as all packages are being maintained by the Flutter team, using a fully federated structure ensures that we are testing the federated model and finding issues and areas for improvement specific to federation.)
### Android Specifics
#### Gradle structure
`package/example/android/settings.gradle` imports the flutter tooling, includes the app directory (same as `flutter create` projects) additionally it configures GoogleCloudPlatform/artifact-registry-maven-tools for use in CI.
This repo has a GCP instance that mirrors dependencies available from `google()` and `mavenCentral()` used by CI (or Googlers). This gives us redundant uptime for dependency availability.
Using the specific google hosted cache is not intended for contributors outside of CI. We protect that execution with an environment variable `ARTIFACT_HUB_REPOSITORY` to ensure that by default users do not see rejected cloud credentials or errors in builds. Contributors could setup an artifact repository and set the environment variable to point to a hosted repository but that is practically not worth it for almost all contributors.
Googlers can debug locally by setting `ARTIFACT_HUB_REPOSITORY` to the valid artifact hub value and authenticating with GCP. To authenticate run `gcloud auth application-default login`. To find artifact hub url use `<url>` section of go/artifact-hub#maven or inspect the value on CI servers. CI uses a service account for billing. That is defined in go/artifact-hub-service-account (Googler access only).
## Useful links for debuging
https://github.com/GoogleCloudPlatform/artifact-registry-maven-tools/blob/master/README.md
https://docs.gradle.org/current/userguide/declaring_repositories.html
https://docs.gradle.org/current/userguide/viewing_debugging_dependencies.html
Command to force refresh of dependencies `./gradlew app:dependencies --configuration <SOME_TASK> --refresh-dependencies`
### Unfederated plugins
A few plugins are inherently single-platform (for example, `flutter_plugin_android_lifecycle`), and so are not federated. For those plugins the structure is:
- `some_plugin/` - A plugin containing the app-facing API and its implementation
# Tools
`script/tool/` contains the tooling used to manage tasks across all packages in the repository. See [its README](https://github.com/flutter/packages/blob/main/script/tool/README.md) for more information.

12
docs/ecosystem/README.md Normal file
View File

@@ -0,0 +1,12 @@
This is an index of team-facing documentation for the [flutter/packages repository](https://github.com/flutter/packages/).
- [Contributing to Plugins and Packages](contributing/README.md)
- [Flutter migrate](https://github.com/flutter/flutter/wiki/Flutter-migrate)
- [Package migration to 1.0.0](Package-migration-to-1.0.0.md)
- [Plugin Tests](testing/Plugin-Tests.md)
- [Plugins and Packages repository structure](Plugins-and-Packages-repository-structure.md)
- [Setting up the Packages development environment](contributing/Setting-up-the-Packages-development-environment.md)
- [Setting up the Plugins development environment](contributing/Setting-up-the-Plugins-development-environment.md)
- [Understanding Packages tests](testing/Understanding-Packages-tests.md)
- [Releasing a Plugin or Package](release/README.md)
- [Updating Packages repo for a stable release](release/Updating-Packages-repo-for-a-stable-release.md)

View File

@@ -0,0 +1,433 @@
This page covers additional information that is specific to contributing to flutter/packages. If you aren't already familiar with the general guidance on Flutter contribution, start with [Tree hygiene](https://github.com/flutter/flutter/wiki/Tree-hygiene).
## Version and CHANGELOG updates
Most changes need version and CHANGELOG changes; see below for details.
In most cases, the easiest way to create them is to use [the `update-release-info` repository command](https://github.com/flutter/packages/blob/main/script/tool/README.md#update-changelog-and-version). If you are adding a feature, use `--version=minor`, otherwise `--version=minimal` will almost always do the right thing.
### Version
Any change that needs to be published in order to take effect must update the version in `pubspec.yaml`. There are very few exceptions:
- PRs that only affect tests.
- PRs that only affect unpublished parts of example apps.
- PRs that only affect local development of the package (e.g., changes to ignored lints).
- Breaking change batching (see below).
- Non-code changes that we make to future-proof development in some way, but don't directly benefit clients. Examples of this include
- Updating the minimum Dart or Flutter SDK for all packages when we adjust our test matrix.
- Updating the minimum OS version of plugins to match changes to [Flutter support](https://docs.flutter.dev/reference/supported-platforms) (on `stable`).
(Unless you are a member of the Flutter team, you are likely not making changes that fall under this exemption.)
This is because the packages in flutter/packages use a continuous release model rather than a set release cadence. This model gets improvements to the community faster, makes regressions easier to pinpoint, and simplifies the release process.
(The `override: no versioning needed` label can be added to skip this check, but only if the criteria above are met, or team members agree there is a compelling reason for a new exemption. Team members: please leave a comment when adding the `override` label explaining the reason for the override.)
### CHANGELOG
All version changes must have an accompanying CHANGELOG update. Even version-exempt changes should often update CHANGELOG by adding a special `NEXT` entry at the top of `CHANGELOG.md` (unless they only affect development of the package, such as test-only changes):
```
## NEXT
* Description of the change.
## 1.0.2
...
```
This policy exists because some changes (e.g., certain updates to examples) that do not need to be published may still be of interest to clients of a package.
The tooling errs on the side of false positives, so will sometimes flag changes that should be exempt for one of the reasons listed above. In these cases, or if the reviewer feels that the change would not be relevant to package clients, they can add the `override: no changelog needed` label can to skip this check. Team members: please leave a comment when adding the `override` label explaining the reason for the override.
#### CHANGELOG style
For consistency, all CHANGELOG entries should follow a common style:
- Use `##` for the version line. A version line should have a blank line before and after it.
- Use `*` for individual items.
- Exception: When editing an existing CHANGELOG that uses `-`, use that instead for local consistency.
- Entries should use present tense indicative for verbs, with "this version" as an implied subject. For example, "Adds cool new feature.",
not "Add", "Added", or "Adding".
- Entries should end with a `.`.
- Breaking changes should be introduced with `**BREAKING CHANGE**:`, or `**BREAKING CHANGES**:`
if there is a sub-list of changes.
- Breaking change notifications should include information about how to migrate. If extensive migration is required, this can be a reference to a longer description elsewhere (usually README.md) rather than inline instructions.
Example:
```
## 2.0.0
* Adds the ability to fetch data from the future.
* **BREAKING CHANGES**:
* Removes the deprecated `neverCallThis` method.
* URLs parameters are now `Uri`s rather than `String`s.
## 1.0.3
* Fixes a crash when the device teleports during a network operation.
```
#### Updating a CHANGELOG that has a `NEXT`
*Note: If you are using `update-release-info`, this will be handled correctly for you.*
If you are adding a version change to a CHANGELOG that starts with `NEXT`, and your change also doesn't require a version update, just add a description to the existing `NEXT` list:
```
## NEXT
* Description of your new change.
* Existing entry.
## 1.0.2
...
```
If your change does require a version change, do the same, but then replace `NEXT` with the new version. For example:
```
## 1.0.3
* Description of your new change.
* Existing entry.
## 1.0.2
...
```
If you leave `NEXT` when adding a version change, automated tests for your PR will fail.
### FAQ
**Do I need to update the version if I'm just changing the README?** Yes. Most people read the README on pub.dev, not GitHub, so a README change is not very useful unless it is published.
**Do I need to update the version if I'm just changing comments?** If the comment is intended for clients of the package (a `///` comment on anything exported by the package), then yes, since what developers using the package will see in their IDE will come from the published version. If the comment is only useful for someone working on the package (such as an implementation comment within a method, or a comment in a non-exported file), then no.
**What do I do if I there are conflicts to those changes before or during review?** This is common. You can leave the conflicts until you're at the end of the review process to avoid needing to resolve frequently. Including the version changes at the beginning despite the likelihood of conflicts makes it much harder to forget that step, and also means that a reviewer can easily fix it from the GitHub UI just before landing.
### Breaking changes
Because we prefer to minimize breaking changes to packages after 1.0, breaking changes do not always follow the normal one-version-change-per-PR approach. Instead, when making a breaking change consider whether there are other breaking changes that should be made at the same time, and discuss with other regular contributors. If there are multiple changes to make, they can be batched as follows:
1. File an issue tracking all of the breaking changes to include.
1. Prepare PRs for all of the changes, without version changes. Ensure that they have all been reviewed, but do not land them yet. (They should fail CI due to the lack of version change, preventing accidental landing.)
1. Land a PR that temporarily adds `publish_to: none` to the package, with a comment referencing the issue from step 1.
1. Land all of the breaking change PRs. This step should be done in a relatively short window of time (thus the advance preparation above) to avoid having the plugin be unpublishable for longer than necessary. The PRs will pass CI once rebased, since the version check is disabled for unpublishable packages.
1. Once all breaking changes have landed, land a final PR to update the version and remove `publish_to: none`.
## Dependencies
We try to minimize external package dependencies as much as possible, where "external" means packages that are not generally within the control of the Flutter or Dart teams (Examples non-external packages include `sdk:` dependencies, packages in flutter/packages, and packages published by dart.dev), or by an organization with a track record of strong support for both engineering best practices and Flutter. This is for several reasons:
- Maintainability:
- We have a policy of always supporting Flutter `master`; if we can't guarantee that fixes for breaking changes can be landed immediately in dependencies, it can block our roller.
- If a package is abandoned by its authors, we will have to fork or migrate in order to unblock the entire repository.
- External packages increase our expose to out-of-band breakage (e.g., if breaking change is published without following semver).
- Security: We cannot make any guarantees about the code in an external package. For example, if a package we depend on is later taken over by a malicious actor, our dependency would expose all clients of our own package to potential attack via the transitive dependency.
If you are considering adding an external dependency:
- Consider other options, and discuss with #hackers-ecosystem in Discord.
- If you add a `dev_dependency` on an external package, pin it to a specific version if at all possible.
- If you add a `dependency` on an external package in an `example/`, pin it to a specific version if at all possible.
- Some dependencies should only be linked as dev_dependencies like integration_test
### Native dependencies
The same general principles apply to native dependencies for plugins (e.g., dependencies specified in an Android Gradle file or iOS podspec file): minimize dependencies—and especially non-test dependencies—on libraries that are not created by either the platform vendor or another organization with a track record of strong support for engineering best practices in whom we can have a very high degree of confidence in ongoing support and prompt updates.
## Platform Support
The goal is to have any plugin feature work on every platform on which that feature makes sense; having a lot of features that are only partially implemented across platforms is often confusing and frustrating for developers trying to use those plugins. However, a single developer will not always have the expertise to implement a feature across all supported platforms.
Given that, we welcome PRs that only implement a feature for a subset of platforms, including just one. To set expectations for how such PRs will be handled:
- They will not be fully reviewed until there's an understanding of what support would look like across other platforms, for several reasons:
- API for features that will be permanently platform-specific may structured in ways that make that limitation more clear, so knowing if other platforms can support it will affect the review process.
- We want to avoid over-fitting the plugin APIs to a single platform's API. It is often the case that several platforms can implement a feature, but the behavior is different enough across platforms that we need to design the API in a way that covers those variations in a cohesive way. This means that knowing at a high level what the implementation on other platform also affects the review process.
- Features that are missing implementations on some platforms need to be clearly documented as such in the API, and those comments should clearly express whether those platform are temporarily missing implementations, or are not expected to ever have implementations due to platform limitations.
The PR author isn't necessarily responsible for answering these questions. These cases will be noted in comments during PR triage; if the PR author, or others in the community, can contribute that information, that will certainly help. If not, that investigation will be part of the review process (in which case the review will likely take longer).
- In some cases, a reviewer may wait on approving a PR for landing until there is a plan in place for landing implementations for other platforms. This is not a hard rule, and will be up to reviewer judgement. This could take a number of forms:
- Waiting for other PRs from the community that implement the feature for other platforms, and then moving forward with all of them at once.
- Finding resources within the Flutter team for implementing other platforms before moving forward.
- Landing the platform interface change and the platform implementations that are done, but waiting on one of the options above before adding the API to the app-facing package's API (allowing developers the option of drilling down to the platform implementation to use the feature on some platforms before it's ready everywhere).
"Other platforms" might not always include all other platforms. E.g., a feature might be something that's much more likely to be useful on mobile than desktop, or the reverse, and so we might only wait for implementations of that subset. Again, this will be up to reviewer judgement.
In the case where a PR is put on hold for the reasons above, it should be clearly noted in the PR and on the associated issue. We encourage anyone interested in contributing more platform implementation PRs to comment in the bug in such cases.
### API support queries
In cases where a plugin offers API in the app-facing package that is not implemented on all platforms (or not implemented on some OS versions of some platforms), there should also be an API to query for support of that API at runtime. That is, plugin clients should always be able to write code like:
```dart
if (somePluginInstance.supportsDoingThing) {
somePluginInstance.doThing();
}
```
rather than hard-coding a platform check. (See [`image_picker`'s `supportsImageSource`](https://github.com/flutter/packages/blob/9323e33ed9d8345d87514711dcaeb4cf4159ad1c/packages/image_picker/image_picker/lib/image_picker.dart#L309-L315) for an example.) This is for several reasons:
- It is federation-friendly: a new implementation of the plugin (including the addition of 1P support for a previously-unsupported platform) will automatically be covered.
- It allow seamless adoption of new functionality: if we add previously-missing support to an existing implementation, clients will automatically benefit without any code changes on their part.
- It makes our own documentation more evergreen: we've frequently had app-facing APIs that had a comment saying that an API is only available on platform X, and then forgotten to update it when adding support for platform Y.
These APIs can take a variety of forms, including specific methods to check individual methods or parameters, a single method with an enum of API options, etc. Discuss with your reviewer what pattern is best suited to the specific case, and aim for consistency within a plugin when possible.
*We currently have many cases of APIs that do not follow this guidance because they predate it. This is technical debt, rather than something that should be pointed to as a justification for adding new APIs that do not.*
## Languages
On some platforms, there are multiple native languages that can be used to write plugins; repository policy limits the languages that are used in some cases. These are currently the allowed languages for each platform:
- Android: Depends on the plugin; mixing languages within a plugin is currently not allowed:
- Kotlin if the plugin is already in Kotlin.
- Currently our policy is to have a limited number of plugins in Kotlin, to ensure that we are finding Kotlin-specific plugin issues in our own development.
- Java if the plugin is already in Java (which is almost all of them).
- Allowing Kotlin more broadly is [under consideration](https://docs.google.com/document/d/1Ok_mUPgmw8_l-ynLueEKtXm2Fs48lEVB0JqZd7M7uyA/edit?usp=sharing), but currently most plugin development is limited to Java to avoid adding another language to the set of languages Flutter team members need to interact with regularly.
- If you are interested in taking on a **long-term ownership role in a plugin**, and would like to migrate it to Kotlin, please reach out in the `hackers-ecosystem` channel [on Discord](https://github.com/flutter/flutter/wiki/Chat).
- iOS: Depends on the plugin. The goal is to eventually migrate all plugins to Swift; see [the migration section below](#swift-migration-for-1p-plugins) for details. For non-migration PRs, use:
- Swift if the plugin is entirely Swift.
- Swift or Objective-C if the plugin is partially migrated.
- Objective-C if the plugin is still entirely Objective-C.
- Linux: C. Use of C++ constructs is strongly discouraged; see [repo style notes](https://github.com/flutter/packages/blob/main/CONTRIBUTING.md#style) for details
- macOS: Swift only\*.
- \* In some cases an existing iOS implementation has been updated to support macOS, so is Objective-C (e.g., `in_app_purchase`). This is the only case where Objective-C is allowed for macOS plugins.
- Windows: C++.
- Web: Dart.
For all platforms, use of Dart for platform-specific features is both allowed and encouraged. While there are no specific rules about this in most plugins, in general we are moving toward having more logic written in Dart rather than a host language, as having more code in the project's primary language eases maintenance.
## Changing federated plugins
Most of the plugins in flutter/packages are [federated](https://flutter.dev/docs/development/packages-and-plugins/developing-packages#federated-plugins). Because a logical plugin consists of multiple packages, and our CI tests using published package dependencies—in order to ensure that every PR can be published without breaking the ecosystem—changes that span multiple packages will need to be done in multiple PRs. This is common when adding new features.
We are investigating ways to streamline this, but currently the process for a multi-package PR is:
1. Create a PR that has all the changes, and update the pubspec.yamls to have path-based dependency overrides. This can be done with the [plugin repo tool](https://github.com/flutter/packages/blob/main/script/tool/README.md)'s `make-deps-path-based` command, targeting any dependency packages changed in the PR. For instance, for an Android-specific change to `video_player` that required platform interface changes as well:
```
$ dart run script/tool/bin/flutter_plugin_tools.dart make-deps-path-based --target-dependencies=video_player_platform_interface,video_player_android
```
1. Upload that PR and get it into a state where the only test failure is the one complaining that you can't publish a package that has dependency overrides, then go through the normal process of getting reviews and approvals.
* The overall review is completed first to prevent situations where part of the overall change (usually a platform interface change) lands but the rest is never landed, or where the review of the changes in a higher-level part of the change (the app-facing and/or implementation packages) identifies issues in the lower-level parts.
1. **Once the combined PR is approved**, create a new PR that has only the platform interface package changes from the PR above, and ask the reviewers of the main package to review that.
* This review is generally trivial (unless the CI finds an issue that wasn't noticed in the main PR) since it's a subset of the PR that was already reviewed.
1. Once it has been reviewed, landed, and published, update the initial PR to:
* remove the changes that are part of the other PR,
* replace the dependency overrides on the platform interface package with a dependency on the published version, and
* merge in (or rebase to) the latest version of `master`.
1. If there are any dependency overrides remaining, repeat the previous two steps with those packages. There should never be interdependencies between platform implementation packages, so all implementations should be able to be handled in a single new PR.
* If new functionality is being added to the API surface of the app-facing package, be sure to update the version constraints of the implementation packages in its `pubspec.yaml`. Even though it's possible to compile with only the interface package's constraint updated, we don't want clients of the package who update without using `pub upgrade` to have surprising failures (e.g., `UnimplementedError`s) when using the new functionality due to not having the updated platform packages that implement the new feature.
1. Once there are no dependency overrides, ask the reviewer to land the main PR.
### Breaking changes to plugin platform interfaces
Breaking changes to platform interfaces (any package ending in `_platform_interface`) are strongly discouraged:
- They require each platform implementation to adopt the new version, and the app-facing package can't pick up any of those changes until all implementations have been updated. This could cause situations where bug fixes for one platform are held up on another platform adopting a feature change.
- They require a series of changes to CI to selectively disable testing the latest versions of all packages, then later re-enable them.
- They temporarily lock out unendorsed implementations, until their developers can update.
Because platform interfaces are not expected to be called by clients of the plugins, we favor backward compatibility over having a clean API at that layer.
In order to avoid accidental breaking changes that are missed in review, CI will by default fail for any breaking change to the platform interface. If you believe you need to make a breaking change, discuss with your reviewer and make sure they agree; once they do, add (or if you are not a project member, ask the reviewer to add) the `override: allow breaking change` label, then re-run the failing check. You should also adding something like the following to the PR description:
```
## Breaking change justification
<Insert good reason for breaking change here.>
```
This makes it easy for someone looking back at the change to find the reason for the breaking change without reading all of the comments.
### Changing platform interface method parameters
Because platform implementations are subclasses of the platform interface and override its methods, almost *any* change to the parameters of a method is a breaking change. In particular, adding an optional parameter to a platform interface method *is* a breaking change even though it doesn't break callers of the the method.
The least disruptive way to make a parameter change is:
1. Add a new method to the platform interface with the new parameters, whose default implementation calls the existing method. This is not a breaking change.
1. Strongly consider replacing some or all of the parameters with a parameter object (see [`AuthenticationOptions`](https://github.com/flutter/packages/blob/0ba896b35b2f33517c38ccbb1654ed646ad07af7/packages/local_auth/local_auth_platform_interface/lib/types/auth_options.dart#L7-L9) for [`authenticate`](https://github.com/flutter/packages/blob/0ba896b35b2f33517c38ccbb1654ed646ad07af7/packages/local_auth/local_auth_platform_interface/lib/local_auth_platform_interface.dart#L60) as an example), as this will allow adding other parameters in the future without breaking changes or new methods.
2. Mark the old method as `@Deprecated`, and file an issue about updating all uses of that method in the other packages in the plugin.
Note: The delegation of this method will feel backwards, because the implementing the new method in terms of the old method will discard the information from the new parameters. This is correct though, because the goal is to allow the app-facing package to call the new method regardless of whether implementation packages have implemented it. By forwarding to the existing method by default, implementation packages that haven't been updated will continue to have the behavior they had before (which, by necessity, won't include support for the new parameters). Implementation packages that have been updated will override this implementation with their own that honors the new parameters.
2. Update the implementations to override both methods.
* Usually this will involve having the old method call the new method (the opposite of the delegation done above in the interface package), or in some cases extracting a private helper method that both versions call.
3. Update the app-facing package to call the new method.
At some later point the deprecated method can be cleaned up by:
1. Making a breaking change in the platform interface package to remove any deprecated methods.
2. Updating the app-facing package to allow either the new major version or the previous version of the platform interface (to minimize version lock issues with implementations).
3. Updating all the implementations to use the new major version, removing the override of the deprecated methods.
This cleanup step is low priority though; deprecated methods in a platform interface should be largely harmless, as it's an API with very few direct customers. It's actually preferable to wait quite some time before doing this, as it gives any unendorsed third-party implementations that may exist more time to adapt to the change without disruption.
## Supported Flutter versions
flutter/packages has a general policy of supporting the latest `stable` version of Flutter, as well as the current `master`. In practice, many packages often support older versions as well, as minimum version requirements are generally only updated when there is a specific need, such as using a new Flutter feature.
- One exception is new packages which require features that aren't yet available on `stable`. In this rare case, discuss with `#hackers-ecosystem` as it requires adding conditional logic to the CI scripts.
Most CI only runs against those two version. There are only minimal tests of versions older that current `stable` (currently analysis only, for the previous two stable versions of Flutter).
### When to update the required version
- If you know your change requires a feature of Flutter that was added recently, you should update the minimum version accordingly. In particular, if your change was originally written against `master` and had to wait until a change reached `stable`, that means you need to update the minimum version. (Adding a constraint update as soon as the PR fails on `stable` tests is a good way to make sure you don't forget.)
- If your change requires a newer version of Flutter than is available on `stable`, and it can't wait until that feature reaches `stable`, ask in `#hackers-ecosystem` to see if there's a good solution.
- If your change fails a `*_legacy` CI test, update the minimum version accordingly.
The ecosystem team may also mass-update minimum versions from time to time, to reduce the potential of breaking untested versions (see below). In general, this should use a minimum version somewhat older than the current `stable`, but in some special cases may use the current stable version instead.
### Handling breakage in old versions
Sometimes a change to a package accidentally breaks older version of Flutter; because the full CI test suite does not run anything older than the current stable, such breakage will not necessarily be caught by CI, and will only be discovered via issue reports. When that happens there are several options:
- If the breakage is found quickly enough that retraction is still possible:
- Retract the latest release.
- Release a new version that is identical except for updating the minimum Flutter version.
This minimizes disruption to developers using old versions of Flutter, with no effect on people using current versions.
- Otherwise, there are several options; discuss with `#hackers-ecosystem` to decide which makes sense for the specific case:
1. Release a new update that restores compatibility with the old version. This should generally only be done if it's trivial to do so.
1. Release a revert, then release a new version that reverts the revert but with a constraint update. Consider this option if the number of people affected is likely to be large (e.g., a popular plugin is broken for the previous stable version of Flutter shortly after a stable release). This has essentially the same outcome as retraction, but can be done at any time.
1. Document the need to pin an old version of the package in the issue, and close it (along with making a `## NEXT` PR for the package that updates its minimum version, to document the correct reality). This will require all affected users to find the issue to learn how to fix it, so should generally only be done if the number of people affected is likely to be small (e.g., when it only affects versions of Flutter that are several stable releases behind).
## Plugin architecture conventions
All plugins in flutter/packages should follow the following conventions. Note that existing plugins do not currently always follow those conventions because they predate them. PRs that update plugins to follow conventions are welcome.
### Federation
All plugins should be fully [federated](https://docs.flutter.dev/development/packages-and-plugins/developing-packages#federated-plugins). This is to ensure that:
- Unofficial federated implementations can be created for any of our plugins. This allows for alternate implementations, as well as supporting unofficial embeddings.
- Our development processes for federated plugins also helps ensure that we don't accidentally break any such implementations. For instance, our federated safety checks help ensure that we don't make breaking changes to the platform interface without changing the major version.
- We are eating our own dogfood with federation. Federation adds non-trivial complexity to maintaining a plugin, and best practices for federation aren't always obvious. Using federation ourselves means that we are aware of potential issues, and encourages us to create documentation and tooling to improve the developer experience of using federation.
The only exception to this policy is plugins that are inherently specific to a single platform, such as `espresso`.
### In-package platform channels
All implementations should use in-package platform channels, for the reasons outlined in [the proposal document](https://flutter.dev/go/platform-channels-in-federated-plugins). Most plugins that predate this policy and have a legacy "shared method channel" default implementation in the platform interface package, but it is not be used by any first-party implementations.
### Platform exception handling
Having consistent error handling across platforms is an important part of providing a usable cross-platform API surface. Maintaining consistent errors directly from the native implementations is challenging since there is no easy way to share constants for error code strings across all the different languages, nor any clear reference point for what the possible errors are without reading all of the other implementations. It's also challenging to make changes, as it potentially requires changing every package in the federated plugin.
To ensure that the native errors are a coherent part of the interface, plugins that can throw `PlatformException`s internally should follow these best practices:
- The platform interface package should define a clear, structured error system as part of its interface. Options include:
- A plugin-specific `Exception` subclass, including constants or enums for known error types (e.g., permission failures).
- An alternate structured error-returning mechanism, such as return values that include either a successful value or an error state (e.g., result classes, or Dart 3 patterns and records).
- App-facing packages should `export` that definition, and should include it in relevant API documentation.
- Implementation packages should, in general, have Dart code to catch any `PlatformExceptions` that the native implementation is likely to throw, and convert them to the appropriate interface-defined error types.
- This means that the string constants for error codes returned from native need only be consistent within that platform implementation package, since it won't be passed out of the package (and thus only need to be kept in sync between two languages).
This means that in general, clients of a plugin should not be expected to see raw `PlatformException`s created from error responses in native code. (This is not a strict rule; failure cases that are so obscure that clients would be unlikely to actually have specific handlers for them don't necessarily need to be converted to a common exception type.)
**Note:** Existing `PlatformException`s are a de-facto part of the API, so updating plugins to follow this practice should be done as a breaking change.
### Enum handling
The best practice for doing `switch`es over `enum`s varies depending on the situation:
- If the `enum` is defined in the same package as the `switch`, the `switch` should cover all cases with no fallback, as it can be updated at the same time as any changes to the enum.
- If the `enum` is defined in a different package—this is not uncommon in federated plugins—the code should be robust against new enum values (unless it is just example code), since adding enum values is generally not considered a breaking change:
- Do not use `default:`; instead put the fallback code outside the enum. This will cause the linter to flag code in other packages that we need to update when an `enum` is changed. (This will often require the use of `ignore: dead_code`.) The fallback is needed because even though we can and should [update the package(s) containing the `switch` as a follow-up](https://github.com/flutter/flutter/issues/89866), we **cannot** guarantee that someone won't use an older version of the package containing the `switch` with a newer version of the package containing the `enum`, so that combination must have some well-defined behavior.
- When there is a reasonable default, use that so that the package continues to work, even if it's not the ideal behavior.
- When there is no reasonable default, throw a clear `UnimplementedError` so the client knows they need a new version of the package.
## README code
All new code samples in `README.md` files must `<?code-excerpt?>` pragmas to manage the code. With `<?code-excerpt?>`, the source of truth for the code is an actual Dart file, which is analyzed, compiled, and tested by our CI. This ensures that it stays updated as the package APIs, Flutter, Dart, and repository analyzer settings change.
### Updating `<?code-excerpt?>`-managed examples
If a code block has a `<?code-excerpt ...?>` tag just before it, it is already using `code-excerpt`. To update it:
1. Find the file referenced in that tag (e.g., `<?code-excerpt "lib/main.dart (AppLifecycle)"?>` comes from `lib/main.dart`; if there is a `<?code-excerpt path-base=""?>` directive earlier in the file, paths are resolved relative to the given `path-base` instead of the markdown file's path).
2. Update the code in that file. If you are fixing a bug, add unit tests or widget tests for the change.
3. Run the `update-excerpts` [repository tool command](https://github.com/flutter/packages/blob/main/script/tool/README.md#update-readmemd-from-example-sources), which will update `README.md`. From the root of the packages repository, the command to run this is: `dart run script/tool/bin/flutter_plugin_tools.dart update-excerpts`
### Add or converting a code block
To add a new code block, or fix a legacy code block:
1. Optionally, if this is the first code block to be added, add the following line to the start of the package's `README.md`:
```
<?code-excerpt path-base="example/lib"?>
```
replacing `example/lib` with the directory from which samples will be taken. This sets the base against which other paths are resolved. By default, the base is the path of the markdown file being updated. The base itself is resolved relative to the path of that file as well.
2. Find or write the code that you want to use in the example, then annotate it with `#docregion` and `#enddocregion` comments. Ideally the code should be in one of the examples, but you could also put the code in a test. The key is to put the code somewhere that is analyzed and, ideally, tested in CI.
For example:
~~~
// #docregion purple
const Color purple = Color(0xFFE6E6FA);
// #enddocregion purple
~~~
3. Reference the code from the `README.md` (or other markdown file where you want the sample to appear):
~~~
<?code-excerpt "{example/lib/-relative filename} ({excerpt name})"?>
```dart
```
~~~
So if you added `#docregion Foo` to `example/lib/main.dart` and specified `example/lib` as the path base, you would put the following in `README.md`:
~~~
<?code-excerpt "main.dart (Foo)"?>
```dart
```
~~~
4. Follow the steps in the "Updating" section above to automatically fill the new block with the code excerpt.
### Documentation
Samples can come from any file. In XML and HTML files, use `<!--#docregion sectionname-->` and `<!--#enddocregion sectionname-->`. In CSS files, use `/* #docregion sectionname */` and `/* #enddocregion sectionname */`. In YAML files, use `# #docregion sectionname` and `# #enddocregion sectionname`. In C++, Dart, JS, Kotlin, Swift, and other similar languages, use `// #docregion sectionname` and `// #enddocregion sectionname`.
You can extract multiple segments into one sample by just having multiple docregions with the same name. The regions will be concatenated with a language-appropriate comment such as `// ···`. You can control what this looks like by using the `plaster` control, as in:
<?code-excerpt "main.dart (Foo)" plaster="more..."?>
```dart
```
To disable this feature, use `plaster="none"`.
The plaster is indented as much as the `#enddocregion` of the region where the splice occurs.
Regions are maximally unindented before being injected into the markdown files (while preserving relative indentation within the block).
## Swift Migration for 1P Plugins
### Preparation
1. Read the [Swift migration design doc](https://docs.google.com/document/d/1XsaulkJA6_ZSpM7chkQLhQY25sQqhEMiqHMYzw8H85o/edit?resourcekey=0-_cUjF1c0iBvRLKfV-3gK5A), which covers several important topics such as the ["top down approach"](https://docs.google.com/document/d/1XsaulkJA6_ZSpM7chkQLhQY25sQqhEMiqHMYzw8H85o/edit?resourcekey=0-_cUjF1c0iBvRLKfV-3gK5A#heading=h.reauq7bq8vak). Feel free to leave any comments and feedback in the doc.
2. Read Google's [Swift Style Guide](https://google.github.io/swift/) and Apple's [API Design Guidelines](https://www.swift.org/documentation/api-design-guidelines/) (which is endorsed by Google's Swift Style Guide).
3. Pick a plugin that you are interested in from the [umbrella GitHub issue](https://github.com/flutter/flutter/issues/119015). This is for multiple contributors to coordinate with each other, and to avoid duplicate or conflicting work.
### Project Settings
1. Remove custom modulemap ([example](https://github.com/flutter/plugins/pull/6229/files)). This is due to a limitation in Cocoapods ([details](https://github.com/flutter/plugins/pull/6369#issue-1363961940)). This unfortunately means that we cannot use `Test` submodules, and all ObjC headers are exposed publicly during the migration.
2. Add Swift dependency information to the podspec ([example](https://github.com/flutter/packages/blob/617f9d99954fe394dc91258c431c9a2626921e08/packages/quick_actions/quick_actions_ios/ios/quick_actions_ios.podspec#L17-L22)). Note that `.h` and `.m` should be removed from the `spec.source_files` after migration is done.
3. After the plugin class is migrated to Swift, update `pluginClass` in `pubspec.yaml` ([example](https://github.com/flutter/packages/blob/617f9d99954fe394dc91258c431c9a2626921e08/packages/quick_actions/quick_actions_ios/pubspec.yaml#L16)).
### Format your Swift code
1. Install [swift-format](https://github.com/apple/swift-format). If you also contribute to the flutter engine, there is [an issue](https://github.com/flutter/flutter/issues/41129#issuecomment-1400812109) with the swift-format under `depot_tools`. Make sure to set up the export PATH properly to run your own copy of `swift-format`.
2. Run `./script/tool_runner.sh format`
### Testing
To reduce the risk of regression, it is important to backfill unit tests to full coverage before the migration, and maintain full coverage during the migration. If possible (i.e., if adding testing does not require refactoring the plugin to make it testable), adding test coverage should be done in a separate PR before the conversion of the implementation.
We do not report code coverage on the CI, since the number can actually be misleading (for example, a 100% coverage may make PR reviewers think that everything is fine, which is not necessarily true). Instead, you (and your PR reviewer) should evaluate whether the test is complete, by actually reading the test code (rather than just looking at the coverage). You may well want to use a coverage tool as part of your evaluation.
During the migration, especially when backfilling tests, it is possible to discover existing bugs. Migration PRs should just focus on migration and should not contain bug fixes. You can either (1) fix the bug in ObjC first in a separate PR, or (2) if the bug is too hard to fix, just acknowledge the bug in a comment so that someone can fix it in the future.

View File

@@ -0,0 +1,37 @@
## Things you will need
* A working [Flutter](https://flutter.dev/docs/get-started/install) installation.
* git (used for source version control).
* An ssh client (used to authenticate with GitHub).
## Getting the code and configuring your repository
* Ensure all the dependencies described in the previous section are installed.
* Fork `https://github.com/flutter/packages` into your own GitHub account. If
you already have a fork, and are now installing a development environment on
a new machine, make sure you've updated your fork so that you don't use stale
configuration options from long ago.
* If you haven't configured your machine with an SSH key that's known to github, then
follow [GitHub's directions](https://help.github.com/articles/generating-ssh-keys/)
to generate an SSH key.
* `git clone git@github.com:<your_name_here>/packages.git`
* `cd packages`
* `git remote add upstream git@github.com:flutter/packages.git` (So that you
fetch from the master repository, not your clone, when running `git fetch`
et al.)
## Setting up tools
### Repository tools
There are scripts for many common tasks (testing, formatting, etc.) that will likely be useful in preparing a PR.
See [the tools README](https://github.com/flutter/packages/blob/main/script/tool/README.md) for more details.
You will need to [set up the tools](https://github.com/flutter/packages/blob/main/script/tool/README.md#getting-started)
before using them for the first time.
### Android tooling
The repository is configured to treat warnings as errors in most cases; on Android that includes enforcing many Java and Android lint options. Not all of these are configured to show up by default in Android Studio, so if you are working on Android plugin implementations consider [enabling all of the Android lint options in Android Studio](https://developer.android.com/studio/write/lint#cis) (by checking the box by Android > Lint).
There are warnings that show up in Android Studio that are not enforced in CI, so it's not always necessary to fix every warning. You can check if warnings you see need to be addressed by running the `lint-android` repository tool command. (In general, we encourage fixing warnings that show up in Android Studio even when they are not enforced; the IDE has an extra linting options that unfortunately aren't accessible via CI. If you aren't sure if a specific unenforced warning needs to be addressed, please ask your reviewer.)

View File

@@ -0,0 +1 @@
The flutter/plugins repository is no longer in use. See [Setting up the Packages development environment](https://github.com/flutter/flutter/wiki/Setting-up-the-Packages-development-environment) instead.

View File

@@ -0,0 +1,70 @@
Any PR that changes a package's version (which should be most PRs) should be published
to pub.dev.
_See also: [Package migration to 1.0.0](../Package-migration-to-1.0.0.md)
## Automatic release
The packages in flutter/packages are automatically released with a Github Action workflow named [“release”](https://github.com/flutter/packages/blob/main/.github/workflows/release.yml). If a commit on master branch contains version updates to one or more packages, the “release” CI will publish the new versions to pub.dev and push the release tag to GitHub. The “release” CI passes if
1. the release process is successful, or
2. there are no version updates in the commit, or
3. the new versions have already been published.
If you are a Flutter team member at Google and you need access to the publisher account, please see b/191674407.
The “release” CI only runs on post-submit, and waits until all the other CI jobs have passed before starting. Like any other CI job, The “release” CI blocks future PRs if failed.
_Note: the “release” CI does not automatically publish the `flutter_plugin_tools` package._
### New packages
When a new package is released for the first time, it will be owned by the publisher account rather than the flutter.dev verified publisher. Someone with access (see above) needs to log into pub.dev with the publisher account and transfer the package to the verified publisher using the package's Admin tab.
### What if the “release” CI failed?
If it is a flake (for example, network issue), a Flutter team member can simply run the CI again. For more complicated cases, a Flutter team member can also manually release the packages, then re-run the CI to pass.
The most common source of failure of the `release` task is that another test failed; if that is due to flake, you will need to first re-run the failing test task, then once it's green re-run `release`.
## Manual release (only when necessary)
If something has gone wrong that prevents auto-publishing—most commonly, an out-of-band breakage that caused post-submit tests to fail for reasons unrelated to the PR that should have been published—a Flutter team member can publish manually. (An alternative to publishing manually is to revert and re-land the relevant PR; this is especially worth considering for PRs that affect many plugins.)
Some things to keep in mind before publishing the release:
- Is the post-submit CI for that commit green? Or if not (due to OOB breakage), is a subsequent post-submit green without having changed anything related to the plugin? Always check the post-submit CI before publishing.
- [Publishing is
forever.](https://dart.dev/tools/pub/publishing#publishing-is-forever)
Hopefully any bugs or breaking in changes in this PR have already been caught
in PR review, but now's a second chance to revert before anything goes live.
- "Don't deploy on a Friday." Consider carefully whether or not it's worth
immediately publishing an update before a stretch of time where you're going
to be unavailable. There may be bugs with the release or questions about it
from people that immediately adopt it, and uncovering and resolving those
support issues will take more time if you're unavailable.
To release a package:
1. `git checkout <commit_hash_to_publish>`. This should be the commit of the
PR you are publishing unless there's a very, **very** good reason you are using
a different version.
1. Ensure that `git status` is clean, and that there are no extra files in
your local repository (e.g., via `git clean -xfd`).
1. Use the [`publish` command from
`flutter_plugin_tools`](https://github.com/flutter/packages/blob/main/script/tool/README.md).
This command checks that you've done the step above, publishes the new version to pub.dev,
and tags the commit in the format of `<package_name>-v<package_version>` then pushes
it to the upstream repository.
### Fully manual backup option
If for some reason you can't use `flutter_plugin_tools` in step 3, you can publish manually:
1. Push the package update to [pub.dev](https://pub.dev) using `dart pub publish`.
2. Tag the commit with `git tag` in the format of `<package_name>-v<package_version>`
3. Push the tag to the upstream master branch with `git push upstream <tagname>`.
## Recovering from a bad release
Sometimes, despite our best efforts, breakage is found only after a package is published. Unlike flutter/engine or flutter/flutter a breaking PR that has been published **cannot be directly reverted**, since that would revert to an earlier, also-already-published version, which cannot be published. To fix published breakage:
1. Land a fix as a new version. This can either be a revert with version and CHANGELOG updates, or a fix-forward, depending on the situation.
2. **Optional**: If the release was within the last seven days, anyone in the 'flutter.dev' publisher group can retract the bad version, using the Admin tab on the package's pub.dev page. This step is especially useful if the problem was related to a bad Flutter or Dart version constraint (i.e., the package relies on functionality from a new version of Flutter or Dart, but doesn't set that minimum), to ensure that package clients on that old version don't still resolve to the broken version even once a new version with the constraint fixed is released. It can also be useful an immediate-term step while the fixed version is being rolled out, to prevent more people from being broken while the fix is prepared.
* If a package is retracted, this should if at all possible be in conjunction with releasing a fixed version, not instead, to make it easy for already-broken users to get to a fixed state.

View File

@@ -0,0 +1,27 @@
This page describes the process of updating flutter/packages after a stable Flutter release. Hotfix releases don't require any changes, since the auto-roller will update the [pinned stable version](https://github.com/flutter/packages/blob/main/.ci/flutter_stable.version), but full stable releases (roughly once per quarter) require manual updates to the repository:
* [The stable pin](https://github.com/flutter/packages/blob/main/.ci/flutter_stable.version) needs to be updated. The autoroller will open a PR, but because it includes a separate commit for every Flutter commit since the last stable, it will overwhelm the CLA check and it will fail. Either the CLA check can be overridden (which is safe since the source repo enforces the CLA), or a new manual PR can be made that updates the hash.
* The [Flutter Dart version mapping](https://github.com/flutter/packages/blob/b4985e25fe0763ece3cfd7af58e0e8c9b9f04fc4/script/tool/lib/src/common/core.dart#L59-L71) needs to be updated. The [Flutter SDK releases page](https://docs.flutter.dev/release/archive) is a useful reference.
* In addition to adding the new release, add the last bugfix version of the previous stable, for the next step.
* The [N-1 and N-2 legacy analysis tests](https://github.com/flutter/packages/blob/b4985e25fe0763ece3cfd7af58e0e8c9b9f04fc4/.ci.yaml#L223-L237) need to be updated. We generally use the latest bugfix versions for these tests.
* The [minimum allowed Flutter version](https://github.com/flutter/packages/blob/b4985e25fe0763ece3cfd7af58e0e8c9b9f04fc4/.ci/targets/repo_checks.yaml#L19) for the repo needs to be updated to the N-2 version. (We generally use .0 here, not the latest hotfix, under the assumption that there are not going to be analysis-breaking changes in a hotfix.)
* This should ideally be done in the same PR as the previous step, since that is the point at which we no longer have any coverage of the previous minimum version.
* All packages need to be updated to that minimum version. This can be trivially done with the repo tooling. E.g.:
`dart run script/tool/bin/flutter_plugin_tools.dart update-min-sdk --flutter-min=3.7.0`
* Per [repo policy](https://github.com/flutter/flutter/wiki/Contributing-to-Plugins-and-Packages#version), we do not version-bump these changes, so the associated `update-release-info` command should use `--version=next`. A convenient way to run the `update-release-info` command on only the necessary packages is to make the `update-min-sdk` run its own commit, then use `--base-branch HEAD^ --run-on-changed-packages` to target only the packages changed in that commit.
* This must be done in the same PR as the previous step, or CI will fail.
* The [release action](https://github.com/flutter/packages/blob/e7d812cefce083fa09762d25cd42303737d05b9f/.github/workflows/release.yml#L34) should be updated to use the new stable.
Many of these steps can be done separately, but they can also be done in combined PRs (as few as one). As an example, 3.13 was done in two PRs: [#4370](https://github.com/flutter/packages/pull/4730) and [#4371](https://github.com/flutter/packages/pull/4731).
### Issue Updates
Sweep all [`p: waiting for stable update` issues](https://github.com/flutter/flutter/labels/p%3A%20waiting%20for%20stable%20update), and update those that are now unblocked to indicate that they can now be addressed (removing the label).
For any that are about deprecated API usage, upgrade them to `P1`, and either find an owner for them or remove the owning team's `triaged-*` label, leaving a comment that the deprecated API usage needs to be removed ASAP to minimize future disruption to package clients.
* The motivation for treating these as P1 is that many clients do not update their packages (in particular, their transitive dependencies) frequently, so the further in advance of the eventual API *removal* the publishing of an update is, the fewer clients will have build errors on future updates of Flutter.
### PR Updates
Similarly sweep all [`p: waiting for stable update` PRs](https://github.com/flutter/packages/labels/waiting%20for%20stable%20update) and comment and remove labels as necessary.

View File

@@ -0,0 +1,237 @@
*If you haven't already read it, start with [the repository structure overview](https://github.com/flutter/flutter/wiki/Plugins-and-Packages-repository-structure) to familiarize yourself with the types of packages discussed below.*
## Types of Tests
Because of the complexities of having native code, plugins have many more types of tests than most other Flutter packages. A plugin will generally have some combination of the following:
- **Dart unit tests**. All plugin packages should have these, with the exception of a federated implementation package that contains only native code (i.e., one that only implements a shared method channel). In a plugin, Dart unit tests would cover:
- The Dart code in a monolithic plugin (generally using a mock method channel).
- The Dart code in an app-facing plugin package (using a mock implementation of the platform interface).
- The Dart code in a platform interface package that contains a shared method channel implementation (using a mock method channel).
- The Dart code of an implementation package, if any. Some federated implementations are pure Dart, and would be largely tested via unit tests, and some have Dart code binding to a package-internal method channel.
These should live in `test/`
- **Integration tests**. These use [the `integration_test` package](https://flutter.dev/docs/testing/integration-tests). Unlike Dart unit tests, integration tests run in the context of a Flutter application (the `example/` app), and can therefore load and exercise native plugin code. Almost all plugin packages other than the platform interface package should have these. The only exceptions would be:
- Plugins that need native UI tests (see below)
- Plugins that have pure Dart implementations which can be comprehensively tested with Dart unit tests.
These should live in `example/integration_tests/`
- **Native unit tests**. Most plugins that have native code should have unit tests for that native code. (Currently, many do not; fixing that is currently a priority for plugins work.) They are written as:
- Android: **JUnit** - These should live in `android/src/test/`
- iOS: **XCTest** - These should live in `example/ios/RunnerTests/` (**Note**: These are in the example directory, not the main package directory, because they are run via the example app's project)
- macOS: **XCTest** - These should live in `example/macos/RunnerTests/` (**Note**: These are in the example directory, not the main package directory, because they are run via the example app's project)
- Linux: **Google Test** - These should live in `linux/test/`, and be named `*_test.cc`.
- Windows: **Google Test** - These should live in `windows/test/`, and be named `*_test.cpp`.
- **Native UI tests**. Some plugins show native UI that the test must interact with (e.g., `image_picker`). For these normal integration tests won't work, as there is not way to drive the native UI from Dart. They are written as:
- Android: **Espresso**, via the [`espresso` plugin](https://pub.dev/packages/espresso) - These should live in `example/android/app/src/androidTest/`
- iOS: **XCUITest** - These should live in `example/ios/RunnerUITests/`
- macOS: **XCUITest** - These should live in `example/macos/RunnerUITests/`
- Windows and Linux: **TBD**, see [#70233 (Windows)](https://github.com/flutter/flutter/issues/70233) and [#70235 (Linux)](https://github.com/flutter/flutter/issues/70235)
## Running Tests
### Dart unit tests
These can be run like any other Flutter unit tests, either from your preferred Flutter IDE, or using `flutter test`. The one exception is unit tests for `*_web` packages, which must be run with `flutter test --platform=chrome`.
You can also run them via the [repository tools `drive-examples` command](https://github.com/flutter/packages/blob/main/script/tool/README.md):
```sh
dart run script/tool/bin/flutter_plugin_tools.dart drive-examples --packages=<name_of_plugin>
```
### Integration tests
To run the integration tests using Flutter test (while in a plugin directory):
```sh
cd example
flutter test integration_test
```
(optionally including a `-d <device>` flag to select the target device), or use the [repository tools `drive-examples` command](https://github.com/flutter/packages/blob/main/script/tool/README.md)
from the root of the repository:
```sh
dart run script/tool/bin/flutter_plugin_tools.dart drive-examples --packages=<name_of_plugin> --<platform>
```
To run integration tests as instrumentation tests on a local Android device:
```sh
cd example
flutter build apk
cd android && ./gradlew -Ptarget=$(pwd)/../test_driver/<name_of_plugin>_test.dart app:connectedAndroidTest
```
### Native tests
From a terminal (while at the repository root), use the [repository tools `native-test` command](https://github.com/flutter/packages/blob/main/script/tool/README.md). Examples:
```sh
# Unit and integration (UI) tests, multiple platforms
dart run script/tool/bin/flutter_plugin_tools.dart native-test --android --ios --packages=<some_plugin_name>
# iOS, integration tests only
dart run script/tool/bin/flutter_plugin_tools.dart native-test --ios --no-unit --packages=<some_plugin_name>
# Android, unit tests only
dart run script/tool/bin/flutter_plugin_tools.dart native-test --android --no-integration --packages=<some_plugin_name>
```
It's also possible to run them from native IDEs:
#### JUnit
Run from Android Studio once the example app is opened as an Android project
#### XCTest and XCUITest
[Run from Xcode](https://developer.apple.com/library/archive/documentation/DeveloperTools/Conceptual/testing_with_xcode/chapters/05-running_tests.html)
once the example app is opened as an Xcode project.
#### Google Test
For Windows plugins, Visual Studio should auto-detect the tests and allow running them as usual.
### Web Tests
Most web tests are written as Integration Tests because they need a web browser (like Chrome) to run. Web integration tests are located in the `example` directory of the `<plugin_name_web>` package.
To run web integration tests:
1. Check what version of Chrome is running on the machine you're running tests on.
2. Download and install the ChromeDriver for that version from here:
* https://chromedriver.chromium.org/downloads
3. Start ChromeDriver with:
```sh
chromedriver --port=4444
```
4. Run tests:
* **All:** from the root `plugins` directory, run:
```sh
dart run script/tool/bin/flutter_plugin_tools.dart drive-examples --packages=<plugin_name>/<plugin_name_web> --web
```
* **One:** `cd` into the `example` directory of the package, then run:
```sh
flutter drive -d web-server --web-port 7357 --browser-name chrome --driver test_driver/integration_test.dart --target integration_test/NAME_OF_YOUR_test.dart
```
All web packages contain a standard `test` directory in the root of the package that can be run with `flutter test`. In most cases, the test there will direct users to the Integration Tests that live in the `example` directory. In some cases (like `file_selector_web`), the directory contains actual Unit Tests that are not web-specific and can run in the Dart VM.
#### Mocks
Some packages (like `google_maps_flutter_web`) contain `.mocks.dart` files alongside the test files that use them.
Mock files are [generated by `package:mockito`](https://pub.dev/packages/mockito#lets-create-mocks). The contents of mock files can change with how the mocks are used within the tests, in addition to actual changes in the APIs they're mocking.
Mock files must be updated by running the following command:
```sh
flutter pub run build_runner build
```
## Adding tests
A PR changing a plugin [should add tests](https://github.com/flutter/flutter/wiki/Tree-hygiene#tests). Which type(s) of tests you should add will depend on what exactly you are changing. See below for some high-level guidance, but if you're not sure please ask in your PR or in `#hackers-ecosystem` [on Discord](https://github.com/flutter/flutter/wiki/Chat).
Hopefully the scaffolding to run the necessary kinds of tests are already in place for that plugin, in which case you just add tests to the existing files in the locations referenced above. If not, see below for more information about adding test scaffolding.
### FAQ: Do I need to add tests even if the part of the code I'm changing isn't already tested?
**Yes.** Much of the plugin code predates the current strict policy about testing, and as a result the coverage is not as complete as it should be. The goal of having a strict policy going forward is to ensure that the situation improves.
### What types of tests to add
The type(s) of tests to add depends on the details of the PR, and there is not always one right answer. Some high level principles to keep in mind:
- Your tests should cover all of the new code you've added whenever possible. For instance, if your change has an error path you should test both the normal path and the error path.
- Unit tests are more reliable, faster to run, and more precise at isolating bugs than integration tests, so it is generally good to have unit testing of any non-trivial logic.
- New functionality should generally include integration tests that validate that the feature works end to end. (In some cases asserting that the native code has done the right thing is impractical in a full integration test, however.)
Some specific guidelines about different test types:
- **Dart unit tests**: If you are changing Dart code, you should almost always have Dart unit tests as well. They are fast to run, and generally easy to write and maintain. Even if your Dart changes are just wiring a new parameter through an app-facing package to the platform interface, or a platform interface implementation to a method channel, Dart unit tests can easily validate that they are being passed through correctly at each step.
- Unless your change has no native code changes, remember that Dart unit tests **are not sufficient by themselves**. No native code is run as part of Dart unit tests.
- **Dart integration tests**: These are the only fully end-to-end tests for plugins, so should be written when possible. This is the only kind of test that can actually test the entire flow as it will be run by plugin clients. Some comment cases where they won't work, however:
- The test requires interacting with native UI (e.g., pushing a button in a modal dialog before the test can complete).
- The test requires inspecting native UI (e.g., changing the properties of a view inside a platform view provided by the native code—although in some cases it may be viable to write a special platform interface just for testing, that can query those properties from Dart via calls to native code).
- The test requires specific hardware state.
- **Native unit tests**: Native unit tests are the only way to unit-test native code; if your native code is non-trivial, then it should probably have native unit tests. In particular:
- It is often much easier to get complete coverage of edge cases in native unit tests than via full integration tests.
- If you need to mock out system components (such as hardware state), you'll need native unit tests.
- **Native integration tests**: These are usually the most complex to maintain (being both per-platform, and more likely to be flaky than unit tests), so use with caution. However, they are the only way to get end-to-end testing when interacting with native UI.
Some patterns to consider given all of the above:
- If Dart integration tests are viable, use that to ensure end-to-end behavior of the overall feature, and add Dart and/or native unit testing to cover specific implementation details.
- If the test requires interacting with native UI (e.g., image or file selection):
- use native integration tests to validate the overall flow, plus unit testing of specific details, or
- use native unit tests that are set up to test the native portion end to end (i.e., calling into the method channel entry point with a synthesized call, and checking the method call response) with the UI APIs stubbed out, plus Dart unit tests that everything is plumbed through from the Dart API surface to the method call, or
- use the first to validate basic functionality, and the second for edge cases that can't be easily tested that way.
- If the tests require mocking device state (e.g., camera), use native unit tests that are set up to test the native portion end to end (i.e., calling into the method channel entry point with a synthesized call, and checking the method call response) with the UI APIs stubbed out, plus Dart unit tests that everything is plumbed through from the Dart API surface to the method call.
### Adding test scaffolding
If a plugin is missing test scaffolding for the type of tests you want to add, you have several options:
- If it's simple to enable them, and you are comfortable making the changes, you can enable them as part of your PR.
- If it's non-trivial to enable them, but you are comfortable doing it, you can make a new PR that enables them with some minimal test, and ask for that to be reviewed and landed before continuing with your PR.
- If you aren't comfortable making the change, reach out [via Discord](https://github.com/flutter/flutter/wiki/Chat) and ask in `#hackers-ecosystem`.
Regardless of the approach you use, please reach out on Discord if a PR that sets up a new kind of test doesn't get reviewed within two weeks. Filling in the gaps in test scaffolding is a priority for the team, so we want to review such PRs quickly whenever possible.
See below for instructions on bringing up test scaffolding in a plugin (*does not yet cover all types of tests*):
#### Enabling XCTests or XCUITests
1. Open `<path_to_plugin>/example/ios/Runner.xcworkspace` using Xcode. (For macOS, replace `ios` with `macos`.)
1. Create a new "Unit Testing Bundle" or "UI Testing Bundle", depending on the type of test.
1. In the target options window, populate details as following, then click on "Finish".
* In the "product name" field, type "RunnerTests" or "RunnerUITests", depending on the type of test.
* In the "Team" field, select "None".
* Set the Organization Identifier to "dev.flutter.plugins".
* In the Language field, select "Objective-C" for iOS, or "Swift" for macOS.
* In the Project field, select the xcodeproj "Runner" (blue color).
* In the Target to be Tested, select xcworkspace "Runner" (white color).
* In the Build Settings tab, remove most of the target-level overrides that are generated by the
template. In particular:
* `CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER` is currently incompatible with Flutter.
* `IPHONEOS_DEPLOYMENT_TARGET` and `TARGETED_DEVICE_FAMILY` may cause issues running tests.
* The compiler settings (`CLANG_*`, `GCC_*`, and `MTL_*`) shouldn't be needed.
1. For XCTests, edit `example/ios/Podfile` (`example/macos/Podfile` for macOS) to add the following to the `target 'Runner' do` block:
```ruby
target 'RunnerTests' do
inherit! :search_paths
pod 'OCMock', '3.5'
end
```
The `OCMock` line is only necessary if your tests use OCMock.
1. A RunnerTests/RunnerUITests folder should be created and you can start hacking in the added `.m`/`.swift` file.
#### Enabling Android UI tests
1. Duplicate the `DartIntegrationTests.java` file from another plugin to `example/android/app/src/androidTest/java/io/flutter/plugins/DartIntegrationTest.java`
1. Create a file under `example/android/app/src/androidTest/java/` with a sub-path corresponding to the example app's package identifier from `example/android/app/src/main/AndroidManifest.xml`. The file should be called `FlutterActivityTest.java` (or if the example uses a custom MainActivity as its `android:name` in `AndroidManifest.xml`, `MainActivityTest.java`).
* For example, if `AndroidManifest.xml` uses `io.flutter.plugins.fooexample` as the package identifier, and `io.flutter.embedding.android.FlutterActivity` as its `android:name`, the file should be `example/android/app/src/androidTest/java/io/flutter/plugins/fooexample/FlutterActivityTest.java`.
The file should look like:
```
package io.flutter.plugins.fooexample;
import androidx.test.rule.ActivityTestRule;
import dev.flutter.plugins.integration_test.FlutterTestRunner;
import io.flutter.embedding.android.FlutterActivity;
import io.flutter.plugins.DartIntegrationTest;
import org.junit.Rule;
import org.junit.runner.RunWith;
@DartIntegrationTest
@RunWith(FlutterTestRunner.class)
public class FlutterActivityTest {
@Rule
public ActivityTestRule<FlutterActivity> rule = new ActivityTestRule<>(FlutterActivity.class);
}
```
Note:
* Update the `package` to match the actual package.
* If using a custom `MainActivity`, replace the `FlutterActivity` references with `MainActivity`.
1. Ensure that `example/android/app/build.gradle`'s `defaultConfig` section contains:
```
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
```

View File

@@ -0,0 +1,168 @@
The flutter/packages repository has a variety of tests; while many are relatively self-explanatory (for instance, a failure in `dart_unit_tests` in presubmit can be debugged simply by running the failing Dart unit tests locally), others are less straightforward to understand. This page covers test structure and details for the repository, and how to investigate failures.
# Structure
## Tooling
Almost every test run by CI is run via the [repository tooling](https://github.com/flutter/packages/tree/main/script/tool). In general, the CI configuration for a task is a minimal wrapper around one (or, rarely, more than one) repository tool command. This has several benefits:
- It makes it easy to run almost any failing CI task locally, using the same command.
- It makes transitioning between different CI systems relatively straightforward.
CI often runs commands via the `script/tool_runner.sh` script. This is just a thin wrapper that passes arguments that are commonly used for CI (such as `--packages-for-branch`, which makes CI behave differently depending on the branch being run) but are unlikely to be useful when running locally. To run a failing test locally, substitute [`dart run script/tool/bin/flutter_plugin_tools.dart`](https://github.com/flutter/packages/tree/main/script/tool#getting-started) for `script/tool_runner.sh`.
## Infrastructure
flutter/packages uses the same LUCI infrastructure as most of the rest of Flutter. The main exception is the `release` step, which uses GitHub Actions.
### LUCI
This is the CI system used by flutter/flutter and flutter/engine. For information about LUCI results pages, see [Understanding a LUCI build failure](https://github.com/flutter/flutter/wiki/Understanding-a-LUCI-build-failure).
#### Results
Results for LUCI runs are available on [the Packages dashboard](https://flutter-dashboard.appspot.com/#/build?repo=packages&branch=main).
#### Configuration
LUCI tasks are configured in `.ci.yaml`, and files in `.ci/`. To find the commands corresponding to a given failing target and task, look in `.ci.yaml` for `name: your-target-name-here`, find the YAML file listed in the `target_file` entry, and look in `.ci/targets/that_yaml_file_name.yaml`. Each task will be an entry in that file, which runs `script` (a file relative to the repository root, usually either `script/tool_runner.sh` or in `.ci/scripts/`), optionally with given `args`.
### GitHub Actions
#### Results
GitHub Actions results only show up [in the GitHub UI](https://github.com/flutter/packages/commits/main/packages): click a check mark (passed), red X (failed) or yellow circle (running) for the list of tasks.
#### Configuration
GitHub Actions tasks are configured in `.github/workflows/`.
## Test matrix
The overall testing structure for flutter/packages is:
- Most tests are run on only one host platform: Linux when possible, or the relevant platform if necessary (e.g., Windows target tests must run on Windows hosts, and iOS and macOS tests must run on macOS hosts).
- Most tests are run with both Flutter `master` and Flutter `stable` (see [discussion of supported platforms](https://github.com/flutter/flutter/wiki/Contributing-to-Plugins-and-Packages#supported-flutter-versions) for more details).
- Since in practice `stable`-only failures are very rare, CI is currently configured to only run `stable` in post-submit to reduce CI time and costs.
- Architecture coverage is as-needed; we generally don't duplicate tests across architectures. For plugins, where architecture is most likely to be an issue, we try to run:
- the majority of the tests (`*_platform_tests`) on the most popular architecture, and
- `build_all_packages` on the other.
This gives us build coverage on both architectures.
## Exclusions
Many test commands in the repository tooling are configured to make having no tests of that type an error, to avoid cases where packages are misconfigured such that we aren't running tests that we think they are (or that an important category of tests is just forgotten). In cases where a missing test is intentional, you can add it to the relevant [exclusion file](https://github.com/flutter/packages/tree/main/script/configs), which are files that are passed to the relevant CI runs.
Exclusions **must** include explanatory comments, and in cases where they are not intended to be permanent, a link to an issue tracking its removal.
# Specific tests
In addition to Dart unit tests, Dart integration tests, and for plugins the various kinds of [native plugin tests](https://github.com/flutter/flutter/wiki/Plugin-Tests), there are a number of tests that check for repository best practices or to catch problems that have affected packages in the past. As a rule of thumb, any time we find a bug or mistake only *after* publishing a package, we try to add a check for that in CI to prevent similar issues in the future.
Below are descriptions of many of the less self-evident CI tests, and common solution to failures. Anyone adding new tests is encouraged to document them here.
- **`submit-queue`**: This only shows in PRs (presubmit), and reflects the current state of the tree: if it is red, the tree is currently closed to commits (which can mean either that the tree is red, or that a recently landed PR is still running post-submit tests), and if it is green the tree is open. This has **no relation** to the PR itself, and as a PR author you do not need to do anything about it; Flutter team members monitor the state of the tree, and will handle failures.
- There is a known issue that sometimes causes the status of this check to be stale; the causes is unknown. If this happens (i.e., the check in red but the tree state as described in the Infrastructure section above is actually green), you an either update your PR by merging in the latest `main` to force updates, or you can reach out to a Flutter team member (in a comment on the PR, or in Discord) to override the incorrect check.
- **`*_platform_tests`**: This runs each package's integration tests on the given target platform, as well as any [native plugin tests](https://github.com/flutter/flutter/wiki/Plugin-Tests) for that platform. This can also include native-language-specific analysis or lint checks.
- **`analyze`**: The initial `analyze` step is a straightforward Dart `analyze` run, but the `pathified_analyze` step is more complicated; it is intended to find issues that will cause out-of-band breakage in our own repository when the change being tested is published (most commonly with federated plugins). It does this by finding all packages that have non-breaking-version changes in the PR, and then rewriting all references to those packages in the repository to be `path:` dependencies, then re-running analysis.
A failure here does not necessarily mean that the PR is wrong; because we use very strict analysis options, changes that are not considered breaking by Dart semver conventions can break our CI. Common sources of failures here include:
- Accidentally making a breaking change without making a major version change to the plugin.
- **Solution**: Fix the versioning.
- Deprecating something that is still in use by another package within the repository.
- **Solution**: Suppress the warnings with `// ignore: deprecated_member_use` annotations in the other packages using that method, [with a comment](https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#comment-all--ignores) linking to the issue that tracks updating it. Once it lands, do a follow-up PR to update the calls and remove the `ignore`s.
- Adding a new enum value. We generally do not consider this breaking, but use your judgement and discuss with your reviewer; consider whether it is likely that clients have critical logic that depends on exhaustively handling all enum values, and what the effects are likely to be for those use cases if a new value is added.
- **Solution**: If it's not treated as breaking, then temporary disable that analyzer warning while adding the value:
* In the PR that adds the value, suppress the warnings with `// ignore: exhaustive_cases` annotations, [with a comment](https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#comment-all--ignores) linking to the issue that tracks updating it.
* In the follow-up PR that picks up the new enum value and uses it, remove the `ignore`.
- **`legacy_version_analyze`**: Runs `analyze` with older versions of Flutter than the current `stable` on any package that claims to support them; see [the supported version policy](https://github.com/flutter/flutter/wiki/Contributing-to-Plugins-and-Packages#supported-flutter-versions) for details.
- **Solution**: Unless you have a specific need to keep support for the old version (unlikely), just update the Flutter constraint in `pubspec.yaml` to exclude the failing version(s) of Flutter.
- **`analyze_downgraded`**: Runs `analyze` after running a `pub downgrade`, to ensure that minimum constraints are correct (e.g., that you don't add usage of an API from version `x.1` of a dependency that is specified as `^x.0` in `pubspec.yaml`).
- **Solution**: Update the relevant constraint to the version that introduced the new APIs.
- **`*_build_all_packages`**: Builds all packages into the same application, to ensure that there are no conflicts between dependencies, as we generally want clients to be able to use the latest versions of any of our packages in the same project.
- **Solutions**:
- If possible, fix the conflict. E.g., if you update a dependency of one package to a new major version, do the same in other packages using that same dependency.
- Otherwise, temporarily add the necessary package(s) to the `exclude_all_packages_app.yaml` exclusion file (see discussion of exclusion files above).
- **`repo_checks`**: Enforces various best practices (formatting, style, common mistakes, etc.). In most cases, the error messages should give clear and actionable explanations of what is wrong and how to fix it. Some general notes on specific steps:
- **`license_script`**: All code files must have the repository copyright/license block at the top. In most cases a failure here just means you forgot to add the license to a new file.
- **`federated_safety_script`**: Changing interdependent sub-packages of a federated plugin in the same PR can mask serious issues, such as undesired breaking changes in platform APIs. See the documentation on [changing federated plugins](https://github.com/flutter/flutter/wiki/Contributing-to-Plugins-and-Packages#changing-federated-plugins) for next steps.
# Out-of-band failures
The flutter/packages repository is more prone to out-of-band failures—persistent failures that do not originate with a PR within the repository—than flutter/engine and flutter/flutter. These are more difficult to debug than most failures since the source may not be obvious, and can be difficult to resolve since there's not necessarily anything that can be reverted to fix them. This page collects information on sources of these failures to help debug and resolve them.
This section doesn't cover flakes. While these failures are easily confused with flakes at first, they can be distinguished by being persistent across retries, as well as showing up in in-progress PRs.
## Infrastructure
This category covers anything that is a function of the CI infrastructure itself: services, machines, etc. It occurs across all repositories, but instances may be specific to one repository.
### LUCI
LUCI tasks are run on Flutter-infrastructure-managed VMs, using an [out-of-repo recipe](https://flutter.googlesource.com/recipes/+/main/recipes/packages/packages.py). Since LUCI images are changed by infrastructure team rollouts, and recipes are out-of-repo, almost any LUCI change is out of band. Potential failure sources include:
- Images changes.
- Recipe changes (very uncommon now that the recipe is generic).
#### Distinguishing features
- May affect all of the LUCI tests.
- Image changes generally result in builds not proceeding at all due to missing dependencies.
- Recipe changes generally cause setup failures or failure to start the test.
#### Distinguishing features
- Usually easy to identify since failures are generally before the tests even run.
#### Investigation & resolution tips
- File an [infrastructure ticket](https://github.com/flutter/flutter/wiki/Infra-Ticket-Queue).
- Check the recipe file for recent changes.
### Firebase Test Lab (Also known as: "FTL")
Integration tests on Android are run in real devices through the Firebase Test Lab infrastructure by [the `firebase-test-lab` command in the repository tooling](https://github.com/flutter/packages/blob/main/script/tool/lib/src/firebase_test_lab_command.dart). From time to time, the Firebase Test Lab will change what devices are available for testing, and tests will start timing out.
#### Distinguishing features
- `firebase_test_lab` task starts timing out. The output is normally just: `Timed out!` ([Example](https://github.com/flutter/plugins/runs/3930255308).)
- These timeouts will start as "flake" tests, and get progressively worse, until no amount of "retries" helps them pass (as devices are phased out / less available).
- `firebase_test_lab` timing out is almost always related to this. Either because of devices becoming unavailable, or by a temporary lack of resource availability.
#### Investigation & resolution tips
- Check the [Deprecation List](https://firebase.google.com/docs/test-lab/android/available-testing-devices#deprecated_devices) in the Firebase documentation, and see if it affects any of the devices [used by the script](https://github.com/flutter/packages/blob/1598ccd896653cbe40b7401fb0eafd890e784b39/.ci/targets/android_device_tests.yaml#L14).
- Pick another device that is more available and update the script. See a [sample PR](https://github.com/flutter/plugins/pull/4436).
- It is likely that `flutter/engine` and `flutter/flutter` have had the same problem. Use the same devices picked by them.
## Publishing
There are some interdependencies between packages in the repository (notably federated plugins, but a few other cases as well, such as examples of one package that depend on another package). Inter-package dependencies are only tested with published versions ([#52115](https://github.com/flutter/flutter/issues/52115)), so publishing a package can potentially break other packages.
#### Distinguishing features
- Timing will correspond to a package being published. (With autorelease, this will be shortly after the version-updating PR lands, unless something goes wrong.)
- May have a clear reference to the published package in the failure.
- This is not guaranteed; e.g., Android plugin Gradle changes can have transitive effects on example apps that depend on those packages.
#### Investigation & resolution tips
- Pinning a specific dependency version can confirm or eliminate this as a source of errors.
- This should generally **not** be used as a mitigation; this category of error is often a failure that will affect clients of the package as well.
## External build dependencies
On platforms where the plugin system includes a dependency management system, there are build-time dependencies on external servers (e.g., Maven for Android, Cocoapods for iOS and macOS). Potential failure sources include:
- Temporary server outages.
- Removal of a package.
#### Distinguishing features
- The logs will be very clear that fetching a dependency failed.
- The only challenge in identifying them quickly is that they look the same as transient server or network issue flakes, which are much more common.
#### Investigation & resolution tips
- Check for reports of outages on the relevant servers.
- Check whether the entire server is failing, or only fetching a specific package is failing.
- Server-level outages are usually short-lived and just have to be waited out; i.e., they are persistent for a matter of hours before the server issue is resolved.
- Package issues may require repository changes. E.g., for Maven, switching to another server that has the package, or to another version of the package that is still available.
## `pub`
The `publish` command periodically enables new checks. Rarely, such a check will be enabled after presubmits for a PR have run, but before it's submitted.
#### Distinguishing features
- Either the `publish` validation step or the `release` step will fail with a clear error message from the `publish` command.
#### Investigation & resolution tips
- These are usually straightforward to resolve by fixing the newly-flagged issue.