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 The Ability To Generate Plugins From The CLI Tool #2144

Merged
merged 28 commits into from
Jun 25, 2024

Conversation

mcmah309
Copy link
Contributor

@mcmah309 mcmah309 commented Jun 22, 2024

Changes

closes #2143

Adds the template field to flutter_rust_bridge_codegen create --template plugin (similar to flutter create --template plugin) and type to flutter_rust_bridge_codegen integrate --template plugin. As well as opens the door for more templates going forward.

Notes For Reviewers

There appear to be a lot of code changes, but that is mainly due to frb_codegen/assets/integration_template being split into shared, app, and plugin. And updating frb_example/flutter_package

Checklist

  • An issue to be fixed by this PR is listed above.
  • New tests are added to ensure new features are working. Please refer to this page to see how to add a test.
  • ./frb_internal precommit --mode slow (or fast) is run (it internal runs code generator, does auto formatting, etc).
  • If this PR adds/changes features, documentations (in the ./website folder) are updated.
  • CI is passing. Please refer to this page to see how to solve a failed CI.

Remark for PR creator

  • ./frb_internal --help shows utilities for development.
  • If fzyzcjy does not reply for a few days, maybe he just did not see it, so please ping him.

Copy link

welcome bot commented Jun 22, 2024

Hi! Thanks for opening this pull request! 😄

@mcmah309 mcmah309 marked this pull request as draft June 22, 2024 14:36
@mcmah309
Copy link
Contributor Author

mcmah309 commented Jun 22, 2024

@fzyzcjy could I get your thoughts on this PR when you have the chance? Not sure if I covered all the related changes for a release - if any changes are needed to adjust generation of frb_codegen/assets/integration_template/shared. If all looks good, I can update the docs and change status to ready for review.

@fzyzcjy
Copy link
Owner

fzyzcjy commented Jun 22, 2024

Good job! Some nits

  • Maybe we can make integrate and create use the same flag (e.g. both use template) to avoid confusion. (Or, do you choose type because there are some conventions there)
  • To test it, try to mimic how flutter_via_create is tested. More specifically, (1) add a line probably below (2) Add a line below
    - frb_example--flutter_via_integrate
    . The test may name flutter_package. The "generate_run_frb_codegen_command_integrate" test means nothing but "let's run the codegen create/integrate command and check the result agrees with existing code".

You can test any CI thing locally by copy-paste-run the ./frb_internal ... command in corresponding CI section.

@mcmah309 mcmah309 marked this pull request as ready for review June 23, 2024 22:23
@mcmah309
Copy link
Contributor Author

mcmah309 commented Jun 23, 2024

@fzyzcjy2 Thanks for the feedback!

  • Changed to template
  • Added tests

This should be ready for review. I was unable to get some commands with ./frb_internal working locally like ./frb_internal precommit --mode slow or ./frb_internal generate-run-frb-codegen-command-integrate --set-exit-if-changed --package frb_example--flutter_via_integrate --coverage. Issues seem to stem from running in dev container, and also running flutter 3.22.2. Side note: fvm does not currently work in dev containers (I run NixOs so dev containers are a must) issue link. So I had to update flutter_package manually which will likely fail the ci since the ci is using 3.22.0. Rather than further banging my head against a wall to get things to work in my environment, I'd ask you or someone else to make the project file changes that satisfy the git diff tests. Running everything by hand locally looks fine though.

In the future, we may want to separate flutter_package into flutter_package_via_create and flutter_package_via_integrate like you did with flutter_via_create and flutter_via_integrate. But I do think diff testing may be a development bottleneck and I recommend creating projects then invoking their integration_test suites instead. But that is just a matter of opinion.

Also, it may be worth while to attach a dev Containerfile to the this project for development. That way local dev and ci dev can be seamless. I know I would appreciate it.

@fzyzcjy
Copy link
Owner

fzyzcjy commented Jun 24, 2024

Looks great! (Btw you mentioned the wrong account ;) that account is to auto publish new versions of flutter_rust_bridge).

Ok, I will run the diff generation later.

But I do think diff testing may be a development bottleneck and I recommend creating projects then invoking their integration_test suites instead.

IMHO we do diff testing because, we want to know whether the codegen create command really works or not.

Also, it may be worth while to attach a dev Containerfile to the this project for development. That way local dev and ci dev can be seamless. I know I would appreciate it.

That's interesting, and feel free to PR for this!

Copy link
Owner

@fzyzcjy fzyzcjy left a comment

Choose a reason for hiding this comment

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

Well done, and mainly some nits!

