Skip to content

Latest commit

 

History

History
269 lines (183 loc) · 9.96 KB

CONTRIBUTING.md

File metadata and controls

269 lines (183 loc) · 9.96 KB

Contributing to PlusPlugins

See also: Flutter's code of conduct

Types of contributions

We welcome all contributions to the project, however some contributions will need extra work in order to be accepted.

Here's some examples:

🟢 Easily accepted contributions

  • Fixing issues
  • Improving the README.md
  • Upgrading deprecated dependencies
  • Improving tests

🟡 Need extra consideration

  • New features covering all platforms

We need to make sure it works well before merging and each platform needs to be reviewed individually.

  • Changing a platform implementation

Ideally an expert in that platform will have to review the change to make sure it works as expected.

🔴 Cannot be accepted

  • New features covering only one platform

New features should cover at least the mobile platforms (Android and iOS) to be considered, and a plan for the rest must be provided.

  • New plugins

We don't have the capacity to accept new plugins.

Setup and running

Please follow this steps when working on the PlusPlugins.

1. Things you will need

2. Forking & cloning the repository

  • Ensure all the dependencies described in the previous section are installed.
  • Fork https://github.com/fluttercommunity/plus_plugins 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 to generate an SSH key.
  • git clone [email protected]:<your_name_here>/plus_plugins.git
  • git remote add upstream [email protected]:fluttercommunity/plus_plugins.git (So that you fetch from the master repository, not your clone, when running git fetch et al.)

3. Environment Setup

PlusPlugins uses Melos to manage the project and dependencies.

To install Melos, run the following command from your SSH client:

pub global activate melos

Next, at the root of your locally cloned repository bootstrap the projects dependencies:

melos bootstrap

The bootstrap command locally links all dependencies within the project without having to provide manual dependency_overrides. This allows all plugins, examples and tests to build from the local clone project.

You do not need to run flutter pub get once bootstrap has been completed.

4. Running an example

Each plugin provides an example app which aims to showcase the main use-cases of each plugin.

To run an example, run the flutter run command from the example directory of each plugins main directory. For example, for sensors_plus example:

cd packages/sensors_plus/sensors_plus/example
flutter run

Using Melos (installed in step 3), any changes made to the plugins locally will also be reflected within all example applications code automatically.

4. Running tests

PlusPlugins comprises of a number of tests for each plugin, either end-to-end (e2e) or unit tests.

Unit tests

Unit tests are responsible for ensuring expected behavior whilst developing the plugins Dart code. Unit tests do not interact with 3rd party services, and mock where possible. To run unit tests for a specific plugin, run the flutter test command from the plugins root directory. For example, sensors_plus platform interface tests can be run with the following commands:

cd packages/sensors_plus/sensors_plus
flutter test

End-to-end (e2e) tests

E2e tests are those which directly communicate with Flutter, whose results cannot be mocked. These tests run directly from an example application.

To run e2e tests, run the flutter drive command from the plugins main example directory, targeting the entry e2e test file.

cd packages/sensors_plus/sensors_plus/example
flutter drive --target=./test_driver/sensors_plus_e2e.dart

To run tests against web environments, run the command as a release build:

cd packages/sensors_plus/sensors_plus/example
flutter drive --target=./test_driver/sensors_plus_e2e.dart --release -d chrome

Using Melos

To help aid developer workflow, Melos provides a number of commands to quickly run tests against plugins. For example, to run all e2e tests across all plugins at once, run the following command from the root of your cloned repository:

# for mobile testing (Android or iOS)
melos run test:mobile_e2e

A full list of all commands can be found within the melos.yaml file.

5. Contributing code

We gladly accept contributions via GitHub pull requests.

Please peruse the Flutter style guide and design principles before working on anything non-trivial. These guidelines are intended to keep the code consistent and avoid common pitfalls.

5.1 Getting started

To start working on a patch:

  1. git fetch upstream
  2. git checkout upstream/main -b <name_of_your_branch>
  3. Hack away!

5.2 Check the code

Once you have made your changes, ensure that it passes the internal analyzer & formatting checks. The following commands can be run locally to highlight any issues before committing your code:

# Run the analyze check
melos run analyze

# Format code
melos run format

5.3 Update version and changelog

Before opening a Pull-Request, please increase the version number in the pubspec.yaml and create a new entry in the CHANGELOG.md describing the change. This will help us speed-up the release process for the provided fix or feature.

If updating a platform package (e.g. device_info_plus_macos), please remember to update version and changelog of the main package (e.g. device_info_plus).

More info about versioning can be found on semver.org.

5.4 Commit and push your changes

Assuming all is successful, commit and push your code:

  1. git commit -a -m "<your informative commit message>"
  2. git push origin <name_of_your_branch>

5.5 Create a pull request

To send us a pull request:

  • git pull-request (if you are using Hub) or go to https://github.com/fluttercommunity/plus_plugins and click the "Compare & pull request" button

Please make sure all your check-ins have detailed commit messages explaining the patch.

When naming the title of your pull request, please follow the Conventional Commits guide. For example, for a fix to the sensor_plus plugin:

fix(sensor_plus): fixed a bug!

Please also enable “Allow edits by maintainers”, this will help to speed-up the review process as well.

5.6 Now be patient :)

Plugins tests are run automatically on contributions using GitHub Actions. Depending on your code contributions, various tests will be run against your updated code automatically.

Once you've gotten an LGTM from a project maintainer and once your PR has received the green light from all our automated testing, wait for one the package maintainers to merge the pull request.

Please understand, that this repository is run by volunteers, and the response may be delayed.

The review process

Newly opened PRs first go through initial triage which results in one of:

  • Merging the PR - if the PR can be quickly reviewed and looks good.
  • Closing the PR - if the PR maintainer decides that the PR should not be merged.
  • Moving the PR to the backlog - if the review requires non trivial effort and the issue isn't a priority; in this case the maintainer will:
    • Make sure that the PR has an associated issue labeled with "plugin".
    • Add the "backlog" label to the issue.
    • Leave a comment on the PR explaining that the review is not trivial and that the issue will be looked at according to priority order.
  • Starting a non trivial review - if the review requires non trivial effort and the issue is a priority; in this case the maintainer will:
    • Add the "in review" label to the issue.
    • Self assign the PR.

The release process

We push releases manually, using Melos to take care of the hard work.

Some things to keep in mind before publishing the release:

  • Has CI ran on the master commit and gone green? Even if CI shows as green on the PR it's still possible for it to fail on merge, for multiple reasons. There may have been some bug in the merge that introduced new failures. CI runs on PRs as it's configured on their branch state, and not on tip of tree. CI on PRs also only runs tests for packages that it detects have been directly changed, vs running on every single package on master.
  • 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.

TODO(mhadaily): detail melos release process