|
1 | | -## Project Workflow |
2 | | -- Project uses GitHub Actions |
3 | | -- Use `ktlint -F .` in root folder to format Kotlin code |
4 | | -- Use SwiftLint for code formatting |
5 | | -- Always resolve formatting and analyzer errors before completing a task |
6 | | -- **CRITICAL**: Always run `ktlint -F .` after modifying any Kotlin files before committing |
7 | | - |
8 | | -## Pigeon Code Generation |
9 | | -- Pigeon configuration is in `workmanager_platform_interface/pigeons/workmanager_api.dart` |
10 | | -- **MUST use melos to regenerate Pigeon files**: `melos run generate:pigeon` |
11 | | -- ⚠️ **DO NOT** run pigeon directly - always use the melos script for consistency |
12 | | -- Generated files: |
13 | | - - Dart: `workmanager_platform_interface/lib/src/pigeon/workmanager_api.g.dart` |
14 | | - - Kotlin: `workmanager_android/android/src/main/kotlin/dev/fluttercommunity/workmanager/pigeon/WorkmanagerApi.g.kt` |
15 | | - - Swift: `workmanager_apple/ios/Classes/pigeon/WorkmanagerApi.g.swift` |
16 | | -- Do not manually edit generated files (*.g.* files) |
17 | | -- Generated files may have different formatting than dart format - this is expected and handled by exclusion patterns |
18 | | - |
19 | | -## Code Formatting Configuration |
20 | | -- `.editorconfig` in root folder configures ktlint to ignore Pigeon-generated Kotlin files |
21 | | -- `.swiftlint.yml` in root folder excludes Pigeon-generated Swift files from linting |
22 | | - |
23 | | -## GitHub Actions Configuration |
24 | | -- Format checks: `.github/workflows/format.yml` |
25 | | - - Runs dart format, ktlint, and SwiftLint |
26 | | -- Tests: `.github/workflows/test.yml` |
27 | | - - `test`: Runs Dart unit tests |
28 | | - - `native_ios_tests`: Runs iOS native tests with xcodebuild |
29 | | - - `native_android_tests`: Runs Android native tests with Gradle |
30 | | - - `drive_ios`: Runs Flutter integration tests on iOS simulator |
31 | | - - `drive_android`: Runs Flutter integration tests on Android emulator |
32 | | - |
33 | | -## Testing Strategy & Preferences |
34 | | -- **Focus on business logic**: Test unique platform implementation logic, not Pigeon plumbing |
35 | | -- **Trust third-party components**: Consider Pigeon a trusted component - don't test its internals |
36 | | -- **Platform-specific behavior**: Test what makes each platform unique (Android WorkManager vs iOS BGTaskScheduler) |
37 | | -- **Avoid channel mocking**: Don't mock platform channels unless absolutely necessary |
38 | | -- **Test unsupported operations**: Verify platform-specific UnsupportedError throwing |
39 | | -- **Integration over unit**: Prefer integration tests for complete platform behavior validation |
40 | | - |
41 | | -## Test Execution |
42 | | -- Run all tests: `flutter test` (from root or individual package) |
43 | | -- Android tests: `cd workmanager_android && flutter test` |
44 | | -- Apple tests: `cd workmanager_apple && flutter test` |
45 | | -- Native Android tests: `cd example/android && ./gradlew :workmanager_android:test` |
46 | | -- Native iOS tests: `cd example/ios && xcodebuild test -workspace Runner.xcworkspace -scheme Runner -destination 'platform=iOS Simulator,name=iPhone 16,OS=latest'` |
47 | | -- Always build example app before completing: `cd example && flutter build apk --debug && flutter build ios --debug --no-codesign` |
48 | | - |
49 | | -## Pigeon Migration Status |
50 | | -- ✅ Migration to Pigeon v22.7.4 completed successfully |
51 | | -- ✅ All platforms (Android, iOS) migrated from MethodChannel to Pigeon |
52 | | -- ✅ Unit tests refactored to focus on platform-specific business logic |
53 | | -- ✅ Code formatting and linting properly configured for generated files |
54 | | -- ✅ All tests passing: Dart unit tests, native Android tests, native iOS tests |
55 | | -- ✅ Example app builds successfully for both Android APK and iOS app |
56 | | - |
57 | | -## Documentation Preferences |
58 | | -- Keep summaries concise - don't repeat completed tasks in status updates |
59 | | -- Focus on current progress and next steps |
60 | | -- Document decisions and architectural choices |
61 | | - |
62 | | -## CHANGELOG Management |
63 | | -- Document improvements in CHANGELOG.md files immediately when implemented |
64 | | -- Use "Future" as the version header for unreleased changes (standard open source practice) |
65 | | -- Keep entries brief and focused on user-facing impact |
66 | | -- Relevant files: workmanager/CHANGELOG.md, workmanager_android/CHANGELOG.md, workmanager_apple/CHANGELOG.md |
67 | | - |
68 | | -## GitHub Actions - Package Analysis |
69 | | -- The `analysis.yml` workflow runs package analysis for all packages |
70 | | -- It performs `flutter analyze` and `dart pub publish --dry-run` for each package |
71 | | -- The dry-run validates that packages are ready for publishing |
72 | | -- Common issues that cause failures: |
73 | | - - Uncommitted changes in git (packages should be published from clean state) |
74 | | - - Files ignored by .gitignore but checked into git (use .pubignore if needed) |
75 | | - - Modified files that haven't been committed |
76 | | -- Always ensure all changes are committed before pushing to avoid CI failures |
77 | | - |
78 | | -## GitHub Actions - Formatting Issues |
79 | | -- The `format.yml` workflow runs formatting checks |
80 | | -- ❌ **Important Discovery**: `analysis_options.yml formatter.exclude` does NOT prevent `dart format` from formatting files |
81 | | -- ✅ **FIXED**: Updated CI workflow to use `find` command to exclude .g.dart files: |
82 | | - ```bash |
83 | | - find . -name "*.dart" ! -name "*.g.dart" ! -path "*/.*" -print0 | xargs -0 dart format --set-exit-if-changed |
84 | | - ``` |
85 | | -- **Root Issue**: `dart format` ignores analysis_options.yml exclusions and will always format ALL Dart files |
86 | | -- **Solution**: Filter files before passing to dart format to exclude generated files |
87 | | -- The `analysis_options.yml` exclusions only affect static analysis, not formatting |
| 1 | +## Pre-Commit Requirements |
| 2 | +**CRITICAL**: Always run from project root before ANY commit: |
| 3 | +1. `ktlint -F .` |
| 4 | +2. `find . -name "*.dart" ! -name "*.g.dart" ! -path "*/.*" -print0 | xargs -0 dart format --set-exit-if-changed` |
| 5 | +3. `flutter test` (all Dart tests) |
| 6 | +4. `cd example/android && ./gradlew :workmanager_android:test` (Android native tests) |
| 7 | + |
| 8 | +## Code Generation |
| 9 | +- Regenerate Pigeon files: `melos run generate:pigeon` |
| 10 | +- Do not manually edit *.g.* files |
| 11 | + |
| 12 | +## Test Quality Requirements |
| 13 | +- **NEVER create useless tests**: No `assert(true)`, `expect(true, true)`, or compilation-only tests |
| 14 | +- **Test real logic**: Exercise actual methods with real inputs and verify meaningful outputs |
| 15 | +- **Test edge cases**: null inputs, error conditions, boundary values |
| 16 | + |
| 17 | +## Complex Component Testing |
| 18 | +- **BackgroundWorker**: Cannot be unit tested due to Flutter engine dependencies - use integration tests |
0 commit comments