Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate Android integration tests into CI pipeline #230

Merged
merged 64 commits into from
Feb 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
7c3cfb6
Integrate Android integration tests into CI pipeline
nilsreichardt May 17, 2022
d116dcf
Put test command into one line
nilsreichardt May 17, 2022
3a6a812
Merge branch 'main' into add-android-integration-test-ci
nilsreichardt May 17, 2022
57a30a6
Merge branch 'main' into add-android-integration-test-ci
nilsreichardt May 17, 2022
7e0a4fc
Use `subosito/flutter-action@main`
nilsreichardt May 18, 2022
047a315
Merge branch 'add-android-integration-test-ci' of https://github.com/…
nilsreichardt May 18, 2022
af8c261
Merge branch 'main' into add-android-integration-test-ci
nilsreichardt May 18, 2022
ed61912
Add better comment
nilsreichardt May 18, 2022
7b85000
Try `google_atd`
nilsreichardt Jun 13, 2022
ebafab1
Merge remote-tracking branch 'origin/main' into add-android-integrati…
nilsreichardt Jun 13, 2022
8978f15
Use better configs for `google_atd`
nilsreichardt Jun 13, 2022
9be9acb
disable `request`
nilsreichardt Jun 13, 2022
948d58f
Merge branch 'main' into add-android-integration-test-ci
nilsreichardt Jun 13, 2022
f540213
Skip `requestPermission` for Android when running integration test
nilsreichardt Jun 13, 2022
bff3de4
Remove matrix
nilsreichardt Jun 13, 2022
fd034fc
Revert "Remove matrix"
nilsreichardt Jun 14, 2022
c329337
Remove matrix again
nilsreichardt Jun 14, 2022
169f0b0
Add comment
nilsreichardt Jun 14, 2022
743f338
Try matrix
nilsreichardt Jun 14, 2022
f103f2b
Try matrix 2
nilsreichardt Jun 14, 2022
5ac76cd
move matrix
nilsreichardt Jun 14, 2022
22531b0
decrease matrix
nilsreichardt Jun 14, 2022
08e63f2
Use `drain` in `homework_page_bloc.dart`
nilsreichardt Jun 14, 2022
d167dee
Remove matrix
nilsreichardt Jun 14, 2022
30a47e8
Skip if draft pr
nilsreichardt Jun 14, 2022
c3e3f6a
Retrigger skipped jobs
nilsreichardt Jun 14, 2022
2c61c38
Update .github/workflows/main.yml
nilsreichardt Jun 14, 2022
4432311
Update .github/workflows/main.yml
nilsreichardt Jun 14, 2022
8c3aee1
Update .github/workflows/main.yml
nilsreichardt Jun 14, 2022
8e1a2f3
Update .github/workflows/main.yml
nilsreichardt Jun 14, 2022
3130b52
Add comment why we need Java
nilsreichardt Jun 16, 2022
768dbd7
Merge branch 'add-android-integration-test-ci' of https://github.com/…
nilsreichardt Jun 16, 2022
edd99c0
Add comment for types
nilsreichardt Jun 16, 2022
60cb3aa
Just return nothing when the platform is not iOS in `_requestIOSPermi…
nilsreichardt Jun 16, 2022
1a75f41
Add comment
nilsreichardt Jun 16, 2022
dfd90c6
Remove `IS_INTEGRATION_TEST`
nilsreichardt Jun 16, 2022
cecf210
Fix iOS integration test
nilsreichardt Jun 16, 2022
33e6fca
Remove camera options
nilsreichardt Jun 16, 2022
16ad43f
fixing iOS integration test issue
nilsreichardt Jun 16, 2022
e056e1e
Add empty line
nilsreichardt Jun 16, 2022
b40a3f1
Use `emulator`
nilsreichardt Jun 16, 2022
4614b4a
Revert "Remove camera options"
nilsreichardt Jun 16, 2022
47c4dba
Adjust camera options
nilsreichardt Jun 16, 2022
f21e40b
Test flaky
nilsreichardt Jun 16, 2022
45231c8
Enable for draft PR
nilsreichardt Jun 16, 2022
20f7a3d
Using `flutter drive` command
nilsreichardt Jun 17, 2022
439f216
Try out `Galaxy Nexus`
nilsreichardt Jun 17, 2022
495c218
Merge remote-tracking branch 'origin/main' into add-android-integrati…
nilsreichardt Sep 30, 2022
0627046
Try different configurations
nilsreichardt Sep 30, 2022
73419a2
Merge branch 'main' into add-android-integration-test-ci
nilsreichardt Oct 1, 2022
751d4c4
Merge branch 'main' into add-android-integration-test-ci
nilsreichardt Feb 22, 2023
7d540fe
Try to use `flutter test`
nilsreichardt Feb 22, 2023
47d4bec
Add working dir
nilsreichardt Feb 22, 2023
a98418e
Increase timeout and add comments
nilsreichardt Feb 23, 2023
cfcad3c
Uncomment `api-level`
nilsreichardt Feb 23, 2023
afe26e2
Use `google_atd`
nilsreichardt Feb 23, 2023
b74ab90
Use correct target
nilsreichardt Feb 23, 2023
ff0d2d8
revert temp staff
nilsreichardt Feb 23, 2023
a95c991
Remove strategy
nilsreichardt Feb 23, 2023
817f919
Merge branch 'main' into add-android-integration-test-ci
nilsreichardt Feb 23, 2023
ebfb5c9
Change order of `emulator-options`
nilsreichardt Feb 24, 2023
8185a7d
Merge branch 'add-android-integration-test-ci' of https://github.com/…
nilsreichardt Feb 24, 2023
c306e3e
Merge branch 'main' into add-android-integration-test-ci
nilsreichardt Feb 24, 2023
63d1030
Re-trigger CI
nilsreichardt Feb 24, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 92 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,98 @@ jobs:
# We ignore it when no files could be found because the test command
# could also be failed because of an unit test. In this case there
# would be no failed golden test to upload.
if-no-files-found: ignore
if-no-files-found: ignore

android-integration-test:
# Is recommended to run the job with a macOS machine to take advantage of
# hardware acceleration support provided by HAXM. See more details in the
# README.md of the Android emulator action:
# https://github.com/ReactiveCircus/android-emulator-runner#usage
runs-on: macos-latest
if: ${{ github.event.pull_request.draft == false }}
timeout-minutes: 60
steps:
- uses: actions/checkout@v3

# Java is needed for building the APK, see
# https://github.com/marketplace/actions/flutter-action.
- uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '11'
nilsreichardt marked this conversation as resolved.
Show resolved Hide resolved

- name: Set Flutter version from FVM config file to environment variables
uses: kuhnroyal/flutter-fvm-config-action@v1

- uses: subosito/flutter-action@main
with:
flutter-version: ${{ env.FLUTTER_VERSION }}
channel: ${{ env.FLUTTER_CHANNEL }}

# Building the Android app as workaround for the timeout problem with
# integration tests.
#
# We need to build the Android app first to hope that the build for the
# integration test needs less than 12 minutes. Currently, it's not
# possible to increase the timeout for integration tests:
# https://github.com/flutter/flutter/issues/105913.
#
# Using `flutter drive` as workaround is not an option because it's super
# flaky in terms of stability. With `flutter drive` ~ 30% the Android
# Emulator have difficulties to start properly.
- name: Build Android App
working-directory: ./app
env:
USER_1_EMAIL: ${{ secrets.INTEGRATION_TEST_USER_1_EMAIL }}
USER_1_PASSWORD: ${{ secrets.INTEGRATION_TEST_USER_1_PASSWORD }}
run: flutter build apk --target=integration_test/app_test.dart --flavor dev --dart-define USER_1_EMAIL=$USER_1_EMAIL --dart-define USER_1_PASSWORD=$USER_1_PASSWORD

- name: Run integration tests
uses: reactivecircus/android-emulator-runner@v2
env:
USER_1_EMAIL: ${{ secrets.INTEGRATION_TEST_USER_1_EMAIL }}
USER_1_PASSWORD: ${{ secrets.INTEGRATION_TEST_USER_1_PASSWORD }}
with:
# When you are going to change something here (like a different
# target, arch, profile, channel, etc.), please check if these
# configurations are stable.
#
# You can do this by running this workflow multiple times. Use a
# matrix to run multiple tests in parallel (matrix needs to be copied
# to above the "with"):
# strategy:
# fail-fast: false
# matrix:
# test1: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
# test2: [1, 2, 3]
api-level: 30
target: google_apis
arch: x86_64
profile: Nexus 5X
channel: canary
# We use some emulator options for the following reasons:
# * "-no-snapshot": Disables the quick boot feature. Therefore, the
# emulator does not load or save the emulator state. We want to have
# * "-no-window": Disables the graphical windows, so no display is
# required.
# a fresh testing environment for every test run.
# * "-no-boot-anim": Disables the boot animation for faster booting.
# * "-camera-back virtualscene": Shows this virtual room when opening
# the back camera where you can walk. Default option for emulators
# created by Android Studio. We use this so we have the same
# environment locally as when using this action. Is needed when
# testing things with the camera. It's also possible to inject
# images into the virtual scene to test things like qr code scanner.
# * "-camera-front": Shows this green monster when opening the front
# camera. Default option for emulators created by Android Studio. We
# use this so we have the same environment locally as when using
# this action. Is needed when testing things with camera.
emulator-options: -no-snapshot -no-window -no-boot-anim -camera-back virtualscene -camera-front emulated
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be helpful to know why these emulator-options are used. You could also put some together and explain only their general purpose since one can probably google the exact description.

-no-snapshot -no-window -no-boot-anim -> for faster startup and execution (I guess?)
-camera-back virtualscene -> TODO
-camera-front emulated -> TODO

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will add comments later 👍

working-directory: ./app
# We can not use a multiline command because the
# "android-emulator-runner" action doesn't support it. It just takes every
# line as separate command.
script: flutter test integration_test --flavor dev --dart-define USER_1_EMAIL=$USER_1_EMAIL --dart-define USER_1_PASSWORD=$USER_1_PASSWORD

ios-integration-test:
# It seems so that our integration tests are not working `macos-12`. The
Expand Down
9 changes: 8 additions & 1 deletion app/lib/blocs/homework/homework_page_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,14 @@ class HomeworkPageBloc extends BlocBase {

/// Take care of closing streams.
@override
void dispose() {
Future<void> dispose() async {
await Future.wait([
_homeworkNotDoneSubject.drain(),
_homeworkDoneSubject.drain(),
_errorsSubject.drain(),
_homeworkListSubject.drain(),
]);
Jonas-Sander marked this conversation as resolved.
Show resolved Hide resolved

_homeworkNotDoneSubject.close();
_homeworkDoneSubject.close();
_toggleIsHomeworkDoneToController.close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import 'package:sharezone/notifications/widgets/error_dialog.dart';
import 'package:sharezone/notifications/widgets/in_app_notification.dart';
import 'package:sharezone/onboarding/group_onboarding/logic/signed_up_bloc.dart';
import 'package:sharezone/util/navigation_service.dart';
import 'package:sharezone_utils/platform.dart';

import 'action_requests/action_requests.dart';

Expand Down Expand Up @@ -125,7 +126,18 @@ class FirebaseMessagingCallbackConfigurator {
}
}

/// Prompts the native iOS permissions dialog to ask the user if we are allowed
/// to send push notifications.
///
/// Does nothing if the platform is not iOS.
Future<void> _requestIOSPermission(BuildContext context) async {
if (!PlatformCheck.isIOS) {
// We are only using push notifications for iOS and Android. Android does
// not required to get the permission from the user. Therefore, we can skip
// this for Android devices.
return;
}

final signUpBloc = BlocProvider.of<SignUpBloc>(context);
final signedUp = await signUpBloc.signedUp.first;

Expand Down