Skip to content

Commit

Permalink
ci: run integration tests with the latest runners and fix tests stabi…
Browse files Browse the repository at this point in the history
…lity
  • Loading branch information
jokerttu committed Sep 26, 2024
1 parent 0d17144 commit eca1c12
Show file tree
Hide file tree
Showing 12 changed files with 222 additions and 109 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/analyze.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,15 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b
name: Checkout code
- uses: subosito/flutter-action@44ac965b96f18d999802d4b807e3256d5a3f9fa1
name: Setup flutter
with:
flutter-version: "3.22.x"
channel: "stable"
cache: true
- uses: bluefireteam/melos-action@6085791af7036f6366c9a4b9d55105c0ef9c6388
name: Setup melos
with:
melos-version: "6.0.0"
- name: "Run Flutter Analyze"
Expand All @@ -45,16 +48,20 @@ jobs:
timeout-minutes: 20
steps:
- uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b
name: Checkout code
- uses: actions/setup-java@v4
name: Setup java
with:
distribution: "temurin"
java-version: "17"
- uses: subosito/flutter-action@44ac965b96f18d999802d4b807e3256d5a3f9fa1
name: Setup flutter
with:
flutter-version: "3.22.x"
channel: "stable"
cache: true
- uses: bluefireteam/melos-action@6085791af7036f6366c9a4b9d55105c0ef9c6388
name: Setup melos
with:
melos-version: "6.0.0"
- name: Restore Cache
Expand Down
73 changes: 64 additions & 9 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,21 @@ concurrency:

jobs:
test-dart:
name: Run dart unit tests
timeout-minutes: 45
runs-on:
labels: ubuntu-latest-8core
labels: ubuntu-latest
steps:
- uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b
name: Checkout code
- uses: actions/setup-java@v4
name: Setup java
with:
distribution: "temurin"
java-version: "17"
cache: "gradle"
- uses: subosito/flutter-action@44ac965b96f18d999802d4b807e3256d5a3f9fa1
name: Setup flutter
with:
flutter-version: "3.22.x"
channel: "stable"
Expand All @@ -47,28 +51,41 @@ jobs:
run: melos run test:dart

test-android:
name: Run Android native unit tests
timeout-minutes: 45
runs-on:
labels: ubuntu-latest-8core
labels: ubuntu-latest
steps:
- uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b
name: Checkout code
- uses: actions/setup-java@v4
name: Setup java
with:
distribution: "temurin"
java-version: "17"
cache: "gradle"
- uses: subosito/flutter-action@44ac965b96f18d999802d4b807e3256d5a3f9fa1
name: Setup flutter
with:
flutter-version: "3.22.x"
channel: "stable"
cache: true
- uses: bluefireteam/melos-action@6085791af7036f6366c9a4b9d55105c0ef9c6388
name: Setup melos
with:
melos-version: "6.0.0"
- name: Cache build
uses: actions/cache@v4
with:
path: example/build
key: ${{ runner.os }}-example-build-${{ github.job }}-${{ github.run_number }}
restore-keys: |
${{ runner.os }}-example-build-
- name: "Run Android native unit tests"
run: melos run test:android

test-ios:
name: Run iOS native unit tests
timeout-minutes: 45
runs-on:
labels: macos-latest-xlarge
Expand All @@ -77,53 +94,78 @@ jobs:
working_directory: ["example"]
steps:
- uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b
- uses: actions/cache@v4
with:
path: "**/Pods"
key: ${{ runner.os }}-pods-${{ hashFiles('**/*.podspec') }}
restore-keys: |
${{ runner.os }}-pods-
name: Checkout code
- uses: subosito/flutter-action@44ac965b96f18d999802d4b807e3256d5a3f9fa1
name: Setup flutter
with:
flutter-version: "3.22.x"
channel: "stable"
cache: true
- uses: bluefireteam/melos-action@6085791af7036f6366c9a4b9d55105c0ef9c6388
with:
melos-version: "6.0.0"
- uses: actions/cache@v4
name: Cache podfiles
with:
path: "**/Pods"
key: ${{ runner.os }}-pods-${{ hashFiles('**/*.podspec') }}
restore-keys: |
${{ runner.os }}-pods-
- name: Cache build
uses: actions/cache@v4
with:
path: example/build
key: ${{ runner.os }}-example-build-${{ github.job }}-${{ github.run_number }}
restore-keys: |
${{ runner.os }}-example-build-
- name: Select XCode 16.0
run: sudo xcode-select -s '/Applications/Xcode_16.app/Contents/Developer'
- name: Generate necessary files with flutter build
working-directory: ${{ matrix.working_directory }}
run: flutter build ios --config-only
- name: "Run iOS native unit tests"
run: DEVICE='iPhone 14 Pro' melos run test:ios

