From 226daac21e49ab15402100eace715117baedb987 Mon Sep 17 00:00:00 2001 From: kenresoft Date: Tue, 6 Aug 2024 18:01:54 +0100 Subject: [PATCH] Add github workflow `main.yml` --- .github/workflows/main.yml | 133 ++++++++++++++++++ .gitignore | 4 + .../plugins/GeneratedPluginRegistrant.java | 27 ++-- example/.gitignore | 1 + example/pubspec.lock | 56 +++++--- ios/Runner/GeneratedPluginRegistrant.m | 7 + .../.plugin_symlinks/path_provider_linux | 1 + .../.plugin_symlinks/shared_preferences_linux | 1 + macos/Flutter/GeneratedPluginRegistrant.swift | 2 + 9 files changed, 203 insertions(+), 29 deletions(-) create mode 100644 .github/workflows/main.yml create mode 120000 linux/flutter/ephemeral/.plugin_symlinks/path_provider_linux create mode 120000 linux/flutter/ephemeral/.plugin_symlinks/shared_preferences_linux diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..36b8a71 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,133 @@ +name: Flutter Package CI + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + build: + strategy: + matrix: + platform: [ubuntu-latest] + flutter-version: ['3.22.1'] + working-directory: ['.'] + fail-fast: false + + runs-on: ${{ matrix.platform }} + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Cache Flutter SDK + uses: actions/cache@v4 + with: + path: ~/.pub-cache + key: ${{ runner.os }}-pub-cache-${{ matrix.flutter-version }} + restore-keys: | + ${{ runner.os }}-pub-cache- + + - name: Set up Flutter + uses: subosito/flutter-action@v2 + with: + flutter-version: ${{ matrix.flutter-version }} + + - name: Install dependencies + run: flutter pub get + working-directory: ${{ matrix.working-directory }} + + - name: Analyze code + run: dart analyze . + working-directory: ${{ matrix.working-directory }} + + - name: Run lint + run: flutter analyze + working-directory: ${{ matrix.working-directory }} + + - name: Run tests + run: flutter test --coverage + working-directory: ${{ matrix.working-directory }} + + - name: Upload code coverage + uses: actions/upload-artifact@v4 + with: + name: coverage-report + path: coverage/lcov.info + + test-example: + strategy: + matrix: + platform: [ubuntu-latest] + flutter-version: ['3.22.1'] + working-directory: ['example'] + fail-fast: false + + runs-on: ${{ matrix.platform }} + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Cache Flutter SDK + uses: actions/cache@v4 + with: + path: ~/.pub-cache + key: ${{ runner.os }}-pub-cache-${{ matrix.flutter-version }} + restore-keys: | + ${{ runner.os }}-pub-cache- + + - name: Set up Flutter + uses: subosito/flutter-action@v2 + with: + flutter-version: ${{ matrix.flutter-version }} + + - name: Install dependencies + run: flutter pub get + working-directory: ${{ matrix.working-directory }} + + - name: Analyze code + run: dart analyze . + working-directory: ${{ matrix.working-directory }} + + - name: Run lint + run: flutter analyze + working-directory: ${{ matrix.working-directory }} + + - name: Run tests + run: flutter test + working-directory: ${{ matrix.working-directory }} + + publish: + needs: [build, test-example] + runs-on: ubuntu-latest + if: github.event_name == 'push' && startsWith(github.ref, 'refs/heads/main') + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Cache Flutter SDK + uses: actions/cache@v4 + with: + path: ~/.pub-cache + key: ${{ runner.os }}-pub-cache-${{ matrix.flutter-version }} + restore-keys: | + ${{ runner.os }}-pub-cache- + + - name: Set up Flutter + uses: subosito/flutter-action@v2 + with: + flutter-version: ${{ matrix.flutter-version }} + + - name: Install dependencies + run: flutter pub get + + - name: Publish package + env: + PUB_TOKEN: ${{ secrets.PUB_TOKEN }} + run: | + flutter pub publish --force diff --git a/.gitignore b/.gitignore index 96486fd..16cb18d 100644 --- a/.gitignore +++ b/.gitignore @@ -28,3 +28,7 @@ migrate_working_dir/ .dart_tool/ .packages build/ +example/pubspec.lock + +.flutter-plugins +.flutter-plugins-dependencies diff --git a/android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java b/android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java index d007606..223031f 100644 --- a/android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java +++ b/android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java @@ -1,23 +1,24 @@ package io.flutter.plugins; -import io.flutter.plugin.common.PluginRegistry; +import androidx.annotation.Keep; +import androidx.annotation.NonNull; +import io.flutter.Log; + +import io.flutter.embedding.engine.FlutterEngine; /** * Generated file. Do not edit. + * This file is generated by the Flutter tool based on the + * plugins that support the Android platform. */ +@Keep public final class GeneratedPluginRegistrant { - public static void registerWith(PluginRegistry registry) { - if (alreadyRegisteredWith(registry)) { - return; - } - } - - private static boolean alreadyRegisteredWith(PluginRegistry registry) { - final String key = GeneratedPluginRegistrant.class.getCanonicalName(); - if (registry.hasPlugin(key)) { - return true; + private static final String TAG = "GeneratedPluginRegistrant"; + public static void registerWith(@NonNull FlutterEngine flutterEngine) { + try { + flutterEngine.getPlugins().add(new io.flutter.plugins.sharedpreferences.SharedPreferencesPlugin()); + } catch (Exception e) { + Log.e(TAG, "Error registering plugin shared_preferences_android, io.flutter.plugins.sharedpreferences.SharedPreferencesPlugin", e); } - registry.registrarFor(key); - return false; } } diff --git a/example/.gitignore b/example/.gitignore index 24476c5..065dc2c 100644 --- a/example/.gitignore +++ b/example/.gitignore @@ -31,6 +31,7 @@ migrate_working_dir/ .pub-cache/ .pub/ /build/ +pubspec.lock # Symbolication related app.*.symbols diff --git a/example/pubspec.lock b/example/pubspec.lock index 0e131b5..a627c44 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -83,6 +83,30 @@ packages: description: flutter source: sdk version: "0.0.0" + leak_tracker: + dependency: transitive + description: + name: leak_tracker + sha256: "7f0df31977cb2c0b88585095d168e689669a2cc9b97c309665e3386f3e9d341a" + url: "https://pub.dev" + source: hosted + version: "10.0.4" + leak_tracker_flutter_testing: + dependency: transitive + description: + name: leak_tracker_flutter_testing + sha256: "06e98f569d004c1315b991ded39924b21af84cf14cc94791b8aea337d25b57f8" + url: "https://pub.dev" + source: hosted + version: "3.0.3" + leak_tracker_testing: + dependency: transitive + description: + name: leak_tracker_testing + sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3" + url: "https://pub.dev" + source: hosted + version: "3.0.1" lints: dependency: transitive description: @@ -95,34 +119,34 @@ packages: dependency: transitive description: name: matcher - sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e" + sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb url: "https://pub.dev" source: hosted - version: "0.12.16" + version: "0.12.16+1" material_color_utilities: dependency: transitive description: name: material_color_utilities - sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41" + sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a" url: "https://pub.dev" source: hosted - version: "0.5.0" + version: "0.8.0" meta: dependency: transitive description: name: meta - sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e + sha256: "7687075e408b093f36e6bbf6c91878cc0d4cd10f409506f7bc996f68220b9136" url: "https://pub.dev" source: hosted - version: "1.10.0" + version: "1.12.0" path: dependency: transitive description: name: path - sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917" + sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af" url: "https://pub.dev" source: hosted - version: "1.8.3" + version: "1.9.0" riff_switch: dependency: "direct main" description: @@ -179,10 +203,10 @@ packages: dependency: transitive description: name: test_api - sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b" + sha256: "9955ae474176f7ac8ee4e989dadfb411a58c30415bcfb648fa04b2b8a03afa7f" url: "https://pub.dev" source: hosted - version: "0.6.1" + version: "0.7.0" vector_math: dependency: transitive description: @@ -191,14 +215,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.4" - web: + vm_service: dependency: transitive description: - name: web - sha256: afe077240a270dcfd2aafe77602b4113645af95d0ad31128cc02bce5ac5d5152 + name: vm_service + sha256: "3923c89304b715fb1eb6423f017651664a03bf5f4b29983627c4da791f74a4ec" url: "https://pub.dev" source: hosted - version: "0.3.0" + version: "14.2.1" sdks: - dart: ">=3.2.3 <4.0.0" - flutter: ">=3.16.5" + dart: ">=3.3.0 <4.0.0" + flutter: ">=3.18.0-18.0.pre.54" diff --git a/ios/Runner/GeneratedPluginRegistrant.m b/ios/Runner/GeneratedPluginRegistrant.m index efe65ec..4260074 100644 --- a/ios/Runner/GeneratedPluginRegistrant.m +++ b/ios/Runner/GeneratedPluginRegistrant.m @@ -6,9 +6,16 @@ #import "GeneratedPluginRegistrant.h" +#if __has_include() +#import +#else +@import shared_preferences_foundation; +#endif + @implementation GeneratedPluginRegistrant + (void)registerWithRegistry:(NSObject*)registry { + [SharedPreferencesPlugin registerWithRegistrar:[registry registrarForPlugin:@"SharedPreferencesPlugin"]]; } @end diff --git a/linux/flutter/ephemeral/.plugin_symlinks/path_provider_linux b/linux/flutter/ephemeral/.plugin_symlinks/path_provider_linux new file mode 120000 index 0000000..5d4ad7a --- /dev/null +++ b/linux/flutter/ephemeral/.plugin_symlinks/path_provider_linux @@ -0,0 +1 @@ +C:/Users/amadi/AppData/Local/Pub/Cache/hosted/pub.dev/path_provider_linux-2.2.1/ \ No newline at end of file diff --git a/linux/flutter/ephemeral/.plugin_symlinks/shared_preferences_linux b/linux/flutter/ephemeral/.plugin_symlinks/shared_preferences_linux new file mode 120000 index 0000000..28dca3a --- /dev/null +++ b/linux/flutter/ephemeral/.plugin_symlinks/shared_preferences_linux @@ -0,0 +1 @@ +C:/Users/amadi/AppData/Local/Pub/Cache/hosted/pub.dev/shared_preferences_linux-2.4.0/ \ No newline at end of file diff --git a/macos/Flutter/GeneratedPluginRegistrant.swift b/macos/Flutter/GeneratedPluginRegistrant.swift index cccf817..724bb2a 100644 --- a/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/macos/Flutter/GeneratedPluginRegistrant.swift @@ -5,6 +5,8 @@ import FlutterMacOS import Foundation +import shared_preferences_foundation func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { + SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin")) }