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 146417f
Show file tree
Hide file tree
Showing 9 changed files with 110 additions and 95 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
test-dart:
timeout-minutes: 45
runs-on:
labels: ubuntu-latest-8core
labels: ubuntu-latest
steps:
- uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b
- uses: actions/setup-java@v4
Expand All @@ -49,7 +49,7 @@ jobs:
test-android:
timeout-minutes: 45
runs-on:
labels: ubuntu-latest-8core
labels: ubuntu-latest
steps:
- uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b
- uses: actions/setup-java@v4
Expand Down Expand Up @@ -102,7 +102,7 @@ jobs:
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:
Expand Down
46 changes: 28 additions & 18 deletions .github/workflows/integration_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ concurrency:
jobs:
android:
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 Down Expand Up @@ -77,13 +77,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 @@ -107,7 +107,7 @@ jobs:
patrol_cli_version: [2.7.0]
working_directory: ["example"]
runs-on:
labels: macos-13-large
labels: macos-14-large
env:
MAPS_API_KEY: ${{ secrets.ACTIONS_API_KEY }}
steps:
Expand All @@ -128,28 +128,38 @@ jobs:
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"
- 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 "iPhone 16 Pro" || 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 'iPhone 16 Pro'
- name: Upload test report
uses: actions/upload-artifact@v4
if: ${{ always() }}
Expand Down
6 changes: 3 additions & 3 deletions example/integration_test/t01_initialization_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,10 @@ void main() {
final Destinations destinations = Destinations(
waypoints: <NavigationWaypoint>[
NavigationWaypoint.withLatLngTarget(
title: 'Grace Cathedral',
title: 'California St & Taylor St',
target: const LatLng(
latitude: 37.791957,
longitude: -122.412529,
latitude: 37.7917884,
longitude: -122.413838,
)),
],
displayOptions:
Expand Down
16 changes: 8 additions & 8 deletions example/integration_test/t03_navigation_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ void main() {
await startNavigationWithoutDestination($);

/// Specify tolerance and navigation end coordinates.
const double tolerance = 0.0005;
const double tolerance = 0.05;
const double endLat = 68.60338455021943, endLng = 23.548804200724454;

/// Simulate location.
Expand Down Expand Up @@ -541,10 +541,10 @@ void main() {
final Destinations destinations = Destinations(
waypoints: <NavigationWaypoint>[
NavigationWaypoint.withLatLngTarget(
title: 'Grace Cathedral',
title: 'California St & Taylor St',
target: const LatLng(
latitude: 37.791957,
longitude: -122.412529,
latitude: 37.7917884,
longitude: -122.413838,
),
),
],
Expand Down Expand Up @@ -591,10 +591,10 @@ void main() {
/// Create a waypoint.
final List<NavigationWaypoint> waypoint = <NavigationWaypoint>[
NavigationWaypoint.withLatLngTarget(
title: 'Grace Cathedral',
title: 'California St & Taylor St',
target: const LatLng(
latitude: 37.791957,
longitude: -122.412529,
latitude: 37.7917884,
longitude: -122.413838,
),
),
];
Expand Down Expand Up @@ -715,7 +715,7 @@ void main() {
expect(beginRouteSegments.length, greaterThan(0));

/// The current route segment.
expect(beginCurrentSegment, isNotNull);
expect(beginCurrentSegment, isNotNull, reason: 'Current segment is null.');

/// Start simulation.
await GoogleMapsNavigator.simulator
Expand Down
8 changes: 5 additions & 3 deletions example/integration_test/t04_navigation_ui_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ void main() {
final Destinations destinations = Destinations(
waypoints: <NavigationWaypoint>[
NavigationWaypoint.withLatLngTarget(
title: 'Grace Cathedral',
title: 'California St & Taylor St',
target: const LatLng(
latitude: 37.791957,
longitude: -122.412529,
latitude: 37.7917884,
longitude: -122.413838,
),
),
],
Expand Down Expand Up @@ -172,5 +172,7 @@ void main() {
final bool isEnabled = await viewController.isRecenterButtonEnabled();
expect(isEnabled, result);
}

await GoogleMapsNavigator.cleanup();
});
}
7 changes: 4 additions & 3 deletions example/integration_test/t05_camera_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -392,11 +392,12 @@ void main() {

// Test stoppedFollowingMyLocation event is received on Android.
if (Platform.isAndroid) {
const double tolerance = 0.01;
expect(followingMyLocationActive, false);
expect(stoppedFollowingMyLocationPosition!.target.latitude,
closeTo(oldTarget.latitude, 0.003));
closeTo(oldTarget.latitude, tolerance));
expect(stoppedFollowingMyLocationPosition!.target.longitude,
closeTo(oldTarget.longitude, 0.003));
closeTo(oldTarget.longitude, tolerance));
}

// 8. Test cameraMoveStarted, cameraMove and cameraIdle events.
Expand Down Expand Up @@ -430,7 +431,7 @@ void main() {

// Test that cameraMoveEvent position coordinates are between the start and the end coordinates
// and that the other values match within tolerance.
const double tolerance = 0.003;
const double tolerance = 0.01;
expect(cameraMovePosition.target.latitude,
greaterThanOrEqualTo(camera.target.latitude - tolerance));
expect(cameraMovePosition.target.latitude,
Expand Down
Loading

0 comments on commit 146417f

Please sign in to comment.