Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Malinskiy/action-android
Collection of Android-related GitHub Actions
https://github.com/Malinskiy/action-android
action-android actions android android-emulators android-sdk ci emulator emulator-start github github-actions githubactions install sdk testing
Last synced: about 1 month ago
JSON representation
Collection of Android-related GitHub Actions
- Host: GitHub
- URL: https://github.com/Malinskiy/action-android
- Owner: Malinskiy
- License: mit
- Created: 2019-09-29T10:04:19.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2024-05-29T08:44:57.000Z (3 months ago)
- Last Synced: 2024-05-29T21:12:30.193Z (3 months ago)
- Topics: action-android, actions, android, android-emulators, android-sdk, ci, emulator, emulator-start, github, github-actions, githubactions, install, sdk, testing
- Language: TypeScript
- Size: 7.36 MB
- Stars: 178
- Watchers: 9
- Forks: 22
- Open Issues: 14
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
- awesome-actions - GitHub Actions for Android
- fucking-awesome-actions - GitHub Actions for Android
- awesome-workflows - GitHub Actions for Android
- awesome-list - Malinskiy/action-android - Collection of Android-related GitHub Actions (TypeScript)
README
# action-android
This is a collection of GitHub Actions for Android development
# Requirements
Tested with **macOS-12** and **ubuntu-latest** runner images. It might work using other runners (including self-hosted ones) but there is no support for them.
## Android SDK
This repo provides an action for installing the Android SDK on the build agent. It will override whatever setup is
already there. You might want to do this since default GitHub Actions environments are now missing `sdkmanager` binary
so they're immutable.### Usage
```yaml
steps:
- uses: actions/checkout@v1# Download & install the Android SDK.
- uses: malinskiy/action-android/install-sdk@release/0.1.6# Set up platform tools like adb.
- run: sdkmanager platform-tools# Start ADB (and verify that pathing is working correctly).
- run: adb devices# Verify $ANDROID_HOME is properly set for later Gradle commands.
- run: echo $ANDROID_HOME
```## Building your code
There is an official [action](https://github.com/actions/setup-java) for Java setup. For execution using Gradle
I suggest to use `./gradlew` to minimize the dependency on environment setup.## Testing against Android Emulator
`action-android/emulator-run-cmd` provide an action which installs the emulator packages, starts the emulator and waits
until it's booted. After this it will execute the provided cmd and stop the running emulator.It's imperative(!) to use `runs-on: ubuntu-latest` with KVM enabled or `runs-on: macOS-12` if you want to have hardware acceleration for your emulator.
### Enabling KVM for ubunut-latest
```
- name: Enable KVM
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
```### Usage
```yaml
steps:
- uses: actions/checkout@v1
- uses: malinskiy/action-android/emulator-run-cmd@release/0.1.6
with:
cmd: ./gradlew integrationTest
api: 25
tag: default
abi: x86
```- `cmd` is the shell command to execute while the emulator is booted
- `api` is the API version of emulator
- `tag` is either the **default** or **google_apis**. Use google_apis for emulator with google store
- `abi` is the abi of the emulator. x86 is the fastest one
- `hardwareProfile` is the hardware profile of the emulator. Check the `avdmanager list` for supported value. I advise to use string names instead of ids since those might change between sdk updates
- `cmdOptions` is value which you can use to pass additional arguments to the emulator start command. By default this is `-no-snapshot-save -noaudio -no-boot-anim`
- `disableAnimations` to disable animations using the system preferences. `false` by default. Keep in mind that applications might not respect system settings and these might have no effect at all
- `bootTimeout` is the emulator boot timeout (default is 600 seconds = 10 minutes)
- `verbose` if you want to enable additional logging for this action### Artifacts
The `emulator-run-cmd` action will generate an `artifacts/logcat.log` artifact that you can use in your builds to investigate issues. For example the next snippet will save the artifact in case the previous steps had failures (your tests failed and you need these logs for investigation).```yaml
- name: Save logcat output
uses: actions/upload-artifact@master
if: failure()
with:
name: logcat
path: artifacts/logcat.log
```### Info about emulator-start and emulator-stop actions
Currently GitHub Actions do not support OS processes that outlive the specific step hence you can't really do a
workflow that starts the emulator and then execute your testing command in a separate step. This is the reason why
I've written the combined `emulator-run-cmd` action. If you have multiple commands to run in parallel to emulator I suggest to write a script and execute it via the cmd arg.# License
```
MIT LicenseCopyright (c) 2020 Anton Malinskiy
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
```## Android SDK
By using this action you're automatically accepting the relevant licenses of Android SDK. See the Android SDK for more details.