Skip to content

Commit 0810ded

Browse files
committed
refactor test workflow to use script
1 parent 8b978e3 commit 0810ded

File tree

3 files changed

+50
-23
lines changed

3 files changed

+50
-23
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
3+
BRANCH=$1
4+
5+
git clone https://github.com/flutter/flutter.git --depth 1 -b $BRANCH _flutter
6+
echo "$GITHUB_WORKSPACE/_flutter/bin" >>$GITHUB_PATH
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
flutter config --no-analytics
6+
flutter pub global activate melos 3.0.0
7+
echo "$HOME/.pub-cache/bin" >>$GITHUB_PATH
8+
echo "$HOME/AppData/Local/Pub/Cache/bin" >>$GITHUB_PATH
9+
echo "$GITHUB_WORKSPACE/_flutter/.pub-cache/bin" >>$GITHUB_PATH
10+
echo "$GITHUB_WORKSPACE/_flutter/bin/cache/dart-sdk/bin" >>$GITHUB_PATH

.github/workflows/test.yml

Lines changed: 34 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,13 @@ jobs:
1111
runs-on: ubuntu-latest
1212
steps:
1313
- uses: actions/checkout@v4
14-
- uses: subosito/flutter-action@v2
15-
with:
16-
channel: 'stable'
14+
- name: "Install Flutter"
15+
run: ./.github/workflows/scripts/install-flutter.sh stable
16+
- name: "Install Tools"
17+
run: |
18+
./.github/workflows/scripts/install-tools.sh
1719
- name: Test
1820
run: |
19-
dart pub global activate melos
2021
melos bootstrap
2122
cd workmanager
2223
flutter pub get
@@ -26,27 +27,37 @@ jobs:
2627
runs-on: macos-latest
2728
steps:
2829
- uses: actions/checkout@v4
29-
- uses: subosito/flutter-action@v2
30-
with:
31-
channel: 'stable'
30+
- name: "Install Flutter"
31+
run: ./.github/workflows/scripts/install-flutter.sh stable
32+
- name: "Install Tools"
33+
run: |
34+
./.github/workflows/scripts/install-tools.sh
3235
- name: Build iOS App
3336
run: cd example && flutter build ios --debug --no-codesign
3437
- name: Run native iOS tests
3538
run: cd example/ios && xcodebuild -workspace Runner.xcworkspace -scheme Runner -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 12,OS=16.2' test
3639

3740
native_android_tests:
38-
runs-on: macos-latest
41+
runs-on: ubuntu-latest
3942
steps:
4043
- uses: actions/checkout@v4
4144
- uses: actions/setup-java@v4
4245
with:
4346
distribution: 'temurin'
4447
java-version: 21
45-
- uses: subosito/flutter-action@v2
48+
- name: "Install Flutter"
49+
run: ./.github/workflows/scripts/install-flutter.sh stable
50+
- name: "Install Tools"
51+
run: |
52+
./.github/workflows/scripts/install-tools.sh
53+
- name: Run Flutter Driver tests
54+
uses: reactivecircus/android-emulator-runner@v2
4655
with:
47-
channel: 'stable'
48-
- name: Activate melos
49-
run: dart pub global activate melos && melos bootstrap
56+
arch: x86_64
57+
profile: Nexus 6
58+
api-level: 34
59+
target: google_apis
60+
script: cd example && flutter test integration_test/workmanager_integration_test.dart
5061
- name: Build Android App
5162
run: cd example && flutter build apk --debug
5263
- name: Run native Android tests
@@ -64,12 +75,12 @@ jobs:
6475
with:
6576
model: '${{ matrix.device }}'
6677
- uses: actions/checkout@v4
67-
- uses: subosito/flutter-action@v2
68-
with:
69-
channel: 'stable'
78+
- name: "Install Flutter"
79+
run: ./.github/workflows/scripts/install-flutter.sh stable
80+
- name: "Install Tools"
81+
run: |
82+
./.github/workflows/scripts/install-tools.sh
7083
# Run flutter integrate tests
71-
- name: Activate melos
72-
run: dart pub global activate melos && melos bootstrap
7384
- name: Run Flutter integration tests
7485
run: cd example && flutter test integration_test/workmanager_integration_test.dart
7586

@@ -90,11 +101,11 @@ jobs:
90101
with:
91102
distribution: 'temurin'
92103
java-version: 21
93-
- uses: subosito/flutter-action@v2
94-
with:
95-
channel: 'stable'
96-
- name: Activate melos
97-
run: dart pub global activate melos && melos bootstrap
104+
- name: "Install Flutter"
105+
run: ./.github/workflows/scripts/install-flutter.sh stable
106+
- name: "Install Tools"
107+
run: |
108+
./.github/workflows/scripts/install-tools.sh
98109
- name: Enable KVM
99110
run: |
100111
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
@@ -103,7 +114,7 @@ jobs:
103114
- name: Run Flutter Driver tests
104115
uses: reactivecircus/android-emulator-runner@v2
105116
with:
106-
arch: x86_64
117+
# arch: x86_64
107118
profile: Nexus 6
108119
api-level: ${{ matrix.api-level }}
109120
target: ${{ matrix.target }}

0 commit comments

Comments
 (0)