Skip to content

Commit

Permalink
style(flutter, lint): commit auto-formatting result, repair CI format…
Browse files Browse the repository at this point in the history
…ting check

- requires that CI for formatting runs on mac so brew + clang / swift formatters are available easily
  • Loading branch information
mikehardy committed Dec 13, 2023
1 parent 59fce1a commit 19e42fb
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 48 deletions.
29 changes: 11 additions & 18 deletions .github/workflows/flutter_checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
working-directory: ./packages/flutter

format:
runs-on: ubuntu-latest
runs-on: macos-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@v2
Expand All @@ -48,30 +48,23 @@ jobs:
run: |
./.github/workflows/scripts/install-tools.sh
curl -sL https://github.com/google/google-java-format/releases/download/google-java-format-1.3/google-java-format-1.3-all-deps.jar -o $HOME/google-java-format.jar
- name: Install native formatters
uses: nick-invision/retry@v2
with:
timeout_minutes: 10
retry_wait_seconds: 60
max_attempts: 3
command: HOMEBREW_NO_AUTO_UPDATE=1 brew install clang-format swiftformat

- name: "Bootstrap Workspace"
run: melos bootstrap
working-directory: ./packages/flutter
- name: "Dart"
run: |
melos exec -c 1 -- \
"flutter format ."
../../.github/workflows/scripts/validate-formatting.sh
working-directory: ./packages/flutter
- name: "Objective-C"
if: ${{ success() || failure() }}
run: |
melos exec -c 4 --ignore="*platform_interface*" --ignore="*web*" --dir-exists="ios" -- \
find . -maxdepth 3 -name "*.h" -o -name "*.m" -print0 \| xargs -0 clang-format -i --style=Google --verbose
melos run format
../../.github/workflows/scripts/validate-formatting.sh
working-directory: ./packages/flutter
- name: "Java"
if: ${{ success() || failure() }}
run: |
melos exec -c 4 --ignore="*platform_interface*" --ignore="*web*" --dir-exists="android" -- \
find . -maxdepth 12 -name "*.java" -print0 \| xargs -0 java -jar $HOME/google-java-format.jar --replace
../../.github/workflows/scripts/validate-formatting.sh
working-directory: ./packages/flutter


test:
runs-on: ubuntu-latest
timeout-minutes: 30
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/scripts/install-tools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

