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

Conversation

nilsreichardt
Copy link
Member

@nilsreichardt nilsreichardt commented May 17, 2022

Closes #176

@github-actions
Copy link

github-actions bot commented May 17, 2022

Visit the preview URL for this PR (updated for commit 73419a2):

https://sharezone-test--pr230-add-android-integrat-20ba6kx5.web.app

(expires Sat, 08 Oct 2022 23:13:54 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Copy link
Collaborator

@Jonas-Sander Jonas-Sander left a comment

Choose a reason for hiding this comment

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

See above.

Maybe also add a comment that we might chache the AVD image to make it start up faster? (See emulator-runner docs)?

.github/workflows/main.yml Outdated Show resolved Hide resolved
Comment on lines 110 to 125
- 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:
api-level: ${{ matrix.api-level }}
target: ${{ matrix.target }}
arch: ${{ matrix.arch }}
profile: pixel_3a
emulator-options: -no-snapshot -no-window -no-boot-anim -camera-back virtualscene -camera-front emulated
working-directory: ./app
# We can not use a multiline command because the
# "android-emulator-runner" 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
Copy link
Collaborator

Choose a reason for hiding this comment

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

Kinda feel like we should put this into our Sharezone CLI in the future - this would also help to run integration tests locally.
We might even automatically retrieve the secrets inside the script (or at least make it nicer by reading from an .env or sth)

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, we can integrate this later in the CLI 👍 But I would like to do a rework of the CLI first and do things like better styling when printing to the console and writing much more tests.

nilsreichardt added a commit that referenced this pull request May 17, 2022
## Description
For now, it was required to have a `key.properties` file with our code signing credentials when you tried to build for Android (even when running in debug mode where no code signing was done).

We now check if a `key.properties` is present. If no, don't try to code sign the android app, which is the expected behavior because you need code signing only for publishing.

This PR unblocks #230 

Closes #234
@github-actions github-actions bot added the ci/cd label May 17, 2022
nilsreichardt added a commit that referenced this pull request May 17, 2022
## Description
This should fix #237. I ran a Codemagic build and this worked 👍 

This unblocks:
* #230
* #235
@nilsreichardt
Copy link
Member Author

Tests are failing because of:


══╡ EXCEPTION CAUGHT BY FLUTTER TEST FRAMEWORK ╞════════════════════════════════════════════════════
The following MissingPluginException was thrown running a test:
MissingPluginException(No implementation found for method Messaging#requestPermission on channel
plugins.flutter.io/firebase_messaging)

When the exception was thrown, this was the stack:
#0      convertPlatformException (package:firebase_messaging_platform_interface/src/method_channel/utils/exception.dart:13:5)
#1      MethodChannelFirebaseMessaging.requestPermission (package:firebase_messaging_platform_interface/src/method_channel/method_channel_messaging.dart:286:13)
<asynchronous suspension>
<asynchronous suspension>
(elided one frame from package:stack_trace)

The test description was:
  User should be able to sign in
════════════════════════════════════════════════════════════════════════════════════════════════════

Hmm, it seems so that we need to upgrade Firebase Messaging and Firebase Core to unblock this PR: https://stackoverflow.com/questions/69880191/missingpluginexceptionno-implementation-found-for-method-messagingrequestpermi

@nilsreichardt nilsreichardt marked this pull request as draft June 14, 2022 10:39
@Jonas-Sander
Copy link
Collaborator

Just want to say that some android actions fail but because of an firebase auth error, e.g. https://github.com/SharezoneApp/sharezone-app/actions/runs/3160777863/jobs/5145617181

@github-actions
Copy link

github-actions bot commented Feb 22, 2023

Visit the preview URL for this PR (updated for commit 63d1030):

https://sharezone-test--pr230-add-android-integrat-or4aeld9.web.app

(expires Fri, 03 Mar 2023 10:03:55 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: 4cb3ae61e1e018abfd9841fd3239f5b49ccc034b

@nilsreichardt
Copy link
Member Author

Using flutter test instead of flutter drive seams to fix the problem with the Android Emulator. Instead of 30% - 40% failure rate we now have only ~6%. I'm testing the google_atd. When there is everything fine, we can merge this :)

@nilsreichardt nilsreichardt marked this pull request as ready for review February 23, 2023 22:58
@Sharezone-Admin
Copy link
Member

Sharezone-Admin commented Feb 23, 2023

⬇️ Generated builds by Codemagic for commit 63d1030 ⬇️

Note: Only Sharezone team members are able to install the iOS app.

iOS Android
image
Download link
image
Download link

Copy link
Collaborator

@Jonas-Sander Jonas-Sander left a comment

Choose a reason for hiding this comment

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

See nits above.

Comment on lines 226 to 231
# We use the `flutter drive` instead of the `flutter test` command
# because the test command times out after 12 minutes. But building the
# app takes more than 12 minutes... It seems so that there is no way to
# set the timeout (the --timeout argument has not effect). Tracking
# issue: https://github.com/flutter/flutter/issues/105913
script: flutter test integration_test --flavor dev --dart-define USER_1_EMAIL=$USER_1_EMAIL --dart-define USER_1_PASSWORD=$USER_1_PASSWORD
Copy link
Collaborator

Choose a reason for hiding this comment

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

The comment is out-of-date (you're using flutter test here, not flutter drive)

Copy link
Member Author

Choose a reason for hiding this comment

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

ah, thanks

Comment on lines 203 to 220
# We use some emulator options for the following reasons:
# * "-no-boot-anim": Disables the boot animation for faster booting.
# * "-no-window": Disables the graphical windows, so no display is
# required.
# * "-no-snapshot": Disables the quick boot feature. Therefore, the
# emulator does not load or save the emulator state. We want to have
# a fresh testing environment for every test run.
# * "-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.

Teeny tiny nit: Could you use the same order for the emulator-options: flags and for the comment above explaining them?

Copy link
Member Author

Choose a reason for hiding this comment

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

Changed

@nilsreichardt nilsreichardt enabled auto-merge (squash) February 24, 2023 06:50
@nilsreichardt nilsreichardt merged commit 2be7dfb into main Feb 24, 2023
@nilsreichardt nilsreichardt deleted the add-android-integration-test-ci branch February 24, 2023 10:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Run integration tests for Android in our CI
3 participants