android-emulator-runner
android-emulator-runner copied to clipboard
[Self-hosted] When running emulator, fails because dir for config.ini does not exist.
When I try to run this action on self-hosted runner, it fails because of dir fails.
Action try to create config.ini to /github/home/.android/avd/test.avd/, but directory is not there.
So, simply I created that directory by mkdir -p /github/home/.android/avd/test.avd/, but it seems not right thing.
Can u give me any hint about right way to do this?
I haven't used self hosted runner myself so I'm not sure what needs to be setup for this action. I know some people were able to use the action with self-hosted runner but it's possible that recent updates had broke something which I'm not able to test on CI.
Can you share some logs?
bin/sh -c \echo no | avdmanager create avd --force -n test --abi 'default/x86_64' --package 'system-images;android-30;default;x86_64'
Picked up _JAVA_OPTIONS: -Xmx3g
Loading local repository...
[========= ] 25% Loading local repository...
[========= ] 25% Fetch remote repository...
[=======================================] 100% Fetch remote repository...
sh to create a custom hardware profile? [no] [command]/bin/sh -c \printf 'hw.cpu.ncore=2
' >> /github/home/.android/avd/test.avd/config.ini
/bin/sh: 1: cannot create /github/home/.android/avd/test.avd/config.ini: Directory nonexistent
/opt/android/sdk/platform-tools/adb -s emulator-5554 emu kill
error: could not connect to TCP port 5554: Address family not supported by protocol
The process '/opt/android/sdk/platform-tools/adb' failed with exit code 1
Error: The process '/bin/sh' failed with exit code 2
@ychescale9 This is the log, I didn't check public github action, but I think root directory seems different, because in case of my docker, home directory was /home/circleci because I use docker circleci/android:api-30.
And I found that https://github.com/ReactiveCircus/android-emulator-runner/blob/d1f5d2c0171bb5a00d3d7b3669161076fe9545f3/lib/sdk-installer.js#L61
Shows export variable ANDROID_AVD_HOME from process.env.HOME. I think it can be a hint, but I don't know how can I debug this github action at the local.
So I also ran into this and have worked out the problem/a workaround.
The thing is that github actions sets $HOME for you (even if you set it differently in a container) to /github/home.
It ALSO deletes everything in this folder (even if you've pre-populated it in a container). However, it doesn't remake any folders.
What you need to do then is to make the directory again i.e. mkdir -p /github/home/.android/avd
Ideally this action would take this into account in some way but this works for now!
@rob-mur Very interesting find! Thanks for this. I'll add some logging and see if there's anything we can do to better support this. If possible, can you please attach more of your .yml file?
Sure thing, see below:
Workflow
name: CI/CD
on:
push:
branches:
- main
jobs:
commit:
runs-on: self-hosted
container:
image: rmurphy599/strength_assistant:latest
steps:
- name: Checkout the code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Read Version
id: read-version
uses: NiklasLehnfeld/flutter-version-number-action@main
with:
file-path: pubspec.yaml
- name: Get Latest release version
id: previoustag
uses: "WyriHaximus/github-action-get-previous-tag@v1"
- name: Check version bump
uses: nick-invision/assert-action@v1
with:
expected: ${{ steps.previoustag.outputs.tag }}
actual: ${{ steps.read-version.outputs.version-number }}
comparison: notEqual
- name: Restore packages
run: flutter pub get
- name: Check formatting
run: flutter format --set-exit-if-changed .
- name: Check errors
run: flutter analyze .
- name: Rust Checks
run: cargo fmt --check && cargo clippy && cargo test
working-directory: ./lib/domain
outputs:
tag: ${{ steps.read-version.outputs.version-number }}
integration:
runs-on: self-hosted
container:
image: rmurphy599/strength_assistant:latest
options: --gpus all --device /dev/kvm
needs: commit
steps:
- name: Checkout the code
uses: actions/checkout@v3
- name: Create directory for AVD
run: mkdir -p /github/home/.android/avd
- name: Restore packages
run: flutter pub get
- name: Execute tests
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 29
arch: x86_64
profile: pixel
disable-linux-hw-accel: false
script: |
flutter run integration_test/main_test.dart --host-vmservice-port 9753 --disable-service-auth-codes --dart-define CONVENIENT_TEST_MANAGER_HOST=10.0.2.2 --dart-define CONVENIENT_TEST_APP_CODE_DIR=. --dart-define CONVENIENT_TEST_CI_MODE=true &
./packages/convenient_test_manager_dart > /dev/null
android:
needs: integration
runs-on: self-hosted
container:
image: rmurphy599/strength_assistant:latest
steps:
- name: Checkout the code
uses: actions/checkout@v3
- name: Restore packages
run: flutter pub get
- name: Create the Keystore
env:
KEYSTORE_BASE64: ${{ secrets.KEYSTORE_BASE64 }}
run: |
# import keystore from secrets
echo $KEYSTORE_BASE64 | base64 -d > $RUNNER_TEMP/my_production.keystore
- name: Build Android App Bundle
run: flutter build appbundle --release
- name: Sign Android App Bundle
run: jarsigner -keystore $RUNNER_TEMP/my_production.keystore -storepass ${{ secrets.KEYSTORE_PASSWORD }} -keypass ${{ secrets.KEYSTORE_PASSWORD_ALIAS }} -sigalg SHA256withRSA -digestalg SHA-256 -signedjar build/app/outputs/bundle/release/app-release-signed.aab build/app/outputs/bundle/release/*.aab keystore
- name: Publish Android Artifact
uses: actions/upload-artifact@v1
with:
name: android-build
path: build/app/outputs/bundle/release/app-release-signed.aab
web:
needs: integration
runs-on: self-hosted
container:
image: rmurphy599/strength_assistant:latest
env:
RUSTFLAGS: "-C target-feature=+atomics,+bulk-memory,+mutable-globals"
steps:
- name: Checkout the code
uses: actions/checkout@v3
- name: Restore packages
run: flutter pub get
- name: Build wasm
run: |
wasm-pack build lib/domain \
-t no-modules \
-d ../../web/pkg \
--no-typescript -- \
-Z build-std=std,panic_abort
- name: Build flutter
run: flutter build web
- name: Publish Web Artifcat
uses: actions/upload-artifact@v1
with:
name: web-build
path: build/web/
deploy:
needs: [commit, android, web]
runs-on: self-hosted
container:
image: rmurphy599/strength_assistant:latest
steps:
- name: Download Artifacts
uses: actions/download-artifact@v3
- name: Zip web build
uses: vimtor/action-zip@v1
with:
files: web-build/
dest: web.zip
- name: Publish Release on Github
uses: ncipollo/release-action@v1
with:
artifacts: android-build/app-release-signed.aab, web.zip
token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ needs.commit.outputs.tag }}
- name: Deploy Web
uses: Azure/static-web-apps-deploy@1a947af9992250f3bc2e68ad0754c0b0c11566c9
with:
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN }}
repo_token: ${{ secrets.GITHUB_TOKEN }}
action: "upload"
app_location: "web-build/"
output_location: ""
skip_build: true
- name: Publish Release to internal test track
uses: r0adkll/[email protected]
with:
serviceAccountJsonPlainText: ${{ secrets.SERVICE_ACCOUNT_JSON }}
packageName: com.jimmy_solutions.strength_assistant
releaseFiles: android-build/app-release-signed.aab
track: internal
status: completed
changesNotSentForReview: true
Hey @rob-mur , I'm going to close this out since there is a workaround -- but if there are any negative consequences of this, we can reopen because there will be more reasoning to put in a PR to address this.
However, for now any PRs are welcome if you want to try to solve this more gracefully.