|
| 1 | +name: Run tests |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + pull_request: |
| 7 | + branches: [main] |
| 8 | + |
| 9 | +jobs: |
| 10 | + dart-unit-tests: |
| 11 | + name: Dart unit tests |
| 12 | + runs-on: ubuntu-latest |
| 13 | + |
| 14 | + steps: |
| 15 | + - uses: actions/checkout@v4 |
| 16 | + |
| 17 | + - name: Set up Flutter (stable) |
| 18 | + uses: subosito/flutter-action@v2 |
| 19 | + with: |
| 20 | + channel: stable |
| 21 | + cache: true |
| 22 | + |
| 23 | + - name: Install package dependencies |
| 24 | + run: flutter pub get |
| 25 | + |
| 26 | + - name: Run tests |
| 27 | + run: flutter test |
| 28 | + |
| 29 | + native-macos-unit-tests: |
| 30 | + name: Native macOS unit tests |
| 31 | + runs-on: macos-latest |
| 32 | + |
| 33 | + steps: |
| 34 | + - uses: actions/checkout@v4 |
| 35 | + |
| 36 | + - name: Set up Flutter (stable) |
| 37 | + uses: subosito/flutter-action@v2 |
| 38 | + with: |
| 39 | + channel: stable |
| 40 | + cache: true |
| 41 | + |
| 42 | + - name: Install dependencies |
| 43 | + run: flutter pub get |
| 44 | + working-directory: example |
| 45 | + |
| 46 | + - name: Set up Xcode |
| 47 | + uses: maxim-lobanov/setup-xcode@v1 |
| 48 | + with: |
| 49 | + xcode-version: latest-stable |
| 50 | + |
| 51 | + # macOS 14+ requires UI access to open the app for running tests. To work around this, disable macOS sandboxing. |
| 52 | + # For more details, see: https://github.com/flutter/packages/pull/6866 |
| 53 | + - name: Disable macOS sandboxing |
| 54 | + run: | |
| 55 | + # Replace <true/> with <false/> for DebugProfile.entitlements |
| 56 | + /usr/libexec/PlistBuddy -c "Set :com.apple.security.app-sandbox bool false" DebugProfile.entitlements |
| 57 | +
|
| 58 | + # Replace <true/> with <false/> for Release.entitlements |
| 59 | + /usr/libexec/PlistBuddy -c "Set :com.apple.security.app-sandbox bool false" Release.entitlements |
| 60 | + working-directory: example/macos/Runner |
| 61 | + |
| 62 | + # Native macOS tests are in the example app: https://docs.flutter.dev/testing/testing-plugins#native-unit-tests |
| 63 | + - name: Run tests |
| 64 | + run: xcodebuild test -workspace Runner.xcworkspace -scheme Runner -configuration Debug -quiet |
| 65 | + working-directory: example/macos |
0 commit comments