flutter config --no-analytics
flutter pub global activate melos 1.1.0
flutter pub global activate flutter_plugin_tools
echo "$HOME/.pub-cache/bin" >> $GITHUB_PATH
echo "$GITHUB_WORKSPACE/_flutter/.pub-cache/bin" >> $GITHUB_PATH
echo "$GITHUB_WORKSPACE/_flutter/bin/cache/dart-sdk/bin" >> $GITHUB_PATH
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# melos_managed_dependency_overrides: notifee,notifee_platform_interface
dependency_overrides:
notifee:
path: ../
notifee_platform_interface:
path: ../../notifee_platform_interface
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,21 @@ public class NotifeePluginSwift: NSObject, FlutterPlugin, NotifeeCoreDelegate {

var args = NSDictionary()

init(messenger: FlutterBinaryMessenger, channel: FlutterMethodChannel) {
init(messenger: FlutterBinaryMessenger, channel: FlutterMethodChannel) {
self.messenger = messenger
self.channel = channel
}

public func didReceiveNotifeeCoreEvent(_ event: [AnyHashable: Any]) {
print(event)

DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
if (UIApplication.shared.applicationState == .background) {
self.channel?.invokeMethod("Notifee#onBackgroundEvent" , arguments: event)
} else {
NotifeePluginSwift.eventSink?(event)
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
if UIApplication.shared.applicationState == .background {
self.channel?.invokeMethod("Notifee#onBackgroundEvent", arguments: event)
} else {
NotifeePluginSwift.eventSink?(event)
}
}
}
}

public static func register(with registrar: FlutterPluginRegistrar) {
Expand All @@ -34,8 +34,6 @@ public class NotifeePluginSwift: NSObject, FlutterPlugin, NotifeeCoreDelegate {

let channel = FlutterMethodChannel(name: kFLTNotifeeChannelName, binaryMessenger: binaryMessenger)
let instance = NotifeePluginSwift(messenger: binaryMessenger, channel: channel)



registrar.addMethodCallDelegate(instance, channel: channel)
registrar.publish(instance)
Expand All @@ -46,7 +44,7 @@ public class NotifeePluginSwift: NSObject, FlutterPlugin, NotifeeCoreDelegate {
eventChannel.setStreamHandler(NotifeeStreamHandler())
}

internal func displayNotification(arguments: [String: Any], result: @escaping FlutterResult) {
func displayNotification(arguments: [String: Any], result: @escaping FlutterResult) {
NotifeeCore.displayNotification(arguments, with: { (error: Error?) in
if error != nil {
result(error)
Expand All @@ -56,7 +54,7 @@ public class NotifeePluginSwift: NSObject, FlutterPlugin, NotifeeCoreDelegate {
})
}

internal func createTriggerNotification(arguments: [String: Any], result: @escaping FlutterResult) {
func createTriggerNotification(arguments: [String: Any], result: @escaping FlutterResult) {
NotifeeCore.createTriggerNotification(arguments["notification"] as! [String: Any], withTrigger: arguments["trigger"] as! [String: Any], with: { (error: Error?) in
if error != nil {
result(error)
Expand All @@ -66,7 +64,7 @@ public class NotifeePluginSwift: NSObject, FlutterPlugin, NotifeeCoreDelegate {
})
}

internal func cancelAllNotifications(arguments: [String: Any], result: @escaping FlutterResult) {
func cancelAllNotifications(arguments: [String: Any], result: @escaping FlutterResult) {
NotifeeCore.cancelAllNotifications(arguments["type"] as! Int, with: { (error: Error?) in
if error != nil {
result(error)
Expand All @@ -76,7 +74,7 @@ public class NotifeePluginSwift: NSObject, FlutterPlugin, NotifeeCoreDelegate {
})
}

internal func cancelAllNotificationsWithIds(arguments: [String: Any], result: @escaping FlutterResult) {
func cancelAllNotificationsWithIds(arguments: [String: Any], result: @escaping FlutterResult) {
NotifeeCore.cancelAllNotifications(withIds: arguments["type"] as! Int, withIds: arguments["ids"] as! [String], with: { (error: Error?) in
if error != nil {
result(error)
Expand All @@ -86,7 +84,7 @@ public class NotifeePluginSwift: NSObject, FlutterPlugin, NotifeeCoreDelegate {
})
}

internal func requestPermission(arguments _: [String: Any], result: @escaping FlutterResult) {
func requestPermission(arguments _: [String: Any], result: @escaping FlutterResult) {
NotifeeCore.requestPermission(["alert": true, "sound": true, "badge": true], with: { (error: Error?, settings: Any?) in
if error != nil {
result(error)
Expand All @@ -96,7 +94,7 @@ public class NotifeePluginSwift: NSObject, FlutterPlugin, NotifeeCoreDelegate {
})
}

internal func getBadgeCount(result: @escaping FlutterResult) {
func getBadgeCount(result: @escaping FlutterResult) {
NotifeeCore.getBadgeCount { (error: Error?, count: Any?) in
if error != nil {
result(error)
Expand All @@ -106,7 +104,7 @@ public class NotifeePluginSwift: NSObject, FlutterPlugin, NotifeeCoreDelegate {
}
}

internal func getNotificationCategories(result: @escaping FlutterResult) {
func getNotificationCategories(result: @escaping FlutterResult) {
NotifeeCore.getNotificationCategories { (error: Error?, categories: Any?) in
if error != nil {
result(error)
Expand All @@ -116,7 +114,7 @@ public class NotifeePluginSwift: NSObject, FlutterPlugin, NotifeeCoreDelegate {
}
}

internal func getNotificationSettings(result: @escaping FlutterResult) {
func getNotificationSettings(result: @escaping FlutterResult) {
NotifeeCore.getNotificationSettings { (error: Error?, settings: Any?) in
if error != nil {
result(error)
Expand All @@ -126,7 +124,7 @@ public class NotifeePluginSwift: NSObject, FlutterPlugin, NotifeeCoreDelegate {
}
}

internal func getTriggerNotificationIds(result: @escaping FlutterResult) {
func getTriggerNotificationIds(result: @escaping FlutterResult) {
NotifeeCore.getTriggerNotificationIds { (error: Error?, ids: Any?) in
if error != nil {
result(error)
Expand All @@ -136,7 +134,7 @@ public class NotifeePluginSwift: NSObject, FlutterPlugin, NotifeeCoreDelegate {
}
}

internal func getTriggerNotifications(result: @escaping FlutterResult) {
func getTriggerNotifications(result: @escaping FlutterResult) {
NotifeeCore.getTriggerNotifications { (error: Error?, notifications: Any?) in
if error != nil {
result(error)
Expand All @@ -146,7 +144,7 @@ public class NotifeePluginSwift: NSObject, FlutterPlugin, NotifeeCoreDelegate {
}
}

internal func getDisplayedNotifications(result: @escaping FlutterResult) {
func getDisplayedNotifications(result: @escaping FlutterResult) {
NotifeeCore.getDisplayedNotifications { (error: Error?, notifications: Any?) in
if error != nil {
result(error)
Expand All @@ -155,8 +153,8 @@ public class NotifeePluginSwift: NSObject, FlutterPlugin, NotifeeCoreDelegate {
}
}
}
internal func getInitialNotification(result: @escaping FlutterResult) {

func getInitialNotification(result: @escaping FlutterResult) {
NotifeeCore.getInitialNotification { (error: Error?, notification: Any?) in
if error != nil {
result(error)
Expand All @@ -166,7 +164,7 @@ public class NotifeePluginSwift: NSObject, FlutterPlugin, NotifeeCoreDelegate {
}
}

internal func incrementBadgeCount(arguments: Int, result: @escaping FlutterResult) {
func incrementBadgeCount(arguments: Int, result: @escaping FlutterResult) {
NotifeeCore.incrementBadgeCount(arguments, with: { (error: Error?) in
if error != nil {
result(error)
Expand All @@ -176,7 +174,7 @@ public class NotifeePluginSwift: NSObject, FlutterPlugin, NotifeeCoreDelegate {
})
}

internal func decrementBadgeCount(arguments: Int, result: @escaping FlutterResult) {
func decrementBadgeCount(arguments: Int, result: @escaping FlutterResult) {
NotifeeCore.decrementBadgeCount(arguments, with: { (error: Error?) in
if error != nil {
result(error)
Expand All @@ -186,7 +184,7 @@ public class NotifeePluginSwift: NSObject, FlutterPlugin, NotifeeCoreDelegate {
})
}

internal func setBadgeCount(arguments: Int, result: @escaping FlutterResult) {
func setBadgeCount(arguments: Int, result: @escaping FlutterResult) {
NotifeeCore.setBadgeCount(arguments, with: { (error: Error?) in
if error != nil {
result(error)
Expand All @@ -196,7 +194,7 @@ public class NotifeePluginSwift: NSObject, FlutterPlugin, NotifeeCoreDelegate {
})
}

internal func setNotificationCategories(arguments: [[AnyHashable: Any]], result: @escaping FlutterResult) {
func setNotificationCategories(arguments: [[AnyHashable: Any]], result: @escaping FlutterResult) {
NotifeeCore.setNotificationCategories(arguments, with: { (error: Error?) in
if error != nil {
result(error)
Expand All @@ -210,7 +208,7 @@ public class NotifeePluginSwift: NSObject, FlutterPlugin, NotifeeCoreDelegate {
if call.method == "displayNotification" {
displayNotification(arguments: call.arguments as! [String: Any], result: result)
} else if call.method == "getInitialNotification" {
getInitialNotification(result: result)
getInitialNotification(result: result)
} else if call.method == "createTriggerNotification" {
createTriggerNotification(arguments: call.arguments as! [String: Any], result: result)
} else if call.method == "cancelAllNotifications" {
Expand Down
4 changes: 4 additions & 0 deletions packages/flutter/packages/notifee/pubspec_overrides.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# melos_managed_dependency_overrides: notifee_platform_interface
dependency_overrides:
notifee_platform_interface:
path: ../notifee_platform_interface
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ import 'package:flutter_test/flutter_test.dart';
typedef MethodCallCallback = dynamic Function(MethodCall methodCall);

void handleMethodCall(MethodCallCallback methodCallCallback) =>
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
.setMockMethodCallHandler(MethodChannelNotifee.channel, (call) async {
return await methodCallCallback(call);
});

void initializeMethodChannel() {
TestWidgetsFlutterBinding.ensureInitialized();
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
.setMockMethodCallHandler(MethodChannelNotifee.channel, (call) async {
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
.setMockMethodCallHandler(MethodChannelNotifee.channel, (call) async {
return null;
});
}
Expand Down

0 comments on commit 19e42fb

Please sign in to comment.