Skip to content

Commit

Permalink
refactor test workflow to use script
Browse files Browse the repository at this point in the history
  • Loading branch information
charafau committed Aug 20, 2024
1 parent 8b978e3 commit 0810ded
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 23 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/scripts/install-flutter.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

BRANCH=$1

git clone https://github.com/flutter/flutter.git --depth 1 -b $BRANCH _flutter
echo "$GITHUB_WORKSPACE/_flutter/bin" >>$GITHUB_PATH
10 changes: 10 additions & 0 deletions .github/workflows/scripts/install-tools.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

set -e

flutter config --no-analytics
flutter pub global activate melos 3.0.0
echo "$HOME/.pub-cache/bin" >>$GITHUB_PATH
echo "$HOME/AppData/Local/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
57 changes: 34 additions & 23 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: subosito/flutter-action@v2
with:
channel: 'stable'
- name: "Install Flutter"
run: ./.github/workflows/scripts/install-flutter.sh stable
- name: "Install Tools"
run: |
./.github/workflows/scripts/install-tools.sh
- name: Test
run: |
dart pub global activate melos
melos bootstrap
cd workmanager
flutter pub get
Expand All @@ -26,27 +27,37 @@ jobs:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- uses: subosito/flutter-action@v2
with:
channel: 'stable'
- name: "Install Flutter"
run: ./.github/workflows/scripts/install-flutter.sh stable
- name: "Install Tools"
run: |
./.github/workflows/scripts/install-tools.sh
- name: Build iOS App
run: cd example && flutter build ios --debug --no-codesign
- name: Run native iOS tests
run: cd example/ios && xcodebuild -workspace Runner.xcworkspace -scheme Runner -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 12,OS=16.2' test

native_android_tests:
runs-on: macos-latest
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 21
- uses: subosito/flutter-action@v2
- name: "Install Flutter"
run: ./.github/workflows/scripts/install-flutter.sh stable
- name: "Install Tools"
run: |
./.github/workflows/scripts/install-tools.sh
- name: Run Flutter Driver tests
uses: reactivecircus/android-emulator-runner@v2
with:
channel: 'stable'
- name: Activate melos
run: dart pub global activate melos && melos bootstrap
arch: x86_64
profile: Nexus 6
api-level: 34
target: google_apis
script: cd example && flutter test integration_test/workmanager_integration_test.dart
- name: Build Android App
run: cd example && flutter build apk --debug
- name: Run native Android tests
Expand All @@ -64,12 +75,12 @@ jobs:
with:
model: '${{ matrix.device }}'
- uses: actions/checkout@v4
- uses: subosito/flutter-action@v2
with:
channel: 'stable'
- name: "Install Flutter"
run: ./.github/workflows/scripts/install-flutter.sh stable
- name: "Install Tools"
run: |
./.github/workflows/scripts/install-tools.sh
# Run flutter integrate tests
- name: Activate melos
run: dart pub global activate melos && melos bootstrap
- name: Run Flutter integration tests
run: cd example && flutter test integration_test/workmanager_integration_test.dart

Expand All @@ -90,11 +101,11 @@ jobs:
with:
distribution: 'temurin'
java-version: 21
- uses: subosito/flutter-action@v2
with:
channel: 'stable'
- name: Activate melos
run: dart pub global activate melos && melos bootstrap
- name: "Install Flutter"
run: ./.github/workflows/scripts/install-flutter.sh stable
- name: "Install Tools"
run: |
./.github/workflows/scripts/install-tools.sh
- name: Enable KVM
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
Expand All @@ -103,7 +114,7 @@ jobs:
- name: Run Flutter Driver tests
uses: reactivecircus/android-emulator-runner@v2
with:
arch: x86_64
# arch: x86_64
profile: Nexus 6
api-level: ${{ matrix.api-level }}
target: ${{ matrix.target }}
Expand Down

0 comments on commit 0810ded

Please sign in to comment.