From 9f8bae0b227f050a9a96ea37245b4d95d23ec614 Mon Sep 17 00:00:00 2001 From: Jordy de Jonghe Date: Thu, 14 Sep 2023 12:00:14 +0200 Subject: [PATCH 1/3] #64: added github actions support --- .github/workflows/analyzer.yml | 18 ++ .github/workflows/test.yml | 25 ++ .travis.yml | 38 --- example/pubspec.lock | 236 +++++++----------- pubspec.lock | 89 +++---- .../test_coverage_filter.dart | 56 +++-- tool/{travis => }/test_coverage_helper.dart | 19 +- tool/test_coverage_validate_percentage.dart | 41 +++ tool/travis/analyze.sh | 3 - tool/travis/test.sh | 30 --- 10 files changed, 247 insertions(+), 308 deletions(-) create mode 100644 .github/workflows/analyzer.yml create mode 100644 .github/workflows/test.yml delete mode 100644 .travis.yml rename coverage/filter_test_coverage.dart => tool/test_coverage_filter.dart (64%) rename tool/{travis => }/test_coverage_helper.dart (68%) create mode 100644 tool/test_coverage_validate_percentage.dart delete mode 100755 tool/travis/analyze.sh delete mode 100755 tool/travis/test.sh diff --git a/.github/workflows/analyzer.yml b/.github/workflows/analyzer.yml new file mode 100644 index 0000000..f3d2762 --- /dev/null +++ b/.github/workflows/analyzer.yml @@ -0,0 +1,18 @@ +name: Analyzer + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +jobs: + check_analyzer: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: subosito/flutter-action@v2.8.0 + with: + channel: 'stable' + - run: flutter packages get + - run: flutter analyze \ No newline at end of file diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..c6322ad --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,25 @@ +name: Test + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: subosito/flutter-action@v2.8.0 + with: + channel: 'stable' + - run: flutter packages get + - run: dart run ./tool/test_coverage_create_helper.dart + - run: flutter test --coverage + - run: dart run ./tool/test_coverage_filter.dart + - run: dart run ./tool/test_coverage_validate_percentage.dart + - name: Coveralls + uses: coverallsapp/github-action@master + with: + github-token: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 9cd514a..0000000 --- a/.travis.yml +++ /dev/null @@ -1,38 +0,0 @@ -os: osx -osx_image: xcode12.2 - -before_install: - - chmod +x ./tool/travis/test.sh - - chmod +x ./tool/travis/analyze.sh - -sudo: required - -before_script: - - git clone https://github.com/flutter/flutter.git -b stable ../flutter - - export PATH="$PATH":`pwd`/../flutter/bin - - export PATH="$PATH":`pwd`/../flutter/bin/cache/dart-sdk/bin - - flutter config --no-analytics - - flutter doctor - - export FLUTTER_SDK=`pwd`/../flutter - - gem install coveralls-lcov - - flutter pub global activate dart_style - - flutter packages get || exit -1; - -jobs: - include: - - stage: quality - name: "Tests" - script: ./tool/travis/test.sh - - stage: quality - name: "Analyze" - script: ./tool/travis/analyze.sh - -stages: - - quality - -branches: - only: - - master -cache: - directories: - - $HOME/.pub-cache \ No newline at end of file diff --git a/example/pubspec.lock b/example/pubspec.lock index 34d0730..5430466 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -5,18 +5,16 @@ packages: dependency: transitive description: name: args - sha256: b003c3098049a51720352d219b0bb5f219b60fbfb68e7a4748139a06a5676515 - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "2.3.1" + version: "2.4.1" async: dependency: transitive description: name: async - sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "2.11.0" + version: "2.9.0" background_location_tracker: dependency: "direct main" description: @@ -28,64 +26,56 @@ packages: dependency: transitive description: name: boolean_selector - sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "2.1.1" + version: "2.1.0" characters: dependency: transitive description: name: characters - sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "1.3.0" + version: "1.2.1" clock: dependency: transitive description: name: clock - sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "1.1.1" collection: dependency: transitive description: name: collection - sha256: "4a07be6cb69c84d677a6c3096fcf960cc3285a8330b4603e0d463d15d9bd934c" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "1.17.1" + version: "1.16.0" dbus: dependency: transitive description: name: dbus - sha256: "6f07cba3f7b3448d42d015bfd3d53fe12e5b36da2423f23838efc1d5fb31a263" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "0.7.8" fake_async: dependency: transitive description: name: fake_async - sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "1.3.1" ffi: dependency: transitive description: name: ffi - sha256: a38574032c5f1dd06c4aee541789906c12ccaab8ba01446e800d9c5b79c4a978 - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "2.0.1" + version: "2.0.2" file: dependency: transitive description: name: file - sha256: "1b92bec4fc2a72f59a8e15af5f52cd441e4a7860b49499d69dfa817af20e925d" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "6.1.4" flutter: @@ -97,24 +87,21 @@ packages: dependency: "direct main" description: name: flutter_local_notifications - sha256: "58729fa76729234ff72597b8825876d781d02c94d5d6c6f6958aeb475f5bf00e" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "9.9.0" + version: "9.9.1" flutter_local_notifications_linux: dependency: transitive description: name: flutter_local_notifications_linux - sha256: b472bfc173791b59ede323661eae20f7fff0b6908fea33dd720a6ef5d576bae8 - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "0.5.1" flutter_local_notifications_platform_interface: dependency: transitive description: name: flutter_local_notifications_platform_interface - sha256: "21bceee103a66a53b30ea9daf677f990e5b9e89b62f222e60dd241cd08d63d3a" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "5.0.0" flutter_test: @@ -131,202 +118,170 @@ packages: dependency: transitive description: name: js - sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3 - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "0.6.7" + version: "0.6.4" matcher: dependency: transitive description: name: matcher - sha256: "6501fbd55da300384b768785b83e5ce66991266cec21af89ab9ae7f5ce1c4cbb" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "0.12.15" + version: "0.12.12" material_color_utilities: dependency: transitive description: name: material_color_utilities - sha256: d92141dc6fe1dad30722f9aa826c7fbc896d021d792f80678280601aff8cf724 - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "0.2.0" + version: "0.1.5" meta: dependency: transitive description: name: meta - sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "1.9.1" + version: "1.8.0" path: dependency: transitive description: name: path - sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "1.8.3" + version: "1.8.2" path_provider_linux: dependency: transitive description: name: path_provider_linux - sha256: ab0987bf95bc591da42dffb38c77398fc43309f0b9b894dcc5d6f40c4b26c379 - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "2.1.7" + version: "2.2.0" path_provider_platform_interface: dependency: transitive description: name: path_provider_platform_interface - sha256: "27dc7a224fcd07444cb5e0e60423ccacea3e13cf00fc5282ac2c918132da931d" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "2.0.4" + version: "2.1.0" path_provider_windows: dependency: transitive description: name: path_provider_windows - sha256: bcabbe399d4042b8ee687e17548d5d3f527255253b4a639f5f8d2094a9c2b45c - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "2.1.3" + version: "2.2.0" permission_handler: dependency: "direct main" description: name: permission_handler - sha256: ae51809c535fd765061c7384a67bc24d304d24cfc455c59e2f6a5cec9a37fc9c - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "10.0.0" + version: "10.4.5" permission_handler_android: dependency: transitive description: name: permission_handler_android - sha256: "692e5dd690cd9e978e1cefa67d97bddd3a7f4748ddac6cd8bbd1a354a6a1869f" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "10.0.0" + version: "10.3.6" permission_handler_apple: dependency: transitive description: name: permission_handler_apple - sha256: "6367799be76d1fe70ffe2df7f025abfe28818b450f550621778995badbebf519" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "9.0.4" + version: "9.1.4" permission_handler_platform_interface: dependency: transitive description: name: permission_handler_platform_interface - sha256: ca16451bfdc6d26693d10b37b2d81370bdf3f0318422f3eecfd6004f5bd7d21f - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "3.7.0" + version: "3.11.5" permission_handler_windows: dependency: transitive description: name: permission_handler_windows - sha256: "40ad5ab4d3c65d75c7f3a069065c77503aae19a1cf01ba246d43489e14f1b90c" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "0.1.0" + version: "0.1.3" petitparser: dependency: transitive description: name: petitparser - sha256: "2ebb289dc4764ec397f5cd3ca9881c6d17196130a7d646ed022a0dd9c2e25a71" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "5.0.0" + version: "5.1.0" platform: dependency: transitive description: name: platform - sha256: "4a451831508d7d6ca779f7ac6e212b4023dd5a7d08a27a63da33756410e32b76" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "3.1.0" + version: "3.1.1" plugin_platform_interface: dependency: transitive description: name: plugin_platform_interface - sha256: "075f927ebbab4262ace8d0b283929ac5410c0ac4e7fc123c76429564facfb757" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "2.1.2" + version: "2.1.5" process: dependency: transitive description: name: process - sha256: "53fd8db9cec1d37b0574e12f07520d582019cb6c44abf5479a01505099a34a09" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "4.2.4" shared_preferences: dependency: "direct main" description: name: shared_preferences - sha256: "76917b7d4b9526b2ba416808a7eb9fb2863c1a09cf63ec85f1453da240fa818a" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "2.0.15" + version: "2.2.0" shared_preferences_android: dependency: transitive description: name: shared_preferences_android - sha256: "853801ce6ba7429ec4e923e37317f32a57c903de50b8c33ffcfbdb7e6f0dd39c" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "2.0.12" - shared_preferences_ios: + version: "2.2.0" + shared_preferences_foundation: dependency: transitive description: - name: shared_preferences_ios - sha256: "585a14cefec7da8c9c2fb8cd283a3bb726b4155c0952afe6a0caaa7b2272de34" - url: "https://pub.dev" + name: shared_preferences_foundation + url: "https://pub.dartlang.org" source: hosted - version: "2.1.1" + version: "2.3.3" shared_preferences_linux: dependency: transitive description: name: shared_preferences_linux - sha256: "28aefc1261746e7bad3d09799496054beb84e8c4ffcdfed7734e17b4ada459a5" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "2.1.1" - shared_preferences_macos: - dependency: transitive - description: - name: shared_preferences_macos - sha256: fbb94bf296576f49be37a1496d5951796211a8db0aa22cc0d68c46440dad808c - url: "https://pub.dev" - source: hosted - version: "2.0.4" + version: "2.3.0" shared_preferences_platform_interface: dependency: transitive description: name: shared_preferences_platform_interface - sha256: da9431745ede5ece47bc26d5d73a9d3c6936ef6945c101a5aca46f62e52c1cf3 - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "2.1.0" + version: "2.3.0" shared_preferences_web: dependency: transitive description: name: shared_preferences_web - sha256: a4b5bc37fe1b368bbc81f953197d55e12f49d0296e7e412dfe2d2d77d6929958 - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "2.0.4" + version: "2.2.0" shared_preferences_windows: dependency: transitive description: name: shared_preferences_windows - sha256: "97f7ab9a7da96d9cf19581f5de520ceb529548498bd6b5e0ccd02d68a0d15eba" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "2.1.1" + version: "2.3.0" sky_engine: dependency: transitive description: flutter @@ -336,90 +291,79 @@ packages: dependency: transitive description: name: source_span - sha256: dd904f795d4b4f3b870833847c461801f6750a9fa8e61ea5ac53f9422b31f250 - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "1.9.1" + version: "1.9.0" stack_trace: dependency: transitive description: name: stack_trace - sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5 - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "1.11.0" + version: "1.10.0" stream_channel: dependency: transitive description: name: stream_channel - sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "2.1.1" + version: "2.1.0" string_scanner: dependency: transitive description: name: string_scanner - sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.1.1" term_glyph: dependency: transitive description: name: term_glyph - sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "1.2.1" test_api: dependency: transitive description: name: test_api - sha256: eb6ac1540b26de412b3403a163d919ba86f6a973fe6cc50ae3541b80092fdcfb - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "0.5.1" + version: "0.4.12" timezone: dependency: transitive description: name: timezone - sha256: "57b35f6e8ef731f18529695bffc62f92c6189fac2e52c12d478dec1931afb66e" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "0.8.0" vector_math: dependency: transitive description: name: vector_math - sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "2.1.4" + version: "2.1.2" win32: dependency: transitive description: name: win32 - sha256: "1952a663c0e34fbde55916010d54bbb249bf5f2583113c497602f0ee01c6faa4" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "3.0.0" + version: "4.1.4" xdg_directories: dependency: transitive description: name: xdg_directories - sha256: "11541eedefbcaec9de35aa82650b695297ce668662bbd6e3911a7fabdbde589f" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "0.2.0+2" + version: "0.2.0+3" xml: dependency: transitive description: name: xml - sha256: ac0e3f4bf00ba2708c33fbabbbe766300e509f8c82dbd4ab6525039813f7e2fb - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "6.1.0" sdks: - dart: ">=3.0.0-0 <4.0.0" - flutter: ">=3.0.0" + dart: ">=2.18.0 <3.0.0" + flutter: ">=3.3.0" diff --git a/pubspec.lock b/pubspec.lock index 5762bdc..9cf620f 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -5,48 +5,42 @@ packages: dependency: transitive description: name: async - sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "2.11.0" + version: "2.9.0" boolean_selector: dependency: transitive description: name: boolean_selector - sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "2.1.1" + version: "2.1.0" characters: dependency: transitive description: name: characters - sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "1.3.0" + version: "1.2.1" clock: dependency: transitive description: name: clock - sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "1.1.1" collection: dependency: transitive description: name: collection - sha256: "4a07be6cb69c84d677a6c3096fcf960cc3285a8330b4603e0d463d15d9bd934c" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "1.17.1" + version: "1.16.0" fake_async: dependency: transitive description: name: fake_async - sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "1.3.1" flutter: @@ -59,46 +53,34 @@ packages: description: flutter source: sdk version: "0.0.0" - js: - dependency: transitive - description: - name: js - sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3 - url: "https://pub.dev" - source: hosted - version: "0.6.7" matcher: dependency: transitive description: name: matcher - sha256: "6501fbd55da300384b768785b83e5ce66991266cec21af89ab9ae7f5ce1c4cbb" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "0.12.15" + version: "0.12.12" material_color_utilities: dependency: transitive description: name: material_color_utilities - sha256: d92141dc6fe1dad30722f9aa826c7fbc896d021d792f80678280601aff8cf724 - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "0.2.0" + version: "0.1.5" meta: dependency: transitive description: name: meta - sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "1.9.1" + version: "1.8.0" path: dependency: transitive description: name: path - sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "1.8.3" + version: "1.8.2" sky_engine: dependency: transitive description: flutter @@ -108,58 +90,51 @@ packages: dependency: transitive description: name: source_span - sha256: dd904f795d4b4f3b870833847c461801f6750a9fa8e61ea5ac53f9422b31f250 - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "1.9.1" + version: "1.9.0" stack_trace: dependency: transitive description: name: stack_trace - sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5 - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "1.11.0" + version: "1.10.0" stream_channel: dependency: transitive description: name: stream_channel - sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "2.1.1" + version: "2.1.0" string_scanner: dependency: transitive description: name: string_scanner - sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.1.1" term_glyph: dependency: transitive description: name: term_glyph - sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "1.2.1" test_api: dependency: transitive description: name: test_api - sha256: eb6ac1540b26de412b3403a163d919ba86f6a973fe6cc50ae3541b80092fdcfb - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "0.5.1" + version: "0.4.12" vector_math: dependency: transitive description: name: vector_math - sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "2.1.4" + version: "2.1.2" sdks: - dart: ">=3.0.0-0 <4.0.0" + dart: ">=2.17.0-0 <3.0.0" flutter: ">=2.0.0" diff --git a/coverage/filter_test_coverage.dart b/tool/test_coverage_filter.dart similarity index 64% rename from coverage/filter_test_coverage.dart rename to tool/test_coverage_filter.dart index 1a8e17e..a3ff86a 100644 --- a/coverage/filter_test_coverage.dart +++ b/tool/test_coverage_filter.dart @@ -1,37 +1,37 @@ import 'dart:io'; -void main() { +void main(List args) { printMessage('Start filtering the lcov.info file'); final file = File('coverage/lcov.info'); if (!file.existsSync()) { - printMessage('"lcov.info" does not exist'); + printMessage('${file.path}" does not exist'); return; } const endOfRecord = 'end_of_record'; final sections = []; final lines = file.readAsLinesSync(); LcovSection? currentSection; - lines.forEach((line) { + for (final line in lines) { if (line.endsWith('.dart')) { final filePath = line.replaceAll('SF:', ''); currentSection = LcovSection() ..header = line ..filePath = filePath; } else if (line == endOfRecord) { - final session = currentSection; - if (session != null) { - session.footer = line; - sections.add(session); + final currentSectionTmp = currentSection; + if (currentSectionTmp != null) { + currentSectionTmp.footer = line; + sections.add(currentSectionTmp); } } else { currentSection?.body.add(line); } - }); + } final filteredSections = getFilteredSections(sections); final sb = StringBuffer(); - filteredSections.forEach((section) { + for (final section in filteredSections) { sb.write(section.toString()); - }); + } file.writeAsStringSync(sb.toString()); printMessage('Filtered the lcov.info file'); } @@ -42,12 +42,10 @@ class LcovSection { final body = []; String? footer; - String getBodyString() { - final path = filePath; - if (path == null) { - throw ArgumentError('file path can not be null'); - } - final file = File(path); + String? getBodyString() { + final filePathTmp = filePath; + if (filePathTmp == null) return null; + final file = File(filePathTmp); final content = file.readAsLinesSync(); final sb = StringBuffer(); getFilteredBody(body, content).forEach((item) => sb @@ -64,13 +62,23 @@ class LcovSection { List getFilteredSections(List sections) { return sections.where((section) { - if (section.header?.endsWith('.g.dart') == true) { + final header = section.header; + if (header == null) return false; + if (!header.endsWith('.dart')) { + return false; + } else if (header.endsWith('.g.dart')) { + return false; + } else if (header.endsWith('.config.dart')) { + return false; + } else if (header.endsWith('injectable.dart')) { + return false; + } else if (header.startsWith('SF:lib/util/locale')) { return false; - } else if (section.header?.endsWith('dummy_service.dart') == true) { + } else if (header.startsWith('SF:lib/widget')) { return false; - } else if (section.header?.startsWith('SF:lib/vendor/') == true) { + } else if (header.startsWith('SF:lib/screen')) { return false; - } else if (section.header?.startsWith('SF:lib/util/locale') == true) { + } else if (header.startsWith('SF:lib/navigator')) { return false; } return true; @@ -99,7 +107,13 @@ List getFilteredBody(List body, List lines) { }).toList(); } -const excludedLines = []; +const excludedLines = [ + 'const TranslationWriter._();', + 'const CaseUtil._();', + 'const LocaleGenParser._();', + 'const LocaleGenSbWriter._();', + 'const LocaleGenWriter._();', +]; const excludedStartsWithLines = []; diff --git a/tool/travis/test_coverage_helper.dart b/tool/test_coverage_helper.dart similarity index 68% rename from tool/travis/test_coverage_helper.dart rename to tool/test_coverage_helper.dart index 5e310f7..6f370d3 100755 --- a/tool/travis/test_coverage_helper.dart +++ b/tool/test_coverage_helper.dart @@ -3,33 +3,26 @@ import 'dart:io'; const packageName = 'background_location_tracker'; void main() { - Logger.debug('===='); Logger.debug( 'First create a file with all other files imported so flutter test coverage uses all files'); - Logger.debug('===='); - final testDir = Directory('test'); - if (!testDir.existsSync()) { - testDir.createSync(recursive: true); - } - final imports = Directory('lib').listSync(recursive: true).where((element) { if (Directory(element.path).existsSync()) return false; + if (!element.path.endsWith('.dart')) return false; if (element.path.endsWith('.g.dart')) return false; + if (element.path.endsWith('_web.dart')) return false; return true; }).map((element) { final importPath = element.path.replaceFirst('lib', packageName); - return 'import "package:$importPath";'; + return "import 'package:$importPath';"; }); final testFile = File('test/coverage_helper_test.dart'); if (!testFile.existsSync()) { testFile.createSync(); } - final content = '${imports.join('\n')}\nvoid main(){}'; + final sortedImports = imports.toList()..sort((e1, e2) => e1.compareTo(e2)); + final content = '${sortedImports.join('\n')}\nvoid main(){}'; testFile.writeAsStringSync(content); - - Logger.debug('===='); - Logger.debug('Finished'); - Logger.debug('===='); + Logger.debug('Created the test/coverage_helper_test.dart'); } class Logger { diff --git a/tool/test_coverage_validate_percentage.dart b/tool/test_coverage_validate_percentage.dart new file mode 100644 index 0000000..f22d605 --- /dev/null +++ b/tool/test_coverage_validate_percentage.dart @@ -0,0 +1,41 @@ +import 'dart:io'; + +const minRequiredCoverage = 0; + +void main(List args) { + printMessage('Start checking the lcov.info file'); + final file = File('coverage/lcov.info'); + if (!file.existsSync()) { + printMessage('${file.path}" does not exist'); + return; + } + var totalLines = 0; + var totalLinesCovered = 0; + final lines = file.readAsLinesSync(); + for (final line in lines) { + if (line.startsWith('DA')) { + totalLines++; + } else if (line.startsWith('LH')) { + totalLinesCovered += int.parse(line.replaceAll('LH:', '')); + } + } + final codeCoveragePercentage = (totalLinesCovered / totalLines) * 100; + if (codeCoveragePercentage == 100) { + printMessage('\n100% CODE COVERAGE!!!!\n'); + } else if (codeCoveragePercentage >= minRequiredCoverage) { + printMessage('COVERAGE IS ${codeCoveragePercentage.toStringAsFixed(2)}%\n'); + printMessage( + 'TIS IS ABOVE THE MIN REQUIRED TARGET of $minRequiredCoverage%\n'); + } else { + printMessage('\nCODE COVERAGE IS TO LOW!!\n'); + printMessage('COVERAGE IS ${codeCoveragePercentage.toStringAsFixed(2)}%\n'); + printMessage('AMOUNT OF LINES:$totalLines'); + printMessage('AMOUNT OF COVERED:$totalLinesCovered\n'); + exit(-1); + } +} + +void printMessage(String message) { + // ignore: avoid_print + print(message); +} diff --git a/tool/travis/analyze.sh b/tool/travis/analyze.sh deleted file mode 100755 index d0bc68f..0000000 --- a/tool/travis/analyze.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -flutter analyze || exit -1; \ No newline at end of file diff --git a/tool/travis/test.sh b/tool/travis/test.sh deleted file mode 100755 index 035658d..0000000 --- a/tool/travis/test.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/bash - -dart run ./tool/travis/test_coverage_helper.dart || exit -1; - -echo "" -echo "====" -echo "Start testing" -echo "====" -flutter test --coverage || exit -1; -echo "====" -echo "Finished testing" -echo "====" - -echo "" -echo "====" -echo "Start filtering tests" -echo "====" -dart run ./coverage/filter_test_coverage.dart || exit -1; -echo "====" -echo "Finished filtering tests" -echo "====" - -echo "" -echo "====" -echo "Start coveralls upload" -echo "====" -coveralls-lcov coverage/lcov.info -echo "====" -echo "Finished coveralls upload" -echo "====" \ No newline at end of file From 7f0a26183bd5e8208b92266a2cf95b90cf25f5f9 Mon Sep 17 00:00:00 2001 From: Jordy de Jonghe Date: Thu, 14 Sep 2023 12:03:57 +0200 Subject: [PATCH 2/3] #64: fixed naming --- ...test_coverage_helper.dart => test_coverage_create_helper.dart} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename tool/{test_coverage_helper.dart => test_coverage_create_helper.dart} (100%) diff --git a/tool/test_coverage_helper.dart b/tool/test_coverage_create_helper.dart similarity index 100% rename from tool/test_coverage_helper.dart rename to tool/test_coverage_create_helper.dart From dc9ee42272d6cdb0c5ef604ba4a28036d39cdc95 Mon Sep 17 00:00:00 2001 From: Jordy de Jonghe Date: Thu, 14 Sep 2023 12:06:18 +0200 Subject: [PATCH 3/3] #64: fixed analyzer --- analysis_options.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/analysis_options.yaml b/analysis_options.yaml index 41a5409..ab8e538 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -58,11 +58,10 @@ linter: - hash_and_equals - implementation_imports - invariant_booleans - - iterable_contains_unrelated_type + - collection_methods_unrelated_type - join_return_with_assignment - library_names - library_prefixes - - list_remove_unrelated_type - literal_only_boolean_expressions - no_adjacent_strings_in_list - no_duplicate_case_values