.fvm/fvm_config.json Outdated Show resolved Hide resolved
frb_codegen/src/binary/commands.rs Outdated Show resolved Hide resolved
frb_codegen/src/library/commands/flutter.rs Outdated Show resolved Hide resolved
frb_codegen/src/library/integration/integrator.rs Outdated Show resolved Hide resolved
tools/frb_internal/lib/src/makefile_dart/release.dart Outdated Show resolved Hide resolved
website/docs/manual/integrate/04-flutter-package.md Outdated Show resolved Hide resolved
frb_codegen/src/library/misc/mod.rs Outdated Show resolved Hide resolved
frb_codegen/src/library/integration/utils.rs Outdated Show resolved Hide resolved
frb_codegen/src/library/integration/integrator.rs Outdated Show resolved Hide resolved
@mcmah309
Copy link
Contributor Author

mcmah309 commented Jun 24, 2024

Looks great! (Btw you mentioned the wrong account ;) that account is to auto publish new versions of flutter_rust_bridge).

Oh haha my bad.

Ok, I will run the diff generation later.

Thanks!

IMHO we do diff testing because, we want to know whether the codegen create command really works or not.

Well the best way to test if it works IMHO is to actually run the code. That's what I meant by

I recommend creating projects then invoking their integration_test suites instead.

Like

flutter_rust_bridge_codegen create flutter_package --template plugin &&
flutter test flutter_package/example/integration_test/simple_test.dart &&
rm -r flutter_package

(probably best run the test for each platform).
rather than running into constant diff discrepancies.

That's interesting, and feel free to PR for this!

I may do that. I could get started at least, write a ticket for what needs to be done and setup rust/flutter in a Containerfile and .devcontainer. Then someone else may be best take over from there. Not super familiar with github ci or additional dev dependency issues I ran into earlier.

This should be good to review again/respond to my responses.

@mcmah309 mcmah309 requested a review from fzyzcjy June 24, 2024 08:58
@fzyzcjy
Copy link
Owner

fzyzcjy commented Jun 24, 2024

Well the best way to test if it works IMHO is to actually run the code.

We have two things on ci indeed:

  1. diff test: generate it and see it matches
  2. running test: run and test the commited code

I may do that. I could get started at least, write a ticket for what needs to be done and setup rust/flutter in a Containerfile and .devcontainer. Then someone else may be best take over from there. Not super familiar with github ci or additional dev dependency issues I ran into earlier.

That looks pretty reasonable!

Copy link
Owner

@fzyzcjy fzyzcjy left a comment

Choose a reason for hiding this comment

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

LGTM, only a nit!

frb_codegen/src/library/integration/integrator.rs Outdated Show resolved Hide resolved
@mcmah309 mcmah309 requested a review from fzyzcjy June 24, 2024 15:53
Copy link

codecov bot commented Jun 24, 2024

Codecov Report

Attention: Patch coverage is 0% with 165 lines in your changes missing coverage. Please review.

Project coverage is 96.30%. Comparing base (a1328d3) to head (4a99351).

Files Patch % Lines
frb_codegen/src/library/integration/integrator.rs 0.00% 89 Missing ⚠️
frb_codegen/src/library/integration/utils.rs 0.00% 35 Missing ⚠️
frb_codegen/src/library/integration/creator.rs 0.00% 29 Missing ⚠️
frb_codegen/src/binary/commands.rs 0.00% 6 Missing ⚠️
frb_codegen/src/library/commands/flutter.rs 0.00% 4 Missing ⚠️
frb_codegen/src/main.rs 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2144      +/-   ##
==========================================
- Coverage   99.08%   96.30%   -2.79%     
==========================================
  Files         486      487       +1     
  Lines       19991    20029      +38     
==========================================
- Hits        19809    19289     -520     
- Misses        182      740     +558     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Owner

@fzyzcjy fzyzcjy 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 will keep it unmerged for a bit of time (maybe 1d?), since need to run codegen etc for this as mentioned above

@fzyzcjy
Copy link
Owner

fzyzcjy commented Jun 25, 2024

@all-contributors please add @mcmah309 for code

Copy link
Contributor

@fzyzcjy

I've put up a pull request to add @mcmah309! 🎉

@fzyzcjy fzyzcjy changed the base branch from master to feat/12413 June 25, 2024 09:50
@fzyzcjy fzyzcjy merged commit e72172f into fzyzcjy:feat/12413 Jun 25, 2024
1 check passed
Copy link

welcome bot commented Jun 25, 2024

Hi! Congrats on merging your first pull request! 🎉

@fzyzcjy
Copy link
Owner

fzyzcjy commented Jun 25, 2024

Update: #2156 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add The Ability To Generate Plugins From The CLI Tool
2 participants