build-android:
name: Build Android
needs: [test-dart, test-android, test-ios]
if: contains(github.base_ref, 'main')
timeout-minutes: 45
runs-on:
labels: ubuntu-latest-8core
labels: ubuntu-latest
env:
MAPS_API_KEY: ${{ secrets.ACTIONS_API_KEY }}
steps:
- uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b
name: Checkout code
- uses: actions/setup-java@v4
name: Setup java
with:
distribution: "temurin"
java-version: "17"
cache: "gradle"
- uses: subosito/flutter-action@44ac965b96f18d999802d4b807e3256d5a3f9fa1
name: Setup flutter
with:
flutter-version: "3.22.x"
channel: "stable"
cache: true
- uses: bluefireteam/melos-action@6085791af7036f6366c9a4b9d55105c0ef9c6388
name: Setup melos
with:
melos-version: "6.0.0"
- name: Cache build
uses: actions/cache@v4
with:
path: example/build
key: ${{ runner.os }}-example-build-${{ github.job }}-${{ github.run_number }}
restore-keys: |
${{ runner.os }}-example-build-
- name: "Run build for Android"
run: melos run flutter-build-android

build-ios:
name: Build iOS
needs: [test-dart, test-android, test-ios]
if: contains(github.base_ref, 'main')
timeout-minutes: 90
Expand All @@ -132,20 +174,33 @@ jobs:
MAPS_API_KEY: ${{ secrets.ACTIONS_API_KEY }}
steps:
- uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b
name: Checkout code
- uses: subosito/flutter-action@44ac965b96f18d999802d4b807e3256d5a3f9fa1
name: Setup flutter
with:
flutter-version: "3.22.x"
channel: "stable"
cache: true
architecture: x64
- uses: bluefireteam/melos-action@6085791af7036f6366c9a4b9d55105c0ef9c6388
name: Setup melos
with:
melos-version: "6.0.0"
- uses: actions/cache@v4
name: Cache podfiles
with:
path: "**/Pods"
key: ${{ runner.os }}-pods-${{ hashFiles('**/*.podspec') }}
restore-keys: |
${{ runner.os }}-pods-
- name: Cache build
uses: actions/cache@v4
with:
path: example/build
key: ${{ runner.os }}-example-build-${{ github.job }}-${{ github.run_number }}
restore-keys: |
${{ runner.os }}-example-build-
- name: Select XCode 16.0
run: sudo xcode-select -s '/Applications/Xcode_16.app/Contents/Developer'
- name: "Run build for iOS"
run: melos run flutter-build-ios
81 changes: 63 additions & 18 deletions .github/workflows/integration_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,15 @@ concurrency:

jobs:
android:
name: Run Android Integration Tests
if: contains(github.base_ref, 'main')
timeout-minutes: 45
timeout-minutes: 90
strategy:
matrix:
patrol_cli_version: [2.7.0]
working_directory: ["example"]
runs-on:
labels: ubuntu-latest-8core
labels: ubuntu-latest
env:
MAPS_API_KEY: ${{ secrets.ACTIONS_API_KEY }}
steps:
Expand All @@ -42,7 +43,9 @@ jobs:
echo "MAPS_API_KEY is not available or empty."
exit 1
- uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b
name: Checkout code
- uses: actions/setup-java@v4
name: Setup java
with:
distribution: "temurin"
java-version: "17"
Expand All @@ -63,10 +66,23 @@ jobs:
~/.android/adb*
key: avd
- uses: subosito/flutter-action@44ac965b96f18d999802d4b807e3256d5a3f9fa1
name: Setup flutter
with:
flutter-version: "3.22.x"
channel: "stable"
cache: true
- name: Cache build
uses: actions/cache@v4
with:
path: example/build
key: ${{ runner.os }}-example-build-${{ github.job }}-${{ github.run_number }}
restore-keys: |
${{ runner.os }}-example-build-
- uses: actions/cache@v4
name: Cache pub global packages
with:
path: ~/.pub-cache
key: ${{ runner.os }}-pub-cache-${{ matrix.patrol_cli_version }}
- name: Install patrol_cli
run: flutter pub global activate patrol_cli ${{ matrix.patrol_cli_version }}
- name: Run flutter pub get
Expand All @@ -77,13 +93,13 @@ jobs:
$ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager --list_installed
echo "Installing system image"
echo "y" | $ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager "system-images;android-33;google_apis;x86_64"
echo "y" | $ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager "system-images;android-35;google_apis;x86_64"
echo "Creating AVD"
echo "no" | $ANDROID_SDK_ROOT/cmdline-tools/latest/bin/avdmanager create avd -n test_emulator -k "system-images;android-33;google_apis;x86_64" --force
echo "no" | $ANDROID_SDK_ROOT/cmdline-tools/latest/bin/avdmanager create avd -n test_emulator -k "system-images;android-35;google_apis;x86_64" --force
echo "Starting emulator"
$ANDROID_SDK_ROOT/emulator/emulator -avd test_emulator -no-audio -no-boot-anim -no-window &
$ANDROID_SDK_ROOT/emulator/emulator -avd test_emulator -no-audio -no-boot-anim -no-window -no-snapshot &
adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed) ]]; do sleep 1; done; input keyevent 82'
- name: Generate gradlew file with flutter build
working-directory: ${{ matrix.working_directory }}
Expand All @@ -100,14 +116,15 @@ jobs:
retention-days: 5

