From d9e21b2527014161ca6aa1d66886e1d7117b7215 Mon Sep 17 00:00:00 2001 From: Alexis Choupault Date: Mon, 3 Mar 2025 18:04:27 +0100 Subject: [PATCH] Setup codecov (#25) set up codecov --- .github/workflows/android.yml | 39 -------- .github/workflows/ci.yml | 137 +++++++++++++++++++++++++++ .github/workflows/flutter.yml | 35 ------- .github/workflows/ios.yml | 40 -------- README.md | 8 +- android/build.gradle | 41 +++++++- example/android/app/build.gradle.kts | 5 + example/pubspec.lock | 55 ----------- example/pubspec.yaml | 2 - example/test/widget_test.dart | 27 ------ lib/eventide.dart | 2 +- 11 files changed, 188 insertions(+), 203 deletions(-) delete mode 100644 .github/workflows/android.yml create mode 100644 .github/workflows/ci.yml delete mode 100644 .github/workflows/flutter.yml delete mode 100644 .github/workflows/ios.yml delete mode 100644 example/test/widget_test.dart diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml deleted file mode 100644 index f5a4e0d..0000000 --- a/.github/workflows/android.yml +++ /dev/null @@ -1,39 +0,0 @@ -name: Android Tests - -on: - push: - branches: [ main ] - paths-ignore: - - '**.md' - pull_request: - branches: [ main ] - paths-ignore: - - '**.md' - -jobs: - android-tests: - runs-on: macos-latest - - steps: - - uses: actions/checkout@v4 - - - uses: actions/setup-java@v4 - with: - distribution: 'corretto' - java-version: '17' - cache: 'gradle' - - - uses: subosito/flutter-action@v2 - with: - flutter-version: '3.29.0' - channel: 'stable' - - - name: Verify Flutter Installation - run: flutter doctor -v - - - name: Install dependencies - run: flutter pub get - - - name: Build and test - run: | - ./example/android/gradlew testDebugUnitTest -p ./example/android/ \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..7df924e --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,137 @@ +name: CI + +on: + push: + branches: [ main ] + paths-ignore: + - '**.md' + pull_request: + branches: [ main ] + paths-ignore: + - '**.md' + +jobs: + flutter-tests: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - uses: subosito/flutter-action@v2 + with: + flutter-version: '3.29.0' + channel: 'stable' + + - name: Install dependencies + run: flutter pub get + + - name: Analyze project source + run: flutter analyze --fatal-infos + working-directory: lib + + - name: Run tests + run: flutter test --coverage + + - name: Upload coverage report as artifact + uses: actions/upload-artifact@v4 + with: + name: flutter-coverage + path: coverage/lcov.info + + ios-tests: + runs-on: macos-latest + + steps: + - uses: actions/checkout@v4 + + - uses: subosito/flutter-action@v2 + with: + flutter-version: '3.29.0' + channel: 'stable' + + - name: Install dependencies + run: | + brew install xcresultparser + flutter pub get + cd example/ios + pod install + cd ../.. + + - name: Run tests + run: | + xcodebuild test -workspace ./example/ios/Runner.xcworkspace \ + -scheme EventideTests \ + -destination 'platform=iOS Simulator,name=iPhone 16,OS=18.1' \ + -resultBundlePath build/reports/EventideTests.xcresult + + - name: Prepare coverage xml file + run: | + xcresultparser \ + --output-format cobertura \ + build/reports/EventideTests.xcresult > build/reports/ios-coverage.xml + + - name: Upload coverage report as artifact + uses: actions/upload-artifact@v4 + with: + name: ios-coverage + path: build/reports/ios-coverage.xml + + android-tests: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-java@v4 + with: + distribution: 'corretto' + java-version: '17' + cache: 'gradle' + + - uses: subosito/flutter-action@v2 + with: + flutter-version: '3.29.0' + channel: 'stable' + + - name: Install dependencies + run: flutter pub get + + - name: Build and test + run: | + ./example/android/gradlew testDebugUnitTest -p ./example/android/ + + - name: Upload coverage report as artifact + uses: actions/upload-artifact@v4 + with: + name: android-coverage + path: ./android/build/reports/jacocoTestReport.xml + + upload-coverage: + runs-on: ubuntu-latest + needs: [flutter-tests, ios-tests, android-tests] + steps: + - name: Download flutter coverage report + uses: actions/download-artifact@v4 + with: + name: flutter-coverage + path: coverage + + - name: Download ios coverage report + uses: actions/download-artifact@v4 + with: + name: ios-coverage + path: build/reports + + - name: Download android coverage report + uses: actions/download-artifact@v4 + with: + name: android-coverage + path: ./android/build/reports/ + + - name: Upload combined coverage report to Codecov + uses: codecov/codecov-action@v5 + env: + token: ${{ secrets.CODECOV_TOKEN }} + with: + fail_ci_if_error: true + files: ./coverage/lcov.info,./build/reports/ios-coverage.xml,./android/build/reports/jacocoTestReport.xml \ No newline at end of file diff --git a/.github/workflows/flutter.yml b/.github/workflows/flutter.yml deleted file mode 100644 index c325751..0000000 --- a/.github/workflows/flutter.yml +++ /dev/null @@ -1,35 +0,0 @@ -name: Flutter Tests - -on: - push: - branches: [ main ] - paths-ignore: - - '**.md' - pull_request: - branches: [ main ] - paths-ignore: - - '**.md' - -jobs: - flutter-tests: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - - uses: subosito/flutter-action@v2 - with: - flutter-version: '3.29.0' - channel: 'stable' - - - name: Verify Flutter Installation - run: flutter doctor -v - - - name: Install dependencies - run: flutter pub get - - - name: Analyze project source - run: dart analyze - - - name: Run tests - run: flutter test \ No newline at end of file diff --git a/.github/workflows/ios.yml b/.github/workflows/ios.yml deleted file mode 100644 index 09f1fe8..0000000 --- a/.github/workflows/ios.yml +++ /dev/null @@ -1,40 +0,0 @@ -name: iOS Tests - -on: - push: - branches: [ main ] - paths-ignore: - - '**.md' - pull_request: - branches: [ main ] - paths-ignore: - - '**.md' - -jobs: - ios-tests: - runs-on: macos-latest - - steps: - - uses: actions/checkout@v4 - - - uses: subosito/flutter-action@v2 - with: - flutter-version: '3.29.0' - channel: 'stable' - - - name: Verify Flutter Installation - run: flutter doctor -v - - - name: Install dependencies - run: | - flutter pub get - cd example/ios - pod install - cd ../.. - - - name: Run tests - run: | - xcodebuild test -workspace ./example/ios/Runner.xcworkspace \ - -scheme EventideTests \ - -destination 'platform=iOS Simulator,name=iPhone 16,OS=18.1' \ - -resultBundlePath build/reports/EventideTests.xcresult \ No newline at end of file diff --git a/README.md b/README.md index 9400296..ed8918d 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ ## 📆 Eventide -[![pub package](https://img.shields.io/pub/v/eventide.svg)](https://pub.dev/packages/eventide) [![Flutter Tests](https://github.com/sncf-connect-tech/eventide/actions/workflows/flutter.yml/badge.svg)](https://github.com/sncf-connect-tech/eventide/actions/workflows/flutter.yml) [![Android Tests](https://github.com/sncf-connect-tech/eventide/actions/workflows/android.yml/badge.svg)](https://github.com/sncf-connect-tech/eventide/actions/workflows/android.yml) [![iOS Tests](https://github.com/sncf-connect-tech/eventide/actions/workflows/ios.yml/badge.svg)](https://github.com/sncf-connect-tech/eventide/actions/workflows/ios.yml) +[![pub package](https://img.shields.io/pub/v/value_state.svg)](https://pub.dev/packages/value_state) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) + +[![codecov](https://codecov.io/gh/sncf-connect-tech/eventide/graph/badge.svg?token=jxA8pZnWmR)](https://codecov.io/gh/sncf-connect-tech/eventide) [![Flutter Tests](https://github.com/sncf-connect-tech/eventide/actions/workflows/flutter.yml/badge.svg)](https://github.com/sncf-connect-tech/eventide/actions/workflows/flutter.yml) [![Android Tests](https://github.com/sncf-connect-tech/eventide/actions/workflows/android.yml/badge.svg)](https://github.com/sncf-connect-tech/eventide/actions/workflows/android.yml) [![iOS Tests](https://github.com/sncf-connect-tech/eventide/actions/workflows/ios.yml/badge.svg)](https://github.com/sncf-connect-tech/eventide/actions/workflows/ios.yml) Eventide provides a easy-to-use flutter interface to access & modify native device calendars (iOS & Android). @@ -76,3 +78,7 @@ You can find more in the example app. ### License Copyright © 2025 SNCF Connect & Tech. This project is licensed under the MIT License - see the LICENSE file for details. + +### Feedback + +Please file any issues, bugs or feature requests as an issue on the [Github page](https://github.com/sncf-connect-tech/eventide/issues). \ No newline at end of file diff --git a/android/build.gradle b/android/build.gradle index d6114ce..2b073c4 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -9,7 +9,7 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:7.3.1' + classpath "com.android.tools.build:gradle:8.8.2" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } @@ -23,6 +23,7 @@ allprojects { apply plugin: 'com.android.library' apply plugin: 'kotlin-android' +apply plugin: 'jacoco' android { compileSdk 35 @@ -71,8 +72,42 @@ android { ndkVersion '27.0.12077973' } +tasks.register('jacocoTestReport', JacocoReport) { + dependsOn 'testDebugUnitTest' + + reports { + xml.required = true + xml.outputLocation.set(file("$project.projectDir/build/reports/jacocoTestReport.xml")) + html.required = false + csv.required = false + } + + def fileFilter = [ + '**/R.class', + '**/R$*.class', + '**/BuildConfig.*', + '**/Manifest*.*', + '**/CalendarApi*', + '**/Calendar.class', + '**/Calendar$Companion.class', + '**/Event*.class', + '**/Account*.class', + ] // ignore pigeon generated files + def mainSrc = "${project.projectDir}/src/main/kotlin/sncf/connect/tech/eventide/" + + sourceDirectories.setFrom(files(mainSrc)) + classDirectories.setFrom(files("${buildDir}/intermediates/runtime_library_classes_dir/debug/sncf/connect/tech/eventide/").asFileTree.matching { + exclude fileFilter + }) + executionData.setFrom(files("${buildDir}/jacoco/testDebugUnitTest.exec")) +} + +tasks.withType(Test).configureEach { + useJUnitPlatform() + finalizedBy jacocoTestReport +} + dependencies { - implementation("androidx.activity:activity-ktx:1.10.0") + implementation("androidx.activity:activity-ktx:1.10.1") implementation("androidx.fragment:fragment-ktx:1.8.6") } - diff --git a/example/android/app/build.gradle.kts b/example/android/app/build.gradle.kts index 964904f..2e3eee3 100644 --- a/example/android/app/build.gradle.kts +++ b/example/android/app/build.gradle.kts @@ -3,6 +3,11 @@ plugins { id("kotlin-android") // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins. id("dev.flutter.flutter-gradle-plugin") + id("jacoco") +} + +jacoco { + toolVersion = "0.8.12" } android { diff --git a/example/pubspec.lock b/example/pubspec.lock index 9ecfbfd..a004b48 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -80,14 +80,6 @@ packages: url: "https://pub.dev" source: hosted version: "1.3.2" - file: - dependency: transitive - description: - name: file - sha256: a3b4f84adafef897088c160faf7dfffb7696046cb13ae90b508c2cbc95d3b8d4 - url: "https://pub.dev" - source: hosted - version: "7.0.1" flutter: dependency: "direct main" description: flutter @@ -101,11 +93,6 @@ packages: url: "https://pub.dev" source: hosted version: "8.1.6" - flutter_driver: - dependency: transitive - description: flutter - source: sdk - version: "0.0.0" flutter_lints: dependency: "direct dev" description: @@ -119,11 +106,6 @@ packages: description: flutter source: sdk version: "0.0.0" - fuchsia_remote_debug_protocol: - dependency: transitive - description: flutter - source: sdk - version: "0.0.0" http: dependency: transitive description: @@ -140,11 +122,6 @@ packages: url: "https://pub.dev" source: hosted version: "4.1.2" - integration_test: - dependency: "direct dev" - description: flutter - source: sdk - version: "0.0.0" leak_tracker: dependency: transitive description: @@ -217,14 +194,6 @@ packages: url: "https://pub.dev" source: hosted version: "1.9.1" - platform: - dependency: transitive - description: - name: platform - sha256: "5d6b1b0036a5f331ebc77c850ebc8506cbc1e9416c27e59b439f917a902a4984" - url: "https://pub.dev" - source: hosted - version: "3.1.6" plugin_platform_interface: dependency: transitive description: @@ -233,14 +202,6 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.8" - process: - dependency: transitive - description: - name: process - sha256: "107d8be718f120bbba9dcd1e95e3bd325b1b4a4f07db64154635ba03f2567a0d" - url: "https://pub.dev" - source: hosted - version: "5.0.3" provider: dependency: transitive description: @@ -294,14 +255,6 @@ packages: url: "https://pub.dev" source: hosted version: "1.4.1" - sync_http: - dependency: transitive - description: - name: sync_http - sha256: "7f0cd72eca000d2e026bcd6f990b81d0ca06022ef4e32fb257b30d3d1014a961" - url: "https://pub.dev" - source: hosted - version: "0.3.1" term_glyph: dependency: transitive description: @@ -367,14 +320,6 @@ packages: url: "https://pub.dev" source: hosted version: "1.1.0" - webdriver: - dependency: transitive - description: - name: webdriver - sha256: "3d773670966f02a646319410766d3b5e1037efb7f07cc68f844d5e06cd4d61c8" - url: "https://pub.dev" - source: hosted - version: "3.0.4" sdks: dart: ">=3.7.0-0 <4.0.0" flutter: ">=3.18.0-18.0.pre.54" diff --git a/example/pubspec.yaml b/example/pubspec.yaml index d9e5bbd..cb4382f 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -22,8 +22,6 @@ dependencies: timezone: ^0.10.0 dev_dependencies: - integration_test: - sdk: flutter flutter_test: sdk: flutter flutter_lints: ^4.0.0 diff --git a/example/test/widget_test.dart b/example/test/widget_test.dart deleted file mode 100644 index 4896183..0000000 --- a/example/test/widget_test.dart +++ /dev/null @@ -1,27 +0,0 @@ -// This is a basic Flutter widget test. -// -// To perform an interaction with a widget in your test, use the WidgetTester -// utility in the flutter_test package. For example, you can send tap and scroll -// gestures. You can also use WidgetTester to find child widgets in the widget -// tree, read text, and verify that the values of widget properties are correct. - -import 'package:flutter/material.dart'; -import 'package:flutter_test/flutter_test.dart'; - -import 'package:eventide_example/main.dart'; - -void main() { - testWidgets('Verify Platform version', (WidgetTester tester) async { - // Build our app and trigger a frame. - await tester.pumpWidget(MyApp()); - - // Verify that platform version is retrieved. - expect( - find.byWidgetPredicate( - (Widget widget) => - widget is Text && widget.data!.startsWith('Running on:'), - ), - findsOneWidget, - ); - }); -} diff --git a/lib/eventide.dart b/lib/eventide.dart index f95a8c7..145a551 100644 --- a/lib/eventide.dart +++ b/lib/eventide.dart @@ -1,4 +1,4 @@ -library eventide; +library; export 'src/eventide.dart' show Eventide; export 'src/eventide_platform_interface.dart' show ETCalendar, ETEvent, ETAccount;