diff --git a/.github/workflows/.env b/.github/workflows/.env new file mode 100644 index 0000000..17f326f --- /dev/null +++ b/.github/workflows/.env @@ -0,0 +1 @@ +FLUTTER_VERSION=3.22.2 \ No newline at end of file diff --git a/.github/workflows/pull-request.yaml b/.github/workflows/pull-request.yaml new file mode 100644 index 0000000..f50ece7 --- /dev/null +++ b/.github/workflows/pull-request.yaml @@ -0,0 +1,66 @@ +name: Pull request checks + +on: + pull_request: + branches: [main] + workflow_call: + +jobs: + analyze: + runs-on: ubuntu-latest + timeout-minutes: 5 + steps: + - name: ๐Ÿ“š Git Checkout + uses: actions/checkout@v4 + + - id: dotenv + uses: falti/dotenv-action@v1.0.4 + with: + path: .github/workflows/.env + + - name: ๐Ÿ’™ Install Flutter + uses: subosito/flutter-action@v2.9.1 + with: + flutter-version: ${{ steps.dotenv.outputs.flutter_version }} + channel: "stable" + cache: true + cache-key: ${{ runner.os }}-flutter-${{ steps.dotenv.outputs.flutter_version }} + cache-path: ${{ runner.tool_cache }}/flutter-${{ steps.dotenv.outputs.flutter_version }} + + - name: ๐ŸŸ  Install Dependencies + uses: bluefireteam/melos-action@v1 + + - name: ๐Ÿง Analyze + run: melos analyze + + test-extensions: + needs: analyze + runs-on: ubuntu-latest + timeout-minutes: 10 + + steps: + - name: ๐Ÿ“š Git Checkout + uses: actions/checkout@v4 + + - id: dotenv + uses: falti/dotenv-action@v1.0.4 + with: + path: .github/workflows/.env + + - name: ๐Ÿ’™ Install Flutter + uses: subosito/flutter-action@v2.9.1 + with: + flutter-version: ${{ steps.dotenv.outputs.flutter_version }} + channel: "stable" + cache: true + cache-key: ${{ runner.os }}-flutter-${{ steps.dotenv.outputs.flutter_version }} + cache-path: ${{ runner.tool_cache }}/flutter-${{ steps.dotenv.outputs.flutter_version }} + + - name: ๐ŸŸ  Install Dependencies + run: flutter pub get + + - name: โœ… Run tests + run: flutter test --coverage --no-pub --test-randomize-ordering-seed random + + - name: ๐Ÿ’ฏ Check coverage + uses: VeryGoodOpenSource/very_good_coverage@v3 diff --git a/.gitignore b/.gitignore index c7f77dc..57893b7 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,5 @@ -.dart_tool \ No newline at end of file +.dart_tool +*coverage/ +melos_riverpod_community_extensions.iml +*build/ +.idea diff --git a/CONTRIBUTE.md b/CONTRIBUTE.md new file mode 100644 index 0000000..f0dbb04 --- /dev/null +++ b/CONTRIBUTE.md @@ -0,0 +1,47 @@ +## How to Contribute ๐Ÿค + +If you want to report a bug, suggest an enhancement, or contribute to this project, you can leave an issue or open a pull request. Here are some guidelines to help you get started: + +- Be respectful and considerate when interacting with other contributors. +- If you want to report a bug, provide a detailed description of the bug, including the steps to reproduce it. +- Clearly describe the issue or enhancement you are reporting or suggesting. +- When opening a pull request, provide a clear and concise description of the changes you have made. +- Write meaningful commit messages that accurately describe the changes made in each commit. +- Make sure to run tests and ensure that all tests are passing before submitting a pull request. + +## Running Tests ๐Ÿงช + +This project uses [melos][melos_link] for convenience scripts such as running tests and coverage. All of these scripts can be run from any directory in the project, and are defined in the root `melos.yaml` file. + +To activate melos, run the following command: + +```sh +dart pub global activate melos +``` + +After that, to run all unit tests: + +```sh +melos test +``` + +To run all tests and generate coverage report: + +```sh +melos test:cov +``` + +To view the generated coverage report using [lcov][lcov_link] in your browser, run: + +```sh +melos open:cov +``` + +If you want to reproduce the CI analyze job locally, you can run: + +```sh +melos analyze +``` + +[melos_link]: https://melos.invertase.dev/ +[lcov_link]: https://github.com/linux-test-project/lcov diff --git a/README.md b/README.md index 2fadf9c..c10f224 100644 --- a/README.md +++ b/README.md @@ -18,34 +18,6 @@ dart pub add riverpods_community_extensions --- -## Continuous Integration ๐Ÿค– - -Riverpods Community Extensions comes with a built-in [GitHub Actions workflow][github_actions_link] powered by [Very Good Workflows][very_good_workflows_link] but you can also add your preferred CI/CD solution. - -Out of the box, on each pull request and push, the CI `formats`, `lints`, and `tests` the code. This ensures the code remains consistent and behaves correctly as you add functionality or make changes. The project uses [Very Good Analysis][very_good_analysis_link] for a strict set of analysis options used by our team. Code coverage is enforced using the [Very Good Workflows][very_good_coverage_link]. - ---- - -## Running Tests ๐Ÿงช - -To run all unit tests: - -```sh -dart pub global activate coverage 1.2.0 -dart test --coverage=coverage -dart pub global run coverage:format_coverage --lcov --in=coverage --out=coverage/lcov.info -``` - -To view the generated coverage report you can use [lcov](https://github.com/linux-test-project/lcov). - -```sh -# Generate Coverage Report -genhtml coverage/lcov.info -o coverage/ - -# Open Coverage Report -open coverage/index.html -``` - [dart_install_link]: https://dart.dev/get-dart [github_actions_link]: https://docs.github.com/en/actions/learn-github-actions [license_badge]: https://img.shields.io/badge/license-MIT-blue.svg diff --git a/melos.yaml b/melos.yaml new file mode 100644 index 0000000..2ace245 --- /dev/null +++ b/melos.yaml @@ -0,0 +1,36 @@ +name: riverpod_community_extensions + +packages: + - . + +scripts: + analyze: + exec: | + dart analyze . && \ + dart format --set-exit-if-changed lib test + description: Run analyzer + + test: + exec: flutter test --no-pub --test-randomize-ordering-seed random + description: Run tests + fix: + exec: | + dart fix . --apply && \ + dart format lib test + description: Run fix + test:cov: + exec: | + rm -rf coverage && \ + flutter test --coverage --no-pub --test-randomize-ordering-seed random && \ + genhtml coverage/lcov.info -o coverage && \ + coverde value -i coverage/lcov.info + description: Run test with coverage + test:cov:check: + exec: | + melos test:cov && \ + coverde check 100 -i coverage/lcov.info + description: Check test coverage + open:cov: + exec: | + open coverage/index.html + description: Open test coverage \ No newline at end of file diff --git a/pubspec.lock b/pubspec.lock index 245e2a6..825e49c 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -17,6 +17,14 @@ packages: url: "https://pub.dev" source: hosted version: "6.3.0" + ansi_styles: + dependency: transitive + description: + name: ansi_styles + sha256: "9c656cc12b3c27b17dd982b2cc5c0cfdfbdabd7bc8f3ae5e8542d9867b47ce8a" + url: "https://pub.dev" + source: hosted + version: "0.3.2+1" args: dependency: transitive description: @@ -41,6 +49,38 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.1" + charcode: + dependency: transitive + description: + name: charcode + sha256: fb98c0f6d12c920a02ee2d998da788bca066ca5f148492b7085ee23372b12306 + url: "https://pub.dev" + source: hosted + version: "1.3.1" + cli_launcher: + dependency: transitive + description: + name: cli_launcher + sha256: "5e7e0282b79e8642edd6510ee468ae2976d847a0a29b3916e85f5fa1bfe24005" + url: "https://pub.dev" + source: hosted + version: "0.3.1" + cli_util: + dependency: transitive + description: + name: cli_util + sha256: c05b7406fdabc7a49a3929d4af76bcaccbbffcbcdcf185b082e1ae07da323d19 + url: "https://pub.dev" + source: hosted + version: "0.4.1" + clock: + dependency: transitive + description: + name: clock + sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf + url: "https://pub.dev" + source: hosted + version: "1.1.1" collection: dependency: transitive description: @@ -49,6 +89,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.18.0" + conventional_commit: + dependency: transitive + description: + name: conventional_commit + sha256: dec15ad1118f029c618651a4359eb9135d8b88f761aa24e4016d061cd45948f2 + url: "https://pub.dev" + source: hosted + version: "0.6.0+1" convert: dependency: transitive description: @@ -61,10 +109,10 @@ packages: dependency: transitive description: name: coverage - sha256: ac86d3abab0f165e4b8f561280ff4e066bceaac83c424dd19f1ae2c2fcd12ca9 + sha256: "3945034e86ea203af7a056d98e98e42a5518fff200d6e8e6647e1886b07e936e" url: "https://pub.dev" source: hosted - version: "1.7.1" + version: "1.8.0" crypto: dependency: transitive description: @@ -97,6 +145,22 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.2" + graphs: + dependency: transitive + description: + name: graphs + sha256: aedc5a15e78fc65a6e23bcd927f24c64dd995062bcd1ca6eda65a3cff92a4d19 + url: "https://pub.dev" + source: hosted + version: "2.3.1" + http: + dependency: transitive + description: + name: http + sha256: "761a297c042deedc1ffbb156d6e2af13886bb305c2a343a4d972504cd67dd938" + url: "https://pub.dev" + source: hosted + version: "1.2.1" http_multi_server: dependency: transitive description: @@ -113,6 +177,14 @@ packages: url: "https://pub.dev" source: hosted version: "4.0.2" + intl: + dependency: transitive + description: + name: intl + sha256: d6f56758b7d3014a48af9701c085700aac781a92a87a62b1333b46d8879661cf + url: "https://pub.dev" + source: hosted + version: "0.19.0" io: dependency: transitive description: @@ -129,6 +201,14 @@ packages: url: "https://pub.dev" source: hosted version: "0.6.7" + json_annotation: + dependency: transitive + description: + name: json_annotation + sha256: "1ce844379ca14835a50d2f019a3099f419082cfdd231cd86a142af94dd5c6bb1" + url: "https://pub.dev" + source: hosted + version: "4.9.0" logging: dependency: transitive description: @@ -141,18 +221,26 @@ packages: dependency: transitive description: name: matcher - sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e" + sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb + url: "https://pub.dev" + source: hosted + version: "0.12.16+1" + melos: + dependency: "direct dev" + description: + name: melos + sha256: a3f06ed871e0348cb99909ad5ddf5f8b53cc61d894c302b5417d2db1ee7ec381 url: "https://pub.dev" source: hosted - version: "0.12.16" + version: "6.1.0" meta: dependency: transitive description: name: meta - sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04 + sha256: "7687075e408b093f36e6bbf6c91878cc0d4cd10f409506f7bc996f68220b9136" url: "https://pub.dev" source: hosted - version: "1.11.0" + version: "1.12.0" mime: dependency: transitive description: @@ -165,10 +253,18 @@ packages: dependency: "direct dev" description: name: mocktail - sha256: bac151b31e4ed78bd59ab89aa4c0928f297b1180186d5daf03734519e5f596c1 + sha256: "890df3f9688106f25755f26b1c60589a92b3ab91a22b8b224947ad041bf172d8" + url: "https://pub.dev" + source: hosted + version: "1.0.4" + mustache_template: + dependency: transitive + description: + name: mustache_template + sha256: a46e26f91445bfb0b60519be280555b06792460b27b19e2b19ad5b9740df5d1c url: "https://pub.dev" source: hosted - version: "1.0.1" + version: "2.0.0" node_preamble: dependency: transitive description: @@ -189,10 +285,18 @@ packages: dependency: transitive description: name: path - sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917" + sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af" url: "https://pub.dev" source: hosted - version: "1.8.3" + version: "1.9.0" + platform: + dependency: transitive + description: + name: platform + sha256: "9b71283fc13df574056616011fb138fd3b793ea47cc509c189a6c3fa5f8a1a65" + url: "https://pub.dev" + source: hosted + version: "3.1.5" pool: dependency: transitive description: @@ -201,6 +305,22 @@ packages: url: "https://pub.dev" source: hosted version: "1.5.1" + process: + dependency: transitive + description: + name: process + sha256: "21e54fd2faf1b5bdd5102afd25012184a6793927648ea81eea80552ac9405b32" + url: "https://pub.dev" + source: hosted + version: "5.0.2" + prompts: + dependency: transitive + description: + name: prompts + sha256: "3773b845e85a849f01e793c4fc18a45d52d7783b4cb6c0569fad19f9d0a774a1" + url: "https://pub.dev" + source: hosted + version: "2.0.0" pub_semver: dependency: transitive description: @@ -209,6 +329,30 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.4" + pub_updater: + dependency: transitive + description: + name: pub_updater + sha256: "54e8dc865349059ebe7f163d6acce7c89eb958b8047e6d6e80ce93b13d7c9e60" + url: "https://pub.dev" + source: hosted + version: "0.4.0" + pubspec: + dependency: transitive + description: + name: pubspec + sha256: f534a50a2b4d48dc3bc0ec147c8bd7c304280fff23b153f3f11803c4d49d927e + url: "https://pub.dev" + source: hosted + version: "2.3.0" + quiver: + dependency: transitive + description: + name: quiver + sha256: b1c1ac5ce6688d77f65f3375a9abb9319b3cb32486bdc7a1e0fdf004d7ba4e47 + url: "https://pub.dev" + source: hosted + version: "3.2.1" riverpod: dependency: "direct main" description: @@ -317,26 +461,26 @@ packages: dependency: "direct dev" description: name: test - sha256: a1f7595805820fcc05e5c52e3a231aedd0b72972cb333e8c738a8b1239448b6f + sha256: "7ee446762c2c50b3bd4ea96fe13ffac69919352bd3b4b17bac3f3465edc58073" url: "https://pub.dev" source: hosted - version: "1.24.9" + version: "1.25.2" test_api: dependency: transitive description: name: test_api - sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b" + sha256: "9955ae474176f7ac8ee4e989dadfb411a58c30415bcfb648fa04b2b8a03afa7f" url: "https://pub.dev" source: hosted - version: "0.6.1" + version: "0.7.0" test_core: dependency: transitive description: name: test_core - sha256: a757b14fc47507060a162cc2530d9a4a2f92f5100a952c7443b5cad5ef5b106a + sha256: "2bc4b4ecddd75309300d8096f781c0e3280ca1ef85beda558d33fcbedc2eead4" url: "https://pub.dev" source: hosted - version: "0.5.9" + version: "0.6.0" typed_data: dependency: transitive description: @@ -345,6 +489,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.3.2" + uri: + dependency: transitive + description: + name: uri + sha256: "889eea21e953187c6099802b7b4cf5219ba8f3518f604a1033064d45b1b8268a" + url: "https://pub.dev" + source: hosted + version: "1.0.0" very_good_analysis: dependency: "direct dev" description: @@ -357,10 +509,10 @@ packages: dependency: transitive description: name: vm_service - sha256: b3d56ff4341b8f182b96aceb2fa20e3dcb336b9f867bc0eafc0de10f1048e957 + sha256: "3923c89304b715fb1eb6423f017651664a03bf5f4b29983627c4da791f74a4ec" url: "https://pub.dev" source: hosted - version: "13.0.0" + version: "14.2.1" watcher: dependency: transitive description: @@ -369,6 +521,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.1.0" + web: + dependency: transitive + description: + name: web + sha256: "97da13628db363c635202ad97068d47c5b8aa555808e7a9411963c533b449b27" + url: "https://pub.dev" + source: hosted + version: "0.5.1" web_socket_channel: dependency: transitive description: @@ -393,5 +553,13 @@ packages: url: "https://pub.dev" source: hosted version: "3.1.2" + yaml_edit: + dependency: transitive + description: + name: yaml_edit + sha256: e9c1a3543d2da0db3e90270dbb1e4eebc985ee5e3ffe468d83224472b2194a5f + url: "https://pub.dev" + source: hosted + version: "2.2.1" sdks: - dart: ">=3.0.0 <4.0.0" + dart: ">=3.3.0 <4.0.0" diff --git a/pubspec.yaml b/pubspec.yaml index 3fa7f8f..3ccfba9 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -6,8 +6,10 @@ environment: sdk: ">=3.0.0 <4.0.0" dev_dependencies: + melos: ^6.1.0 mocktail: ^1.0.0 test: ^1.19.2 very_good_analysis: ^5.1.0 + dependencies: riverpod: ^2.0.0