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

Add CI steps to test iOS and macOS plugins with both CocoaPods and Swift Package Manager #6557

Merged
merged 6 commits into from
Apr 24, 2024

Conversation

vashworth
Copy link
Contributor

Tests new Swift Package Manager feature added in flutter/flutter#146256.

Fixes flutter/flutter#146901.

Pre-launch Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@@ -9,9 +9,12 @@ tasks:
script: .ci/scripts/tool_runner.sh
args: ["fetch-deps", "--ios", "--supporting-target-platforms-only"]
infra_step: true
- name: build examples
- name: build examples with CocoaPods integration
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we need to build-all twice; there's already some redundancy in the build-all app vs individual example builds. We use that redundancy to get x64/arm64 coverage already, and I would vote for doing the same thing here.

To do that we would remove this step, and only build-all with SPM. That gives us SPM build coverage of all plugin in this step, and CocoaPods coverage in all the example app builds. Then when the flag is removed or reversed, we switch build-all to force SPM off and reverse the coverage roles.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So if I understand correctly, you're suggesting we update build-all (https:/flutter/packages/blob/main/.ci/targets/ios_build_all_packages.yaml / https:/flutter/packages/blob/main/.ci/scripts/build_all_packages_app.sh) to have SPM enabled so it builds all with SPM.

And then in platform tests (this file), only build with CocoaPods?

Just a reminder, native tests will need to be run with SPM enabled because CocoaPod testing dependencies will have been removed (see "Updating unit tests in plugin example app"), which will make native tests not be able to be run without SPM. But we can still do what you're suggesting and just add a new step to the yaml that enables SPM

- name: native test
script: .ci/scripts/tool_runner.sh
# Simulator name and version must match name and version in create_simulator.sh
args: ["native-test", "--ios", "--ios-destination", "platform=iOS Simulator,name=Flutter-iPhone,OS=17.0"]

Copy link
Contributor

Choose a reason for hiding this comment

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

And then in platform tests (this file), only build with CocoaPods?

Whoops, I was skimming and thought this was the build-all step. But yes, thanks for figuring out what I meant despite the confusing description.

Just a reminder, native tests will need to be run with SPM enabled because CocoaPod testing dependencies will have been removed

Right, I forgot about that.

I guess we could flip it around from the start, and do the SPM testing in-package, and the CocoaPod testing only in build-all (and, until the flag reaches stable, in stable post-submit). The reason I was thinking we should start the other way is that we could potentially break the example app for people who don't have the flag enabled without noticing if we only tested SPM in-package, but the impact of that if it happens is extremely small, so probably not worth worrying about unless it actually starts happening in practice.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The reason I was thinking we should start the other way is that we could potentially break the example app for people who don't have the flag enabled without noticing if we only tested SPM in-package

So the way I currently have set up, it builds the example app with the flag disabled, then it builds with the flag enabled, then it runs tests (still with the flag enabled).

So the example app builds with both the flag disabled (aka CocoaPods only) and enabled. I'm inclined to keep it this way so we can be sure the example app works both ways.

As for build-all, we could also do it twice - once with it disabled and once with it enabled?

Copy link
Contributor

Choose a reason for hiding this comment

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

So the example app builds with both the flag disabled (aka CocoaPods only) and enabled. I'm inclined to keep it this way so we can be sure the example app works both ways.

The problem is that adds about 5 minutes to each shard (a roughly 25-33% increase). If the only thing we get from that is coverage of an example app that almost nobody but us runs most of the time, and doesn't affect production clients, I don't think that's a good tradeoff of CI resources.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Gotcha, then yeah I think we keep build-all using CocoaPods and do platform tests with SPM (because the example app has to be built with SPM so native tests use SPM).

@vashworth vashworth marked this pull request as ready for review April 19, 2024 17:45
@vashworth
Copy link
Contributor Author

@stuartmorgan friendly ping

Copy link
Contributor

@stuartmorgan stuartmorgan left a comment

Choose a reason for hiding this comment

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

LGTM with one change.

await processRunner.runAndStream(
flutterCommand,
<String>['config', '--enable-swift-package-manager'],
exitOnError: true,
Copy link
Contributor

Choose a reason for hiding this comment

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

This will explode on our stable tests (which you aren't seeing in presubmit because we only run native stable tests on post-submit to reduce CI utilization). You'll need to gate either the whole call, or just exiting on failure, on a Platform.environment['CHANNEL'] != 'stable' check for now, with a TODO to enable it for stable once the flag is available there.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

@stuartmorgan stuartmorgan left a comment

Choose a reason for hiding this comment

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

LGTM!

@vashworth vashworth added the autosubmit Merge PR when tree becomes green via auto submit App label Apr 24, 2024
@auto-submit auto-submit bot merged commit 1292dc3 into flutter:main Apr 24, 2024
78 checks passed
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Apr 25, 2024
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request Apr 25, 2024
flutter/packages@cf6d280...fde908d

2024-04-25 49699333+dependabot[bot]@users.noreply.github.com Bump actions/checkout from 4.1.3 to 4.1.4 (flutter/packages#6609)
2024-04-24 [email protected] [go_router] Add `GoRouterState state` parameter to `GoRouterData.onExit` (flutter/packages#6495)
2024-04-24 [email protected] Add CI steps to test iOS and macOS plugins with both CocoaPods and Swift Package Manager (flutter/packages#6557)
2024-04-24 [email protected] Roll Flutter from 77043ba to dba4f77 (30 revisions) (flutter/packages#6607)
2024-04-24 [email protected] [camera] Finish converting iOS to Pigeon (flutter/packages#6601)
2024-04-24 [email protected] [go_router] Fixes an issue where route future does not complete when â�¦ (flutter/packages#6596)
2024-04-24 98614782+auto-submit[bot]@users.noreply.github.com Reverts "Bump legacy all_packages project AGP version to 7.0.0, Gradle version to 7.0.2 (#6591)" (flutter/packages#6605)
2024-04-23 [email protected] [in_app_purchase_android] Readme update for Alternative billing (flutter/packages#6578)
2024-04-23 [email protected] Bump legacy all_packages project AGP version to 7.0.0, Gradle version to 7.0.2 (flutter/packages#6591)
2024-04-23 [email protected] Roll Flutter from 140edb9 to 77043ba (21 revisions) (flutter/packages#6599)
2024-04-23 49699333+dependabot[bot]@users.noreply.github.com Bump github/codeql-action from 3.25.1 to 3.25.2 (flutter/packages#6597)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages-flutter-autoroll
Please CC [email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Flutter: https:/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
TecHaxter pushed a commit to TecHaxter/flutter_packages that referenced this pull request May 22, 2024
arc-yong pushed a commit to Arctuition/packages-arc that referenced this pull request Jun 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
autosubmit Merge PR when tree becomes green via auto submit App
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update packages CI to test Swift Package Manager integration for plugins
2 participants