ios:
name: Run iOS Integration Tests
if: contains(github.base_ref, 'main')
timeout-minutes: 90
strategy:
matrix:
patrol_cli_version: [2.7.0]
working_directory: ["example"]
runs-on:
labels: macos-13-large
labels: macos-latest-xlarge
env:
MAPS_API_KEY: ${{ secrets.ACTIONS_API_KEY }}
steps:
Expand All @@ -117,39 +134,67 @@ jobs:
echo "MAPS_API_KEY is not available or empty."
exit 1
- uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b
name: Checkout code
- uses: subosito/flutter-action@44ac965b96f18d999802d4b807e3256d5a3f9fa1
name: Setup flutter
with:
flutter-version: "3.22.x"
channel: "stable"
cache: true
- name: Cache build
uses: actions/cache@v4
with:
path: example/build
key: ${{ runner.os }}-example-build-${{ github.job }}-${{ github.run_number }}
restore-keys: |
${{ runner.os }}-example-build-
- uses: actions/cache@v4
name: Cache podfiles
with:
path: "**/Pods"
key: ${{ runner.os }}-pods-${{ hashFiles('**/*.podspec') }}
restore-keys: |
${{ runner.os }}-pods-
- name: Select XCode 15.1
run: sudo xcode-select -s '/Applications/Xcode_15.1.app/Contents/Developer'
- name: Select XCode 16.0
run: sudo xcode-select -s '/Applications/Xcode_16.app/Contents/Developer'
- name: Start iOS simulator
run: |
RESULT=0
while [[ $RESULT == 0 ]]; do
xcrun simctl delete "Flutter-iPhone" || RESULT=1
if [ $RESULT == 0 ]; then
echo -e "Deleted Flutter-iPhone"
fi
done
xcrun simctl create "Flutter-iPhone" "com.apple.CoreSimulator.SimDeviceType.iPhone-14-Pro" "com.apple.CoreSimulator.SimRuntime.iOS-17-2" | xargs xcrun simctl boot
xcrun simctl list
SIMULATOR_NAME="iPhone 16 Pro"
# Find the UUID of the existing simulator by name
DEVICE_ID=$(xcrun simctl list devices | grep "$SIMULATOR_NAME (" | grep -Eo "\([A-F0-9-]+\)" | head -n 1 | tr -d "()")
if [ -z "$DEVICE_ID" ]; then
echo "Simulator $SIMULATOR_NAME not found."
exit 1
else
echo "Found existing simulator: $SIMULATOR_NAME ($DEVICE_ID)"
echo "Erasing the simulator to ensure a clean state..."
xcrun simctl erase "$DEVICE_ID"
fi
echo "Booting the simulator..."
xcrun simctl boot "$DEVICE_ID"
# Save DEVICE_ID for later use
echo "DEVICE_ID=$DEVICE_ID" >> $GITHUB_ENV
- uses: actions/cache@v4
name: Cache pub global packages
with:
path: ~/.pub-cache
key: ${{ runner.os }}-pub-cache-${{ matrix.patrol_cli_version }}
- name: Install patrol_cli
run: flutter pub global activate patrol_cli ${{ matrix.patrol_cli_version }}
- name: Run flutter pub get
run: flutter pub get
- name: Make sure the simulator is booted
run: |
xcrun simctl bootstatus "$DEVICE_ID" || exit 1
- name: Run Integration tests
id: tests_step
working-directory: ${{ matrix.working_directory }}
run: |
patrol test --dart-define=MAPS_API_KEY="$MAPS_API_KEY" --verbose -d 'Flutter-iPhone'
patrol test --dart-define=MAPS_API_KEY="$MAPS_API_KEY" --verbose -d "$DEVICE_ID"
- name: Upload test report
uses: actions/upload-artifact@v4
if: ${{ always() }}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/licence-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ jobs:
timeout-minutes: 30
steps:
- uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b
name: Checkout code
- uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753
with:
go-version: "^1.13.1"
Expand Down
Loading

0 comments on commit eca1c12

Please sign in to comment.