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

ci emulator: Cache AVD emulator setup to speed up repeated jobs #202

Merged
merged 1 commit into from
Nov 24, 2021

Conversation

MarijnS95
Copy link
Member

Our CI currently builds and runs the emulator three times, once for every possible APK source. It is possible to speed up this setup by only building the image once as per 1 and storing it using GitHub's cache system. This approach was suggested in #133 (comment).

CC @Gordon-F for the suggestion!

arch: x86_64
# the `googleapis` emulator target is considerably slower on CI.
target: default
profile: Nexus 6
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: true
force-avd-creation: false
Copy link
Member Author

Choose a reason for hiding this comment

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

@Gordon-F the example in their readme also sets force-avd-creation to false. That seems like a sensible default so perhaps we shouldn't even set this at all. I don't mind it not creating an avd when it already exists, though that is extremely unlikely/impossible unless GH actions environment starts to ship with one...

@@ -94,31 +94,63 @@ jobs:
strategy:
matrix:
source_os: [ubuntu-latest, windows-latest, local]
env:
api-level: 29
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it will be great to make arch, profile and target part of env.

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 didn't expect these to change as often as the api-level (which is also at least used in 3 places, the rest is only dereferenced twice), but it's indeed useful to deduplicate at least emulator-options which is a rather "complicated" string.

I really, really with GH starts supporting YAML anchors, it would have made this 100x better:
https://github.com/MarijnS95/android-ndk-rs/actions/runs/1494051637/workflow

Copy link
Contributor

@Gordon-F Gordon-F Nov 23, 2021

Choose a reason for hiding this comment

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

I didn't expect these to change as often as the api-level

Maybe we should make api-level part of matrix? At least min_sdk_version and target_sdk_version.

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 guess now that we have this cache it's probably worth running it that many times?

Copy link
Contributor

Choose a reason for hiding this comment

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

We can try :) But, probably, after we make sure that the CI is stable enough.

Copy link
Member Author

Choose a reason for hiding this comment

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

However, we'll probably need to come up with a more interesting test/example too. All these versions do is limit API available at compile vs build time, and that's really only interesting if that API is actually used.

Otherwise the only thing we're checking is if the resulting APK is still compatible.

Copy link
Member Author

Choose a reason for hiding this comment

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

Let's land such a change after the CI is stable like this (and it looks like it is already) - note that the examples default to min_sdk_version=16.

Our CI currently builds and runs the emulator three times, once for
every possible APK source.  It is possible to speed up this setup by
only building the image once as per [1] and storing it using GitHub's
cache system.

[1]: https://github.com/ReactiveCircus/android-emulator-runner#usage
Copy link
Contributor

@msiglreith msiglreith left a comment

Choose a reason for hiding this comment

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

nice!

@MarijnS95 MarijnS95 merged commit 317d711 into rust-mobile:master Nov 24, 2021
@MarijnS95 MarijnS95 deleted the avd-cache branch November 24, 2021 19:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants