Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ci/tool] Add external dependency validation #3466

Merged
merged 12 commits into from
Mar 17, 2023

Conversation

stuartmorgan
Copy link
Contributor

We've had a general policy of avoiding external dependencies for at least the last year, but it hadn't really been communicated or enforced. It's now documented in the wiki, and this adds tooling and CI that validates that every package we depend on here is either a) local to this repository, b) from the SDK, or c) in an explicit allow list config file.

This follows the general trend in the repository away from "hope people know/remember/check for all of the policies" to "validate in CI and require explicit opt-out for exceptions". Once this lands, I'll update the wiki to point to the relevant config files where exceptions should be added when we choose to make exceptions.

In most cases, this just allows everything we're already using. For some example and dev-only dependencies, this moves to pinning since that's a simple change to make.

See flutter/flutter#122713

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the relevant style guides and ran the auto-formatter. (Unlike the flutter/flutter repo, the flutter/packages repo does use dart format.)
  • I signed the CLA.
  • The title of the PR starts with the name of the package surrounded by square brackets, e.g. [shared_preferences]
  • I listed at least one issue that this PR fixes in the description above.
  • I updated pubspec.yaml with an appropriate new version according to the pub versioning philosophy, or this PR is exempt from version changes.
  • I updated CHANGELOG.md to add a description of the change, following repository CHANGELOG style.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is test-exempt.
  • All existing and new tests are passing.

Copy link
Contributor

@tarrinneal tarrinneal left a comment

Choose a reason for hiding this comment

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

optional nit, but seems good to me.

}

// Checks whether a given dependency is allowed.
bool _allowDependency(String name, Dependency dependency) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This method name seems a little off from what I would expect. Something like _isDependancyAllowed or something similar.

As is I would expect this to add the dep to an allow list. Up to you if you agree.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good call, changed to _shouldAllowDependency

@stuartmorgan stuartmorgan added override: no versioning needed Override the check requiring version bumps for most changes override: no changelog needed Override the check requiring CHANGELOG updates for most changes labels Mar 15, 2023
@stuartmorgan
Copy link
Contributor Author

Overrides: packages changes are to dev_dependencies, which are dev-only.

@jmagman
Copy link
Member

jmagman commented Mar 15, 2023

For some example and dev-only dependencies, this moves to pinning since that's a simple change to make.

Can we turn on dependabot for this case?

@stuartmorgan
Copy link
Contributor Author

Can we turn on dependabot for this case?

It's on my list to look into in general; currently we're not using it for Dart at all so I don't know how configurable it is. Ideally we'd use it for major versions of most dependencies, and now for other versions of these pinned items.

(For cases like mockito it's not clear if it would be useful since we'd want to actually regenerate the mocks, not just update the pin.)

Copy link
Member

@jmagman jmagman left a comment

Choose a reason for hiding this comment

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

LGTM

script/tool/lib/src/pubspec_check_command.dart Outdated Show resolved Hide resolved
script/tool/lib/src/pubspec_check_command.dart Outdated Show resolved Hide resolved
Copy link
Member

@ditman ditman left a comment

Choose a reason for hiding this comment

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

LGTM! I have 2 deps to remove. (jwt_decoder and mocktail)

script/configs/allowed_pinned_deps.yaml Show resolved Hide resolved
@@ -21,4 +21,4 @@ dev_dependencies:
sdk: flutter
integration_test:
sdk: flutter
mocktail: ^0.3.0
mocktail: 0.3.0
Copy link
Member

@ditman ditman Mar 16, 2023

Choose a reason for hiding this comment

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

giphy

(My bad, this should have never happened in the first place)

Copy link
Member

@cbracken cbracken left a comment

Choose a reason for hiding this comment

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

This makes me happier than I can express in a single lgtm.

Copy link
Contributor

@chunhtai chunhtai left a comment

Choose a reason for hiding this comment

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

LGTM

@stuartmorgan stuartmorgan added the autosubmit Merge PR when tree becomes green via auto submit App label Mar 16, 2023
@auto-submit auto-submit bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Mar 16, 2023
@auto-submit
Copy link
Contributor

auto-submit bot commented Mar 16, 2023

auto label is removed for flutter/packages, pr: 3466, Failed to merge pr#: 3466 with Pull request could not be merged: Pull Request is not mergeable.

@stuartmorgan stuartmorgan added the autosubmit Merge PR when tree becomes green via auto submit App label Mar 17, 2023
@auto-submit auto-submit bot merged commit 9b136a9 into flutter:main Mar 17, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Mar 17, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Mar 17, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Mar 20, 2023
tarrinneal pushed a commit to flutter/flutter that referenced this pull request Mar 20, 2023
* 7636eb7 [go_router_builder] Support default value for `Set`, `List` and `Iterable` route parameters (flutter/packages#3391)

* 26c95da [image_picker] Move HashSet construction within if-statement (flutter/packages#3448)

* f5687b2 [image_picker] fix typos in comments (flutter/packages#3413)

* 84afba7 [image_picker] Migrate Android to Pigeon (flutter/packages#3476)

* 42927fc [image_picker]: Bump androidx.exifinterface:exifinterface from 1.3.3 to 1.3.6 in /packages/image_picker/image_picker_android/android (flutter/packages#3238)

* 9a44bdf Require Dart SDK 2.14, because of using APIs. (flutter/packages#3468)

* 12609a2 [ci] Clean up iOS simulators (flutter/packages#3458)

* 9b136a9 [ci/tool] Add external dependency validation (flutter/packages#3466)

* 11aab47 Manual roll Flutter from fb7e828 to 67e5f66 (8 revisions) (flutter/packages#3482)

* 784291b Update goldens (flutter/packages#3442)

* 43a42d1 [webview_flutter_android] Updates Dart and Java InstanceManagers (flutter/packages#3282)

* d0de136 [camera] Reland android flip/change camera while recording (flutter/packages#3460)

* 74fd094 [image_picker_android] Adjust file extension in FileUtils when it does not match its mime type (flutter/packages#3409)

* d2f1d2d [flutter_adaptive_scaffold] : 🐛 [FIX] : Issue: 121135. (flutter/packages#3253)

* 3d078b5 Roll Flutter from 67e5f66 to 53dfd23 (39 revisions) (flutter/packages#3484)

* 3b3a09d [url_launcher] Convert iOS to Pigeon (flutter/packages#3481)

* 80cd50a Roll Flutter from 53dfd23 to 6bd2b3c (17 revisions) (flutter/packages#3486)

* 998bb29 [webview_flutter] Updates the README with the migration of `WebView.initialCookies` and Hybrid Composition on (flutter/packages#3470)

* bbf86a7 Roll Flutter from 6bd2b3c to 3e4e092 (7 revisions) (flutter/packages#3490)
nploi pushed a commit to nploi/packages that referenced this pull request Jul 16, 2023
[ci/tool] Add external dependency validation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants