Compare commits

...

72 Commits

Author SHA1 Message Date
Yang 2196379783 Test API 23-30. 2020-10-30 20:52:34 +11:00
Yang 448508a511 don't fail fast. 2020-10-30 20:41:01 +11:00
Yang fd437876c6 Try API 23-29. 2020-10-30 20:34:44 +11:00
Yang 517fe314d7 WIP - Test sdcard. 2020-10-30 20:31:43 +11:00
Daniel Jette 4690ba2920 Add Shopify/android-testify to list of projects
Shopify/android-testify uses the Android Emulator Runner for GitHub Actions
2020-10-27 08:42:51 +11:00
Yang 15da0b2f14 Prepare for release 2.12.0. 2020-10-16 14:39:02 +11:00
Yang 53151f5236 Add support for using google_apis_playstore system images. 2020-10-16 14:32:01 +11:00
Adrián Nieto Rodríguez fd240e46a6 Fix README.md typo 2020-10-15 00:01:10 +11:00
Yang 04a32d7ac6 Prepare for release 2.11.1. 2020-10-08 12:20:45 +11:00
Yang 1eebfdbd84 Update npm packages. 2020-10-08 12:14:51 +11:00
dependabot[bot] 47cc04b42b Bump @actions/core from 1.2.4 to 1.2.6
Bumps [@actions/core](https://github.com/actions/toolkit/tree/HEAD/packages/core) from 1.2.4 to 1.2.6.
- [Release notes](https://github.com/actions/toolkit/releases)
- [Changelog](https://github.com/actions/toolkit/blob/main/packages/core/RELEASES.md)
- [Commits](https://github.com/actions/toolkit/commits/HEAD/packages/core)

Signed-off-by: dependabot[bot] <support@github.com>
2020-10-02 03:38:16 +10:00
Yang dd0984ca1b Update to gradle 6.7-rc-1 for test fixture. Build with Java 15 on CI. 2020-09-20 18:50:55 +10:00
Yang fef056dbdf Improve GitHub Actions Gradle cache. 2020-09-03 14:55:52 +10:00
Yang 31e4885c24 Add square/radiography to adopter list 2020-09-02 13:05:03 +10:00
Yang a59d5e6807 Add cashapp/copper to adapter list 2020-08-16 19:13:51 +10:00
Yang 8feb8a564a SDK Build tools 30.0.2. 2020-08-15 15:00:23 +10:00
Yang d677dca18c Update fixture dependencies. 2020-08-15 00:01:17 +10:00
Yang d23e781d9a Gradle 6.6. 2020-08-11 10:34:30 +10:00
Vinay Shenoy 29a8a60dbb Update README.md
We use this action for running instrumented tests in CI. Thanks for the great work!
2020-07-28 22:24:22 +10:00
Yang 327f6f1c1f Update packages. 2020-07-18 19:43:39 +10:00
Yang 1dc0441870 Build tools 30.0.1. 2020-07-09 19:49:16 +10:00
Yang fb3c06d709 Use fs for writing licence files. 2020-07-03 16:14:01 +10:00
Yang e22ecdedee Update cmdline-tools to 2.1. 2020-06-24 23:39:11 +10:00
Yang a72b5eb6c0 Prepare for release 2.11.0. 2020-06-20 19:52:48 +10:00
Yang b39f1a9f8b Support running multiple actions sequentially in a single job. 2020-06-20 19:48:18 +10:00
Yang a4d07e10d7 Add RxBinding to adopter list. 2020-06-19 14:46:44 +10:00
Yang 6f6ca5ebc6 Rename master branch to main. 2020-06-18 19:26:07 +10:00
Yang 9ef7536c4b Prepare for release 2.10.0. 2020-06-12 19:50:37 +10:00
Yang 8d0ce4c94b Support API 30 system images and add API 30 to workflow. Update build tools to 30.0.0. Update test projec’s compileSdk and targetSdk to API 30. 2020-06-12 19:44:21 +10:00
Yang fc17953a7f Prepare for release 2.9.0. 2020-05-29 23:10:13 +10:00
Yang d122d1159d Update test fixture dependencies. 2020-05-29 21:48:25 +10:00
Yang 736093576f SDK Command-line Tools 2.0. 2020-05-29 21:48:25 +10:00
Yang a06469d17c Add information on running on Linux to README.md. 2020-05-21 18:11:25 +10:00
Yang 3609b3300b Fix doc. 2020-05-10 01:07:23 +10:00
vgaidarji 9b15ac23ac Mention ci-matters repo in adopters list 2020-05-09 21:41:51 +10:00
Yang 4df9257dba Prepare for release 2.8.0. 2020-05-01 20:18:07 +10:00
Yang f5435af41b Add support for specifying a custom name used for creating AVD. 2020-05-01 20:11:25 +10:00
Yang fdd35a3667 Fix typo 2020-04-25 18:52:46 +10:00
Yang 2513ea5ecf Add list of projects using android-emulator-runner. 2020-04-25 18:17:11 +10:00
Yang c0431f2812 Bump kotlin and AGP for test fixture project. 2020-04-14 23:57:49 +10:00
Yang 33176ea112 Prepare for release 2.7.0. 2020-04-11 21:50:47 +10:00
Yang 8972f964c9 Security audit. 2020-04-11 21:48:08 +10:00
Yang 438dce7110 Support specifying versions of NDK and CMake to install. 2020-04-11 21:02:42 +10:00
Yang Chen 61dd774a5b Prepare for release 2.6.2. 2020-04-03 00:12:04 +11:00
Yang Chen 8c62a78107 Add gradle caching. 2020-04-02 23:43:06 +11:00
Yang Chen 0d53ec8e43 Use correct cli-tools binary for mac. 2020-04-02 22:56:56 +11:00
Yang Chen 730757f124 Remove API 28 from workflow. 2020-04-01 09:37:55 +11:00
Yang Chen 22965df722 Prepare for release 2.6.1. 2020-04-01 00:51:14 +11:00
Yang Chen 49a3d042e9 Fix sdk license issue with API 28+ system images on Linux. 2020-04-01 00:38:58 +11:00
Yang Chen 0d966550cf Prepare for release 2.6.0. 2020-03-28 14:59:20 +11:00
Yang Chen eb9e069f3f Update packages. 2020-03-28 14:10:50 +11:00
Yang Chen 0ac3f34493 Add information re. hardware acceleration for linux support. 2020-03-28 14:10:50 +11:00
Yang Chen 345ace6178 Support running on linux without hardware accleration. 2020-03-28 14:10:50 +11:00
Yang Chen 490f28e17c Gradle 6.3. 2020-03-25 23:23:07 +11:00
Yang Chen fc08a40bf0 Gradle 6.3-rc-4. 2020-03-25 23:23:07 +11:00
Yang Chen 75464a704b Update workflow to use Java 14. 2020-03-25 23:23:07 +11:00
Yang Chen de92fdaa03 Update npm packages. 2020-03-17 21:16:57 +11:00
dependabot[bot] 47063ae93b Bump acorn from 5.7.3 to 5.7.4
Bumps [acorn](https://github.com/acornjs/acorn) from 5.7.3 to 5.7.4.
- [Release notes](https://github.com/acornjs/acorn/releases)
- [Commits](https://github.com/acornjs/acorn/compare/5.7.3...5.7.4)

Signed-off-by: dependabot[bot] <support@github.com>
2020-03-17 20:55:34 +11:00
Yang Chen da846ad45b Prepare for release 2.5.0. 2020-03-05 14:54:33 +11:00
Yang Chen ede514c8c2 Add support for API 15-19 system images. 2020-03-05 14:50:59 +11:00
Yang Chen 4a949058e2 Use new cmdline-tools with support for running sdkmanager and avdmanager with Java 8+. 2020-03-05 14:34:19 +11:00
Yang Chen e1015a487b Update test-fixture dependencies. Drop minSdkVersion to 15. 2020-03-05 14:34:19 +11:00
Yang Chen 883b8114b1 Update to AGP 3.6.0 and Gradle 6.2.1 for test-fixture project. 2020-02-26 18:33:53 +11:00
Yang Chen aaa1121ed1 Prepare for release 2.4.0. 2020-02-15 18:51:35 +11:00
Yang Chen ff311e8a7d Add support for setting a custom working-directory. 2020-02-15 18:29:17 +11:00
Ricky Ng-Adam d0fa6c63f8 Fix typo 2020-02-15 18:08:40 +11:00
Yang Chen d3a226f97f Prepare for release 2.3.2. 2020-02-04 12:27:56 +11:00
Yang Chen 4082c705ad Fix escaped environment variables in script. 2020-02-04 12:25:35 +11:00
Yang Chen e53c6d9838 Prepare for release 2.3.1. 2020-01-31 11:47:03 +11:00
Yang Chen cb6efbb995 Update Gradle to 6.1.1 for test-fixture. 2020-01-31 11:43:15 +11:00
Yang Chen 97f77e3305 Build tools 29.0.3. 2020-01-31 11:43:15 +11:00
Yang Chen 128c6a83e1 Validate Gradle Wrapper. 2020-01-27 19:48:34 +11:00
23 changed files with 5730 additions and 2844 deletions
+64 -15
View File
@@ -3,45 +3,94 @@ on:
pull_request: pull_request:
push: push:
branches: branches:
- master # - main
- 'yc/*'
paths-ignore: paths-ignore:
- '**.md' - '**.md'
jobs: jobs:
test: test:
runs-on: macOS-latest # runs-on: ${{ matrix.os }}
timeout-minutes: 10 runs-on: macos-latest
env:
JAVA_TOOL_OPTIONS: -Xmx4g
timeout-minutes: 15
strategy: strategy:
fail-fast: false
matrix: matrix:
api-level: [21, 23, 29] # os: [macos-latest, ubuntu-latest]
api-level: [23, 24, 25, 26, 27, 28, 29, 30]
# target: [default, google_apis]
# exclude:
# - os: ubuntu-latest
# api-level: 23
# - os: ubuntu-latest
# api-level: 29
# - target: google_apis
# api-level: 16
# - target: google_apis
# api-level: 23
# - target: google_apis
# api-level: 29
# include:
# - os: macos-latest
# api-level: 30
# target: google_apis
# - os: macos-latest
# api-level: 24
# target: playstore
steps: steps:
- name: checkout - name: checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: validate gradle wrapper
uses: gradle/wrapper-validation-action@v1
- name: build, test and lint - name: build, test and lint
run: | run: |
npm install npm ci
npm run build npm run build
npm run lint npm run lint
npm test npm test
- name: Prepare test fixture - name: Java 15
run: cp -a ./test-fixture/* ./
- name: Java 13
uses: actions/setup-java@v1 uses: actions/setup-java@v1
with: with:
java-version: 13 java-version: 15
- uses: actions/cache@v2
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
- name: run action - name: run action
uses: ./ uses: ./
with: with:
api-level: ${{ matrix.api-level }} api-level: ${{ matrix.api-level }}
target: google_apis target: default
arch: x86 arch: x86
profile: Nexus 6 # profile: Nexus 6
profile: pixel_3a
# avd-name: test
emulator-options: -no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim -camera-back none emulator-options: -no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim -camera-back none
disable-animations: true disable-animations: true
working-directory: ./test-fixture/
script: | script: |
./gradlew help echo $GITHUB_REPOSITORY
./gradlew connectedDebugAndroidTest adb devices
adb shell ls -la /sdcard
adb shell ls -la /storage
adb emu geo fix 0 51
adb shell screenrecord --verbose /sdcard/capture.mpg &
adb shell pkill -INT screenrecord
mkdir -p app/build/report
cd app/build/report && adb pull /sdcard/capture.mpg
# ./gradlew help
# ./gradlew connectedDebugAndroidTest
- name: Upload build artifacts
uses: actions/upload-artifact@v1
with:
name: build-outputs
path: ./test-fixture/app/build/report
+69
View File
@@ -1,5 +1,74 @@
# Change Log # Change Log
## v2.12.0
Added support for using the `playstore` system images:
```
- name: run tests
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 30
target: playstore
arch: x86
script: ./gradlew connectedCheck
```
## v2.11.1
* Update SDK command-line tools to `2.1`.
* Update @actions/core to `1.2.6`.
## v2.11.0
* Support running multiple instances of the action sequentially in a single job - [#73](https://github.com/ReactiveCircus/android-emulator-runner/issues/73).
## v2.10.0
* Support Android 11 (API 30) system images.
* Bump build tools to `30.0.0`.
## v2.9.0
* Updated to SDK command-line tools `2.0`.
## v2.8.0
* Added support for specifying a custom name used for creating the **AVD** - [#59](https://github.com/ReactiveCircus/android-emulator-runner/issues/59).
## v2.7.0
* Added support for specifying versions of **NDK** and **CMake** to install.
## v2.6.2
* Fixed an issue where the Linux command-line tools binary is used for `macos`.
## v2.6.1
* Fixed SDK license issue on Linux when downloading API 28+ system images - [#42](https://github.com/ReactiveCircus/android-emulator-runner/issues/42).
## v2.6.0
* Added support for Linux VMs (no hardware acceleration) - [#15](https://github.com/ReactiveCircus/android-emulator-runner/issues/15).
## v2.5.0
* Added support for API 15-19 system images - [#26](https://github.com/ReactiveCircus/android-emulator-runner/issues/26).
* Switched to the new SDK command-line tools which supports running `sdkmanager` and `avdmanager` with Java 9+ - [#25](https://github.com/ReactiveCircus/android-emulator-runner/issues/25).
## v2.4.0
* Added support for setting custom `working-directory` - e.g. `./android` if your root Gradle project is under the `./android` sub-directory within your repository - [#22](https://github.com/ReactiveCircus/android-emulator-runner/issues/22).
## v2.3.2
* Fixed an issue where environment variables are escaped in script - [#19](https://github.com/ReactiveCircus/android-emulator-runner/issues/19).
## v2.3.1
* Bumped Android Build tools to 29.0.3.
## v2.3.0 ## v2.3.0
* Added support for running the action with Java 9+ by forcing SDK manager and AVD manager to use Java 8. * Added support for running the action with Java 9+ by forcing SDK manager and AVD manager to use Java 8.
+67 -11
View File
@@ -4,11 +4,11 @@
<a href="https://github.com/ReactiveCircus/android-emulator-runner"><img alt="GitHub Actions status" src="https://github.com/ReactiveCircus/android-emulator-runner/workflows/Main%20workflow/badge.svg"></a> <a href="https://github.com/ReactiveCircus/android-emulator-runner"><img alt="GitHub Actions status" src="https://github.com/ReactiveCircus/android-emulator-runner/workflows/Main%20workflow/badge.svg"></a>
</p> </p>
A GitHub Action for installing, configuring and running Android Emulators on macOS virtual machines. A GitHub Action for installing, configuring and running hardware-accelerated Android Emulators on macOS virtual machines.
The old ARM-based emulators were slow and are no longer supported by Google. The modern Intel Atom (x86 and x86_64) emulators require hardware acceleration (HAXM on Mac & Windows, QEMU on Linux) from the host to run fast. This presents a challenge on CI as to be able to run hardware accelerated emulators within a docker container, **KVM** must be supported by the host VM which isn't the case for cloud-based CI providers due to infrastructural limits. If you want to learn more about this, here's an article I wrote: [Running Android Instrumented Tests on CI](https://dev.to/ychescale9/running-android-emulators-on-ci-from-bitrise-io-to-github-actions-3j76). The old ARM-based emulators were slow and are no longer supported by Google. The modern Intel Atom (x86 and x86_64) emulators require hardware acceleration (HAXM on Mac & Windows, QEMU on Linux) from the host to run fast. This presents a challenge on CI as to be able to run hardware accelerated emulators within a docker container, **KVM** must be supported by the host VM which isn't the case for cloud-based CI providers due to infrastructural limits. If you want to learn more about this, here's an article I wrote: [Running Android Instrumented Tests on CI](https://dev.to/ychescale9/running-android-emulators-on-ci-from-bitrise-io-to-github-actions-3j76).
The **masOS** VM provided by **GitHub Actions** has **HAXM** installed so we are able to create a new AVD instance, launch an emulator with hardware acceleration, and run our Android The **macOS** VM provided by **GitHub Actions** has **HAXM** installed so we are able to create a new AVD instance, launch an emulator with hardware acceleration, and run our Android
tests directly on the VM. tests directly on the VM.
This action automates the process by doing the following: This action automates the process by doing the following:
@@ -22,14 +22,14 @@ This action automates the process by doing the following:
## Usage ## Usage
Note that this action must be run on a **macOS** VM, e.g. `macOS-latest` or `macOS-10.14`. It is recommended to run this action on a **macOS** VM, e.g. `macos-latest` or `macos-10.15` to take advantage of hardware accleration support provided by **HAXM**.
A workflow that uses **android-emulator-runner** to run your instrumented tests on **API 29**: A workflow that uses **android-emulator-runner** to run your instrumented tests on **API 29**:
``` ```
jobs: jobs:
test: test:
runs-on: macOS-latest runs-on: macos-latest
steps: steps:
- name: checkout - name: checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
@@ -46,7 +46,7 @@ We can also leverage GitHub Actions's build matrix to test across multiple confi
``` ```
jobs: jobs:
test: test:
runs-on: macOS-latest runs-on: macos-latest
strategy: strategy:
matrix: matrix:
api-level: [21, 23, 29] api-level: [21, 23, 29]
@@ -65,17 +65,73 @@ jobs:
script: ./gradlew connectedCheck script: ./gradlew connectedCheck
``` ```
If you need specific versions of **NDK** and **CMake** installed:
```
jobs:
test:
runs-on: macos-latest
steps:
- name: checkout
uses: actions/checkout@v2
- name: run tests
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 29
ndk: 21.0.6113669
cmake: 3.10.2.4988404
script: ./gradlew connectedCheck
```
## Configurations ## Configurations
| | **Required** | **Default** | **Description** | | **Input** | **Required** | **Default** | **Description** |
|----------------------|--------------|-------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| |-|-|-|-|
| `api-level` | Required | N/A | API level of the platform system image - e.g. 23 for Android Marshmallow, 29 for Android 10. **Minimum API level supported is 21**. | | `api-level` | Required | N/A | API level of the platform system image - e.g. 23 for Android Marshmallow, 29 for Android 10. **Minimum API level supported is 15**. |
| `target` | Optional | `default` | Target of the system image - `default` or `google_apis`. | | `target` | Optional | `default` | Target of the system image - `default`, `google_apis` or `playstore`. |
| `arch` | Optional | `x86` | CPU architecture of the system image - `x86` or `x86_64`. | | `arch` | Optional | `x86` | CPU architecture of the system image - `x86` or `x86_64`. Note that `x86_64` image is only available for API 21+. |
| `profile` | Optional | N/A | Hardware profile used for creating the AVD - e.g. `Nexus 6`. For a list of all profiles available, run `$ANDROID_HOME/tools/bin/avdmanager list` and refer to the results under "Available Android Virtual Devices". | | `profile` | Optional | N/A | Hardware profile used for creating the AVD - e.g. `Nexus 6`. For a list of all profiles available, run `avdmanager list` and refer to the results under "Available Android Virtual Devices". |
| `avd-name` | Optional | `test` | Custom AVD name used for creating the Android Virtual Device. |
| `emulator-options` | Optional | See below | Command-line options used when launching the emulator (replacing all default options) - e.g. `-no-window -no-snapshot -camera-back emulated`. | | `emulator-options` | Optional | See below | Command-line options used when launching the emulator (replacing all default options) - e.g. `-no-window -no-snapshot -camera-back emulated`. |
| `disable-animations` | Optional | `true` | Whether to disable animations - `true` or `false`. | | `disable-animations` | Optional | `true` | Whether to disable animations - `true` or `false`. |
| `emulator-build` | Optional | N/A | Build number of a specific version of the emulator binary to use e.g. `6061023` for emulator v29.3.0.0. | | `emulator-build` | Optional | N/A | Build number of a specific version of the emulator binary to use e.g. `6061023` for emulator v29.3.0.0. |
| `working-directory` | Optional | `./` | A custom working directory - e.g. `./android` if your root Gradle project is under the `./android` sub-directory within your repository. |
| `ndk` | Optional | N/A | Version of NDK to install - e.g. `21.0.6113669` |
| `cmake` | Optional | N/A | Version of CMake to install - e.g. `3.10.2.4988404` |
| `script` | Required | N/A | Custom script to run - e.g. to run Android instrumented tests on the emulator: `./gradlew connectedCheck` | | `script` | Required | N/A | Custom script to run - e.g. to run Android instrumented tests on the emulator: `./gradlew connectedCheck` |
Default `emulator-options`: `-no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim`. Default `emulator-options`: `-no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim`.
## Can I use this action on Linux VMs?
The short answer is yes but it's expected to be a much worse experience (on some newer API levels it might not work at all) than running it on macOS.
For a longer answer please refer to [this issue](https://github.com/ReactiveCircus/android-emulator-runner/issues/46).
## Who is using Android Emulator Runner?
These are some of the open-source projects using (or used) **Android Emulator Runner**:
- [coil-kt/coil](https://github.com/coil-kt/coil/blob/master/.github/workflows/)
- [cashapp/sqldelight](https://github.com/cashapp/sqldelight/blob/master/.github/workflows/)
- [square/workflow](https://github.com/square/workflow/blob/main/.github/workflows/)
- [square/retrofit](https://github.com/square/retrofit/blob/master/.github/workflows/)
- [natario1/CameraView](https://github.com/natario1/CameraView/tree/master/.github/workflows)
- [natario1/Transcoder](https://github.com/natario1/Transcoder/tree/master/.github/workflows)
- [chrisbanes/insetter](https://github.com/chrisbanes/insetter/tree/main/.github/workflows)
- [slackhq/keeper](https://github.com/slackhq/keeper/tree/main/.github/workflows)
- [android/compose-samples](https://github.com/android/compose-samples/blob/master/.github/workflows/ci.yaml)
- [ReactiveCircus/streamlined](https://github.com/ReactiveCircus/streamlined/tree/main/.github/workflows)
- [ReactiveCircus/FlowBinding](https://github.com/ReactiveCircus/FlowBinding)
- [JakeWharton/RxBinding](https://github.com/JakeWharton/RxBinding/tree/master/.github/workflows)
- [vinaygaba/Learn-Jetpack-Compose-By-Example](https://github.com/vinaygaba/Learn-Jetpack-Compose-By-Example/)
- [ashishb/adb-enhanced](https://github.com/ashishb/adb-enhanced/tree/master/.github/workflows)
- [vgaidarji/ci-matters](https://github.com/vgaidarji/ci-matters/blob/master/.github/workflows/main.yaml)
- [simpledotorg/simple-android](https://github.com/simpledotorg/simple-android)
- [cashapp/copper](https://github.com/cashapp/copper/blob/trunk/.github/workflows/build.yaml)
- [square/radiography](https://github.com/square/radiography/blob/main/.github/workflows/android.yml)
- [Shopify/android-testify](https://github.com/Shopify/android-testify/blob/master/.github/workflows/sample_build.yml)
If you are using **Android Emulator Runner** and want your project included in the list, please feel free to create an issue or open a pull request.
+3 -3
View File
@@ -4,7 +4,7 @@ Refer to the [recommendeations for versioning and releasing actions](https://git
## New major release ## New major release
- From `master` branch, run `npm run build && npm test --clean && npm run lint` to make sure `lib/*.js` are up-to-date. - From `main` branch, run `npm run build && npm test --clean && npm run lint` to make sure `lib/*.js` are up-to-date.
- Update `CHANGELOG.md`, push change with "Prepare for release X.Y.Z." (where X.Y.Z is the new version). - Update `CHANGELOG.md`, push change with "Prepare for release X.Y.Z." (where X.Y.Z is the new version).
- Create a new branch e.g. `release/v1`, comment out `node_modules/` in `.gitignore`, commit the change (do not commit yet `node_modules`). - Create a new branch e.g. `release/v1`, comment out `node_modules/` in `.gitignore`, commit the change (do not commit yet `node_modules`).
- Run `npm prune --production`. - Run `npm prune --production`.
@@ -17,9 +17,9 @@ Refer to the [recommendeations for versioning and releasing actions](https://git
## New minor / patch release ## New minor / patch release
- From `master` branch, run `npm run build && npm test --clean && npm run lint` to make sure `lib/*.js` are up-to-date. - From `main` branch, run `npm run build && npm test --clean && npm run lint` to make sure `lib/*.js` are up-to-date.
- Update `CHANGELOG.md`, push change with "Prepare for release X.Y.Z." (where X.Y.Z is the new version). - Update `CHANGELOG.md`, push change with "Prepare for release X.Y.Z." (where X.Y.Z is the new version).
- Merge from `master` into the release branch e.g. `release/v1`. - Merge from `main` into the release branch e.g. `release/v1`.
- Run `npm prune --production`. - Run `npm prune --production`.
- Commit merged changes (and the pruned `node_modules`). - Commit merged changes (and the pruned `node_modules`).
- Push to remote. - Push to remote.
+7 -2
View File
@@ -17,14 +17,14 @@ describe('api-level validator tests', () => {
it('Throws if api-level is lower than min API supported', () => { it('Throws if api-level is lower than min API supported', () => {
const func = () => { const func = () => {
validator.checkApiLevel('20'); validator.checkApiLevel('14');
}; };
expect(func).toThrowError(`Minimum API level supported is ${validator.MIN_API_LEVEL}.`); expect(func).toThrowError(`Minimum API level supported is ${validator.MIN_API_LEVEL}.`);
}); });
it('Validates successfully with valid api-level', () => { it('Validates successfully with valid api-level', () => {
const func1 = () => { const func1 = () => {
validator.checkApiLevel('21'); validator.checkApiLevel('15');
}; };
expect(func1).not.toThrow(); expect(func1).not.toThrow();
@@ -53,6 +53,11 @@ describe('target validator tests', () => {
validator.checkTarget('google_apis'); validator.checkTarget('google_apis');
}; };
expect(func2).not.toThrow(); expect(func2).not.toThrow();
const func3 = () => {
validator.checkTarget('google_apis');
};
expect(func3).not.toThrow();
}); });
}); });
+13 -4
View File
@@ -9,21 +9,30 @@ inputs:
description: 'API level of the platform and system image - e.g. 23 for Android Marshmallow, 29 for Android 10' description: 'API level of the platform and system image - e.g. 23 for Android Marshmallow, 29 for Android 10'
required: true required: true
target: target:
description: 'target of the system image - default or google_apis' description: 'target of the system image - default, google_apis or playstore'
default: 'default' default: 'default'
arch: arch:
description: 'CPU architecture of the system image - x86 or x86_64' description: 'CPU architecture of the system image - x86 or x86_64'
default: 'x86' default: 'x86'
profile: profile:
description: 'Hardware profile used for creating the AVD - e.g. `Nexus 6`.' description: 'hardware profile used for creating the AVD - e.g. `Nexus 6`'
avd-name:
description: 'custom AVD name used for creating the Android Virtual Device'
default: 'test'
emulator-options: emulator-options:
description: 'command-line options used when launching the emulator - e.g. `-no-window -no-snapshot -camera-back emulated`.' description: 'command-line options used when launching the emulator - e.g. `-no-window -no-snapshot -camera-back emulated`'
default: '-no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim' default: '-no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim'
disable-animations: disable-animations:
description: 'whether to disable animations - true or false' description: 'whether to disable animations - true or false'
default: 'true' default: 'true'
emulator-build: emulator-build:
description: 'build number of a specific version of the emulator binary to use e.g. `6061023` for emulator v29.3.0.0.' description: 'build number of a specific version of the emulator binary to use - e.g. `6061023` for emulator v29.3.0.0'
working-directory:
description: 'A custom working directory - e.g. `./android` if your root Gradle project is under the `./android` sub-directory within your repository'
ndk:
description: 'version of NDK to install - e.g. 21.0.6113669'
cmake:
description: 'version of CMake to install - e.g. 3.10.2.4988404'
script: script:
description: 'custom script to run - e.g. `./gradlew connectedCheck`' description: 'custom script to run - e.g. `./gradlew connectedCheck`'
required: true required: true
+40 -24
View File
@@ -1,41 +1,57 @@
"use strict"; "use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
return new (P || (P = Promise))(function (resolve, reject) { if (k2 === undefined) k2 = k;
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } }) : (function(o, m, k, k2) {
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } if (k2 === undefined) k2 = k;
step((generator = generator.apply(thisArg, _arguments || [])).next()); o[k2] = m[k];
}); }));
}; var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) { var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod; if (mod && mod.__esModule) return mod;
var result = {}; var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
result["default"] = mod; __setModuleDefault(result, mod);
return result; return result;
}; };
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
exports.killEmulator = exports.launchEmulator = void 0;
const exec = __importStar(require("@actions/exec")); const exec = __importStar(require("@actions/exec"));
const EMULATOR_BOOT_TIMEOUT_SECONDS = 300; const EMULATOR_BOOT_TIMEOUT_SECONDS = 600;
const AVD_MANAGER_PATH = `${process.env.ANDROID_HOME}/tools/bin/avdmanager`;
const ADB_PATH = `${process.env.ANDROID_HOME}/platform-tools/adb`;
/** /**
* Creates and launches a new AVD instance with the specified configurations. * Creates and launches a new AVD instance with the specified configurations.
*/ */
function launchEmulator(apiLevel, target, arch, profile, emulatorOptions, disableAnimations) { function launchEmulator(apiLevel, target, arch, profile, avdName, emulatorOptions, disableAnimations) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
// create a new AVD // create a new AVD
if (profile.trim() !== '') { if (profile.trim() !== '') {
console.log(`Creating AVD with custom profile ${profile}`); console.log(`Creating AVD with custom profile ${profile}`);
yield exec.exec(`${AVD_MANAGER_PATH} create avd --force -n test --abi "${target}/${arch}" --package "system-images;android-${apiLevel};${target};${arch}" --device "${profile}"`); yield exec.exec(`avdmanager create avd --force -n "${avdName}" --abi "${target}/${arch}" --package "system-images;android-${apiLevel};${target};${arch}" --device "${profile}"`);
} }
else { else {
console.log(`Creating AVD without custom profile.`); console.log(`Creating AVD without custom profile.`);
yield exec.exec(`sh -c \\"echo no | ${AVD_MANAGER_PATH} create avd --force -n test --abi '${target}/${arch}' --package 'system-images;android-${apiLevel};${target};${arch}'"`); yield exec.exec(`sh -c \\"echo no | avdmanager create avd --force -n "${avdName}" --abi '${target}/${arch}' --package 'system-images;android-${apiLevel};${target};${arch}'"`);
} }
// start emulator // start emulator
console.log('Starting emulator.'); console.log('Starting emulator.');
yield exec.exec(`sh -c \\"${process.env.ANDROID_HOME}/emulator/emulator -avd test ${emulatorOptions} &"`, [], { // turn off hardware acceleration on Linux
if (process.platform === 'linux') {
emulatorOptions += ' -accel off';
}
yield exec.exec(`sh -c \\"${process.env.ANDROID_HOME}/emulator/emulator -avd "${avdName}" ${emulatorOptions} &"`, [], {
listeners: { listeners: {
stderr: (data) => { stderr: (data) => {
if (data.toString().includes('invalid command-line parameter')) { if (data.toString().includes('invalid command-line parameter')) {
@@ -46,13 +62,13 @@ function launchEmulator(apiLevel, target, arch, profile, emulatorOptions, disabl
}); });
// wait for emulator to complete booting // wait for emulator to complete booting
yield waitForDevice(); yield waitForDevice();
yield exec.exec(`${ADB_PATH} shell input keyevent 82`); yield exec.exec(`adb shell input keyevent 82`);
// disable animations // disable animations
if (disableAnimations) { if (disableAnimations) {
console.log('Disabling animations.'); console.log('Disabling animations.');
yield exec.exec(`${ADB_PATH} shell settings put global window_animation_scale 0.0`); yield exec.exec(`adb shell settings put global window_animation_scale 0.0`);
yield exec.exec(`${ADB_PATH} shell settings put global transition_animation_scale 0.0`); yield exec.exec(`adb shell settings put global transition_animation_scale 0.0`);
yield exec.exec(`${ADB_PATH} shell settings put global animator_duration_scale 0.0`); yield exec.exec(`adb shell settings put global animator_duration_scale 0.0`);
} }
}); });
} }
@@ -63,7 +79,7 @@ exports.launchEmulator = launchEmulator;
function killEmulator() { function killEmulator() {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
try { try {
yield exec.exec(`${ADB_PATH} -s emulator-5554 emu kill`); yield exec.exec(`adb -s emulator-5554 emu kill`);
} }
catch (error) { catch (error) {
console.log(error.message); console.log(error.message);
@@ -83,7 +99,7 @@ function waitForDevice() {
while (!booted) { while (!booted) {
try { try {
let result = ''; let result = '';
yield exec.exec(`${ADB_PATH} shell getprop sys.boot_completed`, [], { yield exec.exec(`adb shell getprop sys.boot_completed`, [], {
listeners: { listeners: {
stdout: (data) => { stdout: (data) => {
result += data.toString(); result += data.toString();
@@ -97,7 +113,7 @@ function waitForDevice() {
} }
} }
catch (error) { catch (error) {
console.log(error.message); console.warn(error.message);
} }
if (attempts < maxAttemps) { if (attempts < maxAttemps) {
yield delay(retryInterval * 1000); yield delay(retryInterval * 1000);
+3 -2
View File
@@ -1,7 +1,8 @@
"use strict"; "use strict";
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
exports.MIN_API_LEVEL = 21; exports.checkEmulatorBuild = exports.checkDisableAnimations = exports.checkArch = exports.checkTarget = exports.checkApiLevel = exports.VALID_ARCHS = exports.VALID_TARGETS = exports.MIN_API_LEVEL = void 0;
exports.VALID_TARGETS = ['default', 'google_apis']; exports.MIN_API_LEVEL = 15;
exports.VALID_TARGETS = ['default', 'google_apis', 'google_apis_playstore'];
exports.VALID_ARCHS = ['x86', 'x86_64']; exports.VALID_ARCHS = ['x86', 'x86_64'];
function checkApiLevel(apiLevel) { function checkApiLevel(apiLevel) {
if (isNaN(Number(apiLevel)) || !Number.isInteger(Number(apiLevel))) { if (isNaN(Number(apiLevel)) || !Number.isInteger(Number(apiLevel))) {
-60
View File
@@ -1,60 +0,0 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const core = __importStar(require("@actions/core"));
const exec = __importStar(require("@actions/exec"));
/**
* Returns the current $JAVA_HOME path.
*/
function getCurrentJavaHome() {
return __awaiter(this, void 0, void 0, function* () {
let defaultJavaHome = '';
yield exec.exec(`sh -c \\"echo $JAVA_HOME"`, [], {
listeners: {
stdout: (data) => {
defaultJavaHome += data.toString();
}
}
});
return defaultJavaHome.trim();
});
}
exports.getCurrentJavaHome = getCurrentJavaHome;
/**
* Returns the Java 8 $JAVA_HOME path.
*/
function getJavaHomeV8() {
return __awaiter(this, void 0, void 0, function* () {
let javaHomeV8 = '';
yield exec.exec(`/usr/libexec/java_home -v 1.8`, [], {
listeners: {
stdout: (data) => {
javaHomeV8 += data.toString();
}
}
});
return javaHomeV8.trim();
});
}
exports.getJavaHomeV8 = getJavaHomeV8;
/**
* Sets $JAVA_HOME to the specified path.
*/
function setJavaHome(path) {
core.exportVariable('JAVA_HOME', path);
}
exports.setJavaHome = setJavaHome;
+61 -28
View File
@@ -1,19 +1,32 @@
"use strict"; "use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
return new (P || (P = Promise))(function (resolve, reject) { if (k2 === undefined) k2 = k;
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } }) : (function(o, m, k, k2) {
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } if (k2 === undefined) k2 = k;
step((generator = generator.apply(thisArg, _arguments || [])).next()); o[k2] = m[k];
}); }));
}; var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) { var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod; if (mod && mod.__esModule) return mod;
var result = {}; var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
result["default"] = mod; __setModuleDefault(result, mod);
return result; return result;
}; };
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
const core = __importStar(require("@actions/core")); const core = __importStar(require("@actions/core"));
const sdk_installer_1 = require("./sdk-installer"); const sdk_installer_1 = require("./sdk-installer");
@@ -21,13 +34,17 @@ const input_validator_1 = require("./input-validator");
const emulator_manager_1 = require("./emulator-manager"); const emulator_manager_1 = require("./emulator-manager");
const exec = __importStar(require("@actions/exec")); const exec = __importStar(require("@actions/exec"));
const script_parser_1 = require("./script-parser"); const script_parser_1 = require("./script-parser");
const java_version_manager_1 = require("./java-version-manager");
function run() { function run() {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
try { try {
// only support running on macOS // only support running on macOS or Linux
if (process.platform !== 'darwin') { if (process.platform !== 'darwin') {
throw new Error('This action is expected to be run within a macOS virtual machine to enable hardware acceleration.'); if (process.platform === 'linux') {
console.warn(`You're running a Linux VM where hardware acceleration is not available. Please consider using a macOS VM instead to take advantage of native hardware acceleration support provided by HAXM.`);
}
else {
throw new Error('Unsupported virtual machine: please use either macos or ubuntu VM.');
}
} }
// API level of the platform and system image // API level of the platform and system image
const apiLevelInput = core.getInput('api-level', { required: true }); const apiLevelInput = core.getInput('api-level', { required: true });
@@ -35,7 +52,8 @@ function run() {
const apiLevel = Number(apiLevelInput); const apiLevel = Number(apiLevelInput);
console.log(`API level: ${apiLevel}`); console.log(`API level: ${apiLevel}`);
// target of the system image // target of the system image
const target = core.getInput('target'); const targetInput = core.getInput('target');
const target = targetInput == 'playstore' ? 'google_apis_playstore' : targetInput;
input_validator_1.checkTarget(target); input_validator_1.checkTarget(target);
console.log(`target: ${target}`); console.log(`target: ${target}`);
// CPU architecture of the system image // CPU architecture of the system image
@@ -45,6 +63,9 @@ function run() {
// Hardware profile used for creating the AVD // Hardware profile used for creating the AVD
const profile = core.getInput('profile'); const profile = core.getInput('profile');
console.log(`Hardware profile: ${profile}`); console.log(`Hardware profile: ${profile}`);
// custom name used for creating the AVD
const avdName = core.getInput('avd-name');
console.log(`AVD name: ${avdName}`);
// emulator options // emulator options
const emulatorOptions = core.getInput('emulator-options').trim(); const emulatorOptions = core.getInput('emulator-options').trim();
console.log(`emulator options: ${emulatorOptions}`); console.log(`emulator options: ${emulatorOptions}`);
@@ -60,6 +81,24 @@ function run() {
console.log(`using emulator build: ${emulatorBuildInput}`); console.log(`using emulator build: ${emulatorBuildInput}`);
} }
const emulatorBuild = !emulatorBuildInput ? undefined : emulatorBuildInput; const emulatorBuild = !emulatorBuildInput ? undefined : emulatorBuildInput;
// custom working directory
const workingDirectoryInput = core.getInput('working-directory');
if (workingDirectoryInput) {
console.log(`custom working directory: ${workingDirectoryInput}`);
}
const workingDirectory = !workingDirectoryInput ? undefined : workingDirectoryInput;
// version of NDK to install
const ndkInput = core.getInput('ndk');
if (ndkInput) {
console.log(`version of NDK to install: ${ndkInput}`);
}
const ndkVersion = !ndkInput ? undefined : ndkInput;
// version of CMake to install
const cmakeInput = core.getInput('cmake');
if (cmakeInput) {
console.log(`version of CMake to install: ${cmakeInput}`);
}
const cmakeVersion = !cmakeInput ? undefined : cmakeInput;
// custom script to run // custom script to run
const scriptInput = core.getInput('script', { required: true }); const scriptInput = core.getInput('script', { required: true });
const scripts = script_parser_1.parseScript(scriptInput); const scripts = script_parser_1.parseScript(scriptInput);
@@ -67,24 +106,18 @@ function run() {
scripts.forEach((script) => __awaiter(this, void 0, void 0, function* () { scripts.forEach((script) => __awaiter(this, void 0, void 0, function* () {
console.log(`${script}`); console.log(`${script}`);
})); }));
// use Java 8 for sdkmanager and avdmanager
const defaultJavaHome = yield java_version_manager_1.getCurrentJavaHome();
java_version_manager_1.setJavaHome(yield java_version_manager_1.getJavaHomeV8());
// install SDK // install SDK
yield sdk_installer_1.installAndroidSdk(apiLevel, target, arch, emulatorBuild); yield sdk_installer_1.installAndroidSdk(apiLevel, target, arch, emulatorBuild, ndkVersion, cmakeVersion);
try { // launch an emulator
// launch an emulator yield emulator_manager_1.launchEmulator(apiLevel, target, arch, profile, avdName, emulatorOptions, disableAnimations);
yield emulator_manager_1.launchEmulator(apiLevel, target, arch, profile, emulatorOptions, disableAnimations);
}
catch (error) {
core.setFailed(error.message);
}
// use default JAVA_HOME for running custom script
java_version_manager_1.setJavaHome(defaultJavaHome);
// execute the custom script // execute the custom script
try { try {
// move to custom working directory if set
if (workingDirectory) {
process.chdir(workingDirectory);
}
for (const script of scripts) { for (const script of scripts) {
yield exec.exec(`${script}`); yield exec.exec(`sh -c \\"${script}"`);
} }
} }
catch (error) { catch (error) {
+1
View File
@@ -1,5 +1,6 @@
"use strict"; "use strict";
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
exports.parseScript = void 0;
/** /**
* Convert a (potentially multi-line) script to an array of single-line script(s). * Convert a (potentially multi-line) script to an array of single-line script(s).
*/ */
+73 -19
View File
@@ -1,44 +1,98 @@
"use strict"; "use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
return new (P || (P = Promise))(function (resolve, reject) { if (k2 === undefined) k2 = k;
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } }) : (function(o, m, k, k2) {
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } if (k2 === undefined) k2 = k;
step((generator = generator.apply(thisArg, _arguments || [])).next()); o[k2] = m[k];
}); }));
}; var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) { var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod; if (mod && mod.__esModule) return mod;
var result = {}; var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
result["default"] = mod; __setModuleDefault(result, mod);
return result; return result;
}; };
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
exports.installAndroidSdk = void 0;
const core = __importStar(require("@actions/core"));
const exec = __importStar(require("@actions/exec")); const exec = __importStar(require("@actions/exec"));
const BUILD_TOOLS_VERSION = '29.0.2'; const io = __importStar(require("@actions/io"));
const tc = __importStar(require("@actions/tool-cache"));
const fs = __importStar(require("fs"));
const BUILD_TOOLS_VERSION = '30.0.2';
const CMDLINE_TOOLS_URL_MAC = 'https://dl.google.com/android/repository/commandlinetools-mac-6858069_latest.zip';
const CMDLINE_TOOLS_URL_LINUX = 'https://dl.google.com/android/repository/commandlinetools-linux-6858069_latest.zip';
/** /**
* Installs & updates the Android SDK for the macOS platform, including SDK platform for the chosen API level, latest build tools, platform tools, Android Emulator, * Installs & updates the Android SDK for the macOS platform, including SDK platform for the chosen API level, latest build tools, platform tools, Android Emulator,
* and the system image for the chosen API level, CPU arch, and target. * and the system image for the chosen API level, CPU arch, and target.
*/ */
function installAndroidSdk(apiLevel, target, arch, emulatorBuild) { function installAndroidSdk(apiLevel, target, arch, emulatorBuild, ndkVersion, cmakeVersion) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
const sdkmangerPath = `${process.env.ANDROID_HOME}/tools/bin/sdkmanager`; const isOnMac = process.platform === 'darwin';
if (!isOnMac) {
yield exec.exec(`sh -c \\"sudo chown $USER:$USER ${process.env.ANDROID_HOME} -R`);
}
const cmdlineToolsPath = `${process.env.ANDROID_HOME}/cmdline-tools`;
if (!fs.existsSync(cmdlineToolsPath)) {
console.log('Installing new cmdline-tools.');
const sdkUrl = isOnMac ? CMDLINE_TOOLS_URL_MAC : CMDLINE_TOOLS_URL_LINUX;
// await io.mkdirP(cmdlineToolsPath);
const downloadPath = yield tc.downloadTool(sdkUrl);
yield tc.extractZip(downloadPath, cmdlineToolsPath);
yield io.mv(`${cmdlineToolsPath}/cmdline-tools`, `${cmdlineToolsPath}/latest`);
yield exec.exec(`ls -la ${cmdlineToolsPath}`);
// add paths for commandline-tools and platform-tools
core.addPath(`${cmdlineToolsPath}/latest:${cmdlineToolsPath}/latest/bin:${process.env.ANDROID_HOME}/platform-tools`);
yield exec.exec(`ls -la ${cmdlineToolsPath}/latest`);
}
// additional permission and license requirements for Linux
const sdkPreviewLicensePath = `${process.env.ANDROID_HOME}/licenses/android-sdk-preview-license`;
if (!isOnMac && !fs.existsSync(sdkPreviewLicensePath)) {
fs.writeFileSync(sdkPreviewLicensePath, '\n84831b9409646a918e30573bab4c9c91346d8abd');
}
// license required for API 30 system images
const sdkArmDbtLicensePath = `${process.env.ANDROID_HOME}/licenses/android-sdk-arm-dbt-license`;
if (apiLevel == 30 && !fs.existsSync(sdkArmDbtLicensePath)) {
fs.writeFileSync(sdkArmDbtLicensePath, '\n859f317696f67ef3d7f30a50a5560e7834b43903');
}
console.log('Installing latest build tools, platform tools, and platform.'); console.log('Installing latest build tools, platform tools, and platform.');
yield exec.exec(`sh -c \\"${sdkmangerPath} --install 'build-tools;${BUILD_TOOLS_VERSION}' platform-tools 'platforms;android-${apiLevel}' > /dev/null"`); yield exec.exec(`sh -c \\"sdkmanager --install 'build-tools;${BUILD_TOOLS_VERSION}' platform-tools 'platforms;android-${apiLevel}' > /dev/null"`);
if (emulatorBuild) { if (emulatorBuild) {
console.log(`Installing emulator build ${emulatorBuild}.`); console.log(`Installing emulator build ${emulatorBuild}.`);
yield exec.exec(`curl -fo emulator.zip https://dl.google.com/android/repository/emulator-darwin-${emulatorBuild}.zip`); yield exec.exec(`curl -fo emulator.zip https://dl.google.com/android/repository/emulator-${isOnMac ? 'darwin' : 'linux'}-${emulatorBuild}.zip`);
yield exec.exec(`rm -rf ${process.env.ANDROID_HOME}/emulator`); yield io.rmRF(`${process.env.ANDROID_HOME}/emulator`);
yield exec.exec(`unzip -q emulator.zip -d ${process.env.ANDROID_HOME}`); yield exec.exec(`unzip -q emulator.zip -d ${process.env.ANDROID_HOME}`);
yield exec.exec(`rm -f emulator.zip`); yield io.rmRF('emulator.zip');
} }
else { else {
console.log('Installing latest emulator.'); console.log('Installing latest emulator.');
yield exec.exec(`sh -c \\"${sdkmangerPath} --install emulator > /dev/null"`); yield exec.exec(`sh -c \\"sdkmanager --install emulator > /dev/null"`);
} }
console.log('Installing system images.'); console.log('Installing system images.');
yield exec.exec(`sh -c \\"${sdkmangerPath} --install 'system-images;android-${apiLevel};${target};${arch}' > /dev/null"`); yield exec.exec(`sh -c \\"sdkmanager --install 'system-images;android-${apiLevel};${target};${arch}' > /dev/null"`);
if (ndkVersion) {
console.log(`Installing NDK ${ndkVersion}.`);
yield exec.exec(`sh -c \\"sdkmanager --install 'ndk;${ndkVersion}' > /dev/null"`);
}
if (cmakeVersion) {
console.log(`Installing CMake ${cmakeVersion}.`);
yield exec.exec(`sh -c \\"sdkmanager --install 'cmake;${cmakeVersion}' > /dev/null"`);
}
}); });
} }
exports.installAndroidSdk = installAndroidSdk; exports.installAndroidSdk = installAndroidSdk;
+5180 -2568
View File
File diff suppressed because it is too large Load Diff
+17 -16
View File
@@ -21,23 +21,24 @@
"author": "Reactive Circus", "author": "Reactive Circus",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@actions/core": "^1.0.0", "@actions/core": "^1.2.6",
"@actions/exec": "^1.0.1", "@actions/exec": "^1.0.4",
"@actions/tool-cache": "^1.1.2" "@actions/tool-cache": "^1.6.0",
"minimist": "^1.2.5"
}, },
"devDependencies": { "devDependencies": {
"@types/jest": "^24.0.13", "@types/jest": "^24.9.1",
"@types/node": "^12.0.4", "@types/node": "^12.12.64",
"@typescript-eslint/eslint-plugin": "^2.6.1", "@typescript-eslint/eslint-plugin": "^2.34.0",
"@typescript-eslint/parser": "^2.6.1", "@typescript-eslint/parser": "^2.34.0",
"eslint": "^6.6.0", "eslint": "^6.8.0",
"eslint-config-prettier": "^6.5.0", "eslint-config-prettier": "^6.12.0",
"eslint-plugin-import": "^2.18.2", "eslint-plugin-import": "^2.22.1",
"eslint-plugin-prettier": "^3.1.1", "eslint-plugin-prettier": "^3.1.4",
"jest": "^24.8.0", "jest": "^25.5.4",
"jest-circus": "^24.7.1", "jest-circus": "^25.5.4",
"prettier": "^1.18.2", "prettier": "^1.19.1",
"ts-jest": "^24.0.2", "ts-jest": "^26.4.1",
"typescript": "^3.5.1" "typescript": "^3.9.7"
} }
} }
+18 -14
View File
@@ -1,25 +1,29 @@
import * as exec from '@actions/exec'; import * as exec from '@actions/exec';
const EMULATOR_BOOT_TIMEOUT_SECONDS = 300; const EMULATOR_BOOT_TIMEOUT_SECONDS = 600;
const AVD_MANAGER_PATH = `${process.env.ANDROID_HOME}/tools/bin/avdmanager`;
const ADB_PATH = `${process.env.ANDROID_HOME}/platform-tools/adb`;
/** /**
* Creates and launches a new AVD instance with the specified configurations. * Creates and launches a new AVD instance with the specified configurations.
*/ */
export async function launchEmulator(apiLevel: number, target: string, arch: string, profile: string, emulatorOptions: string, disableAnimations: boolean): Promise<void> { export async function launchEmulator(apiLevel: number, target: string, arch: string, profile: string, avdName: string, emulatorOptions: string, disableAnimations: boolean): Promise<void> {
// create a new AVD // create a new AVD
if (profile.trim() !== '') { if (profile.trim() !== '') {
console.log(`Creating AVD with custom profile ${profile}`); console.log(`Creating AVD with custom profile ${profile}`);
await exec.exec(`${AVD_MANAGER_PATH} create avd --force -n test --abi "${target}/${arch}" --package "system-images;android-${apiLevel};${target};${arch}" --device "${profile}"`); await exec.exec(`avdmanager create avd --force -n "${avdName}" --abi "${target}/${arch}" --package "system-images;android-${apiLevel};${target};${arch}" --device "${profile}"`);
} else { } else {
console.log(`Creating AVD without custom profile.`); console.log(`Creating AVD without custom profile.`);
await exec.exec(`sh -c \\"echo no | ${AVD_MANAGER_PATH} create avd --force -n test --abi '${target}/${arch}' --package 'system-images;android-${apiLevel};${target};${arch}'"`); await exec.exec(`sh -c \\"echo no | avdmanager create avd --force -n "${avdName}" --abi '${target}/${arch}' --package 'system-images;android-${apiLevel};${target};${arch}'"`);
} }
// start emulator // start emulator
console.log('Starting emulator.'); console.log('Starting emulator.');
await exec.exec(`sh -c \\"${process.env.ANDROID_HOME}/emulator/emulator -avd test ${emulatorOptions} &"`, [], {
// turn off hardware acceleration on Linux
if (process.platform === 'linux') {
emulatorOptions += ' -accel off';
}
await exec.exec(`sh -c \\"${process.env.ANDROID_HOME}/emulator/emulator -avd "${avdName}" ${emulatorOptions} &"`, [], {
listeners: { listeners: {
stderr: (data: Buffer) => { stderr: (data: Buffer) => {
if (data.toString().includes('invalid command-line parameter')) { if (data.toString().includes('invalid command-line parameter')) {
@@ -31,14 +35,14 @@ export async function launchEmulator(apiLevel: number, target: string, arch: str
// wait for emulator to complete booting // wait for emulator to complete booting
await waitForDevice(); await waitForDevice();
await exec.exec(`${ADB_PATH} shell input keyevent 82`); await exec.exec(`adb shell input keyevent 82`);
// disable animations // disable animations
if (disableAnimations) { if (disableAnimations) {
console.log('Disabling animations.'); console.log('Disabling animations.');
await exec.exec(`${ADB_PATH} shell settings put global window_animation_scale 0.0`); await exec.exec(`adb shell settings put global window_animation_scale 0.0`);
await exec.exec(`${ADB_PATH} shell settings put global transition_animation_scale 0.0`); await exec.exec(`adb shell settings put global transition_animation_scale 0.0`);
await exec.exec(`${ADB_PATH} shell settings put global animator_duration_scale 0.0`); await exec.exec(`adb shell settings put global animator_duration_scale 0.0`);
} }
} }
@@ -47,7 +51,7 @@ export async function launchEmulator(apiLevel: number, target: string, arch: str
*/ */
export async function killEmulator(): Promise<void> { export async function killEmulator(): Promise<void> {
try { try {
await exec.exec(`${ADB_PATH} -s emulator-5554 emu kill`); await exec.exec(`adb -s emulator-5554 emu kill`);
} catch (error) { } catch (error) {
console.log(error.message); console.log(error.message);
} }
@@ -64,7 +68,7 @@ async function waitForDevice(): Promise<void> {
while (!booted) { while (!booted) {
try { try {
let result = ''; let result = '';
await exec.exec(`${ADB_PATH} shell getprop sys.boot_completed`, [], { await exec.exec(`adb shell getprop sys.boot_completed`, [], {
listeners: { listeners: {
stdout: (data: Buffer) => { stdout: (data: Buffer) => {
result += data.toString(); result += data.toString();
@@ -77,7 +81,7 @@ async function waitForDevice(): Promise<void> {
break; break;
} }
} catch (error) { } catch (error) {
console.log(error.message); console.warn(error.message);
} }
if (attempts < maxAttemps) { if (attempts < maxAttemps) {
+2 -2
View File
@@ -1,5 +1,5 @@
export const MIN_API_LEVEL = 21; export const MIN_API_LEVEL = 15;
export const VALID_TARGETS: Array<string> = ['default', 'google_apis']; export const VALID_TARGETS: Array<string> = ['default', 'google_apis', 'google_apis_playstore'];
export const VALID_ARCHS: Array<string> = ['x86', 'x86_64']; export const VALID_ARCHS: Array<string> = ['x86', 'x86_64'];
export function checkApiLevel(apiLevel: string): void { export function checkApiLevel(apiLevel: string): void {
-39
View File
@@ -1,39 +0,0 @@
import * as core from '@actions/core';
import * as exec from '@actions/exec';
/**
* Returns the current $JAVA_HOME path.
*/
export async function getCurrentJavaHome(): Promise<string> {
let defaultJavaHome = '';
await exec.exec(`sh -c \\"echo $JAVA_HOME"`, [], {
listeners: {
stdout: (data: Buffer) => {
defaultJavaHome += data.toString();
}
}
});
return defaultJavaHome.trim();
}
/**
* Returns the Java 8 $JAVA_HOME path.
*/
export async function getJavaHomeV8(): Promise<string> {
let javaHomeV8 = '';
await exec.exec(`/usr/libexec/java_home -v 1.8`, [], {
listeners: {
stdout: (data: Buffer) => {
javaHomeV8 += data.toString();
}
}
});
return javaHomeV8.trim();
}
/**
* Sets $JAVA_HOME to the specified path.
*/
export function setJavaHome(path: string) {
core.exportVariable('JAVA_HOME', path);
}
+43 -19
View File
@@ -4,13 +4,18 @@ import { checkApiLevel, checkTarget, checkArch, checkDisableAnimations, checkEmu
import { launchEmulator, killEmulator } from './emulator-manager'; import { launchEmulator, killEmulator } from './emulator-manager';
import * as exec from '@actions/exec'; import * as exec from '@actions/exec';
import { parseScript } from './script-parser'; import { parseScript } from './script-parser';
import { getCurrentJavaHome, getJavaHomeV8, setJavaHome } from './java-version-manager';
async function run() { async function run() {
try { try {
// only support running on macOS // only support running on macOS or Linux
if (process.platform !== 'darwin') { if (process.platform !== 'darwin') {
throw new Error('This action is expected to be run within a macOS virtual machine to enable hardware acceleration.'); if (process.platform === 'linux') {
console.warn(
`You're running a Linux VM where hardware acceleration is not available. Please consider using a macOS VM instead to take advantage of native hardware acceleration support provided by HAXM.`
);
} else {
throw new Error('Unsupported virtual machine: please use either macos or ubuntu VM.');
}
} }
// API level of the platform and system image // API level of the platform and system image
@@ -20,7 +25,8 @@ async function run() {
console.log(`API level: ${apiLevel}`); console.log(`API level: ${apiLevel}`);
// target of the system image // target of the system image
const target = core.getInput('target'); const targetInput = core.getInput('target');
const target = targetInput == 'playstore' ? 'google_apis_playstore' : targetInput;
checkTarget(target); checkTarget(target);
console.log(`target: ${target}`); console.log(`target: ${target}`);
@@ -33,6 +39,10 @@ async function run() {
const profile = core.getInput('profile'); const profile = core.getInput('profile');
console.log(`Hardware profile: ${profile}`); console.log(`Hardware profile: ${profile}`);
// custom name used for creating the AVD
const avdName = core.getInput('avd-name');
console.log(`AVD name: ${avdName}`);
// emulator options // emulator options
const emulatorOptions = core.getInput('emulator-options').trim(); const emulatorOptions = core.getInput('emulator-options').trim();
console.log(`emulator options: ${emulatorOptions}`); console.log(`emulator options: ${emulatorOptions}`);
@@ -51,6 +61,27 @@ async function run() {
} }
const emulatorBuild = !emulatorBuildInput ? undefined : emulatorBuildInput; const emulatorBuild = !emulatorBuildInput ? undefined : emulatorBuildInput;
// custom working directory
const workingDirectoryInput = core.getInput('working-directory');
if (workingDirectoryInput) {
console.log(`custom working directory: ${workingDirectoryInput}`);
}
const workingDirectory = !workingDirectoryInput ? undefined : workingDirectoryInput;
// version of NDK to install
const ndkInput = core.getInput('ndk');
if (ndkInput) {
console.log(`version of NDK to install: ${ndkInput}`);
}
const ndkVersion = !ndkInput ? undefined : ndkInput;
// version of CMake to install
const cmakeInput = core.getInput('cmake');
if (cmakeInput) {
console.log(`version of CMake to install: ${cmakeInput}`);
}
const cmakeVersion = !cmakeInput ? undefined : cmakeInput;
// custom script to run // custom script to run
const scriptInput = core.getInput('script', { required: true }); const scriptInput = core.getInput('script', { required: true });
const scripts = parseScript(scriptInput); const scripts = parseScript(scriptInput);
@@ -59,27 +90,20 @@ async function run() {
console.log(`${script}`); console.log(`${script}`);
}); });
// use Java 8 for sdkmanager and avdmanager
const defaultJavaHome = await getCurrentJavaHome();
setJavaHome(await getJavaHomeV8());
// install SDK // install SDK
await installAndroidSdk(apiLevel, target, arch, emulatorBuild); await installAndroidSdk(apiLevel, target, arch, emulatorBuild, ndkVersion, cmakeVersion);
try { // launch an emulator
// launch an emulator await launchEmulator(apiLevel, target, arch, profile, avdName, emulatorOptions, disableAnimations);
await launchEmulator(apiLevel, target, arch, profile, emulatorOptions, disableAnimations);
} catch (error) {
core.setFailed(error.message);
}
// use default JAVA_HOME for running custom script
setJavaHome(defaultJavaHome);
// execute the custom script // execute the custom script
try { try {
// move to custom working directory if set
if (workingDirectory) {
process.chdir(workingDirectory);
}
for (const script of scripts) { for (const script of scripts) {
await exec.exec(`${script}`); await exec.exec(`sh -c \\"${script}"`);
} }
} catch (error) { } catch (error) {
core.setFailed(error.message); core.setFailed(error.message);
+59 -9
View File
@@ -1,25 +1,75 @@
import * as core from '@actions/core';
import * as exec from '@actions/exec'; import * as exec from '@actions/exec';
import * as io from '@actions/io';
import * as tc from '@actions/tool-cache';
import * as fs from 'fs';
const BUILD_TOOLS_VERSION = '29.0.2'; const BUILD_TOOLS_VERSION = '30.0.2';
const CMDLINE_TOOLS_URL_MAC = 'https://dl.google.com/android/repository/commandlinetools-mac-6858069_latest.zip';
const CMDLINE_TOOLS_URL_LINUX = 'https://dl.google.com/android/repository/commandlinetools-linux-6858069_latest.zip';
/** /**
* Installs & updates the Android SDK for the macOS platform, including SDK platform for the chosen API level, latest build tools, platform tools, Android Emulator, * Installs & updates the Android SDK for the macOS platform, including SDK platform for the chosen API level, latest build tools, platform tools, Android Emulator,
* and the system image for the chosen API level, CPU arch, and target. * and the system image for the chosen API level, CPU arch, and target.
*/ */
export async function installAndroidSdk(apiLevel: number, target: string, arch: string, emulatorBuild?: string): Promise<void> { export async function installAndroidSdk(apiLevel: number, target: string, arch: string, emulatorBuild?: string, ndkVersion?: string, cmakeVersion?: string): Promise<void> {
const sdkmangerPath = `${process.env.ANDROID_HOME}/tools/bin/sdkmanager`; const isOnMac = process.platform === 'darwin';
if (!isOnMac) {
await exec.exec(`sh -c \\"sudo chown $USER:$USER ${process.env.ANDROID_HOME} -R`);
}
const cmdlineToolsPath = `${process.env.ANDROID_HOME}/cmdline-tools`;
if (!fs.existsSync(cmdlineToolsPath)) {
console.log('Installing new cmdline-tools.');
const sdkUrl = isOnMac ? CMDLINE_TOOLS_URL_MAC : CMDLINE_TOOLS_URL_LINUX;
// await io.mkdirP(cmdlineToolsPath);
const downloadPath = await tc.downloadTool(sdkUrl);
await tc.extractZip(downloadPath, cmdlineToolsPath);
await io.mv(`${cmdlineToolsPath}/cmdline-tools`, `${cmdlineToolsPath}/latest`);
await exec.exec(`ls -la ${cmdlineToolsPath}`);
// add paths for commandline-tools and platform-tools
core.addPath(`${cmdlineToolsPath}/latest:${cmdlineToolsPath}/latest/bin:${process.env.ANDROID_HOME}/platform-tools`);
await exec.exec(`ls -la ${cmdlineToolsPath}/latest`);
}
// additional permission and license requirements for Linux
const sdkPreviewLicensePath = `${process.env.ANDROID_HOME}/licenses/android-sdk-preview-license`;
if (!isOnMac && !fs.existsSync(sdkPreviewLicensePath)) {
fs.writeFileSync(sdkPreviewLicensePath, '\n84831b9409646a918e30573bab4c9c91346d8abd');
}
// license required for API 30 system images
const sdkArmDbtLicensePath = `${process.env.ANDROID_HOME}/licenses/android-sdk-arm-dbt-license`;
if (apiLevel == 30 && !fs.existsSync(sdkArmDbtLicensePath)) {
fs.writeFileSync(sdkArmDbtLicensePath, '\n859f317696f67ef3d7f30a50a5560e7834b43903');
}
console.log('Installing latest build tools, platform tools, and platform.'); console.log('Installing latest build tools, platform tools, and platform.');
await exec.exec(`sh -c \\"${sdkmangerPath} --install 'build-tools;${BUILD_TOOLS_VERSION}' platform-tools 'platforms;android-${apiLevel}' > /dev/null"`);
await exec.exec(`sh -c \\"sdkmanager --install 'build-tools;${BUILD_TOOLS_VERSION}' platform-tools 'platforms;android-${apiLevel}' > /dev/null"`);
if (emulatorBuild) { if (emulatorBuild) {
console.log(`Installing emulator build ${emulatorBuild}.`); console.log(`Installing emulator build ${emulatorBuild}.`);
await exec.exec(`curl -fo emulator.zip https://dl.google.com/android/repository/emulator-darwin-${emulatorBuild}.zip`); await exec.exec(`curl -fo emulator.zip https://dl.google.com/android/repository/emulator-${isOnMac ? 'darwin' : 'linux'}-${emulatorBuild}.zip`);
await exec.exec(`rm -rf ${process.env.ANDROID_HOME}/emulator`); await io.rmRF(`${process.env.ANDROID_HOME}/emulator`);
await exec.exec(`unzip -q emulator.zip -d ${process.env.ANDROID_HOME}`); await exec.exec(`unzip -q emulator.zip -d ${process.env.ANDROID_HOME}`);
await exec.exec(`rm -f emulator.zip`); await io.rmRF('emulator.zip');
} else { } else {
console.log('Installing latest emulator.'); console.log('Installing latest emulator.');
await exec.exec(`sh -c \\"${sdkmangerPath} --install emulator > /dev/null"`); await exec.exec(`sh -c \\"sdkmanager --install emulator > /dev/null"`);
} }
console.log('Installing system images.'); console.log('Installing system images.');
await exec.exec(`sh -c \\"${sdkmangerPath} --install 'system-images;android-${apiLevel};${target};${arch}' > /dev/null"`); await exec.exec(`sh -c \\"sdkmanager --install 'system-images;android-${apiLevel};${target};${arch}' > /dev/null"`);
if (ndkVersion) {
console.log(`Installing NDK ${ndkVersion}.`);
await exec.exec(`sh -c \\"sdkmanager --install 'ndk;${ndkVersion}' > /dev/null"`);
}
if (cmakeVersion) {
console.log(`Installing CMake ${cmakeVersion}.`);
await exec.exec(`sh -c \\"sdkmanager --install 'cmake;${cmakeVersion}' > /dev/null"`);
}
} }
+6 -6
View File
@@ -3,13 +3,13 @@ apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions' apply plugin: 'kotlin-android-extensions'
android { android {
compileSdkVersion 29 compileSdkVersion 30
buildToolsVersion "29.0.2" buildToolsVersion "30.0.2"
defaultConfig { defaultConfig {
applicationId "com.example.testapp" applicationId "com.example.testapp"
minSdkVersion 21 minSdkVersion 15
targetSdkVersion 29 targetSdkVersion 30
versionCode 1 versionCode 1
versionName "1.0" versionName "1.0"
@@ -28,9 +28,9 @@ dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar']) implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.1.0' implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.core:core-ktx:1.1.0' implementation 'androidx.core:core-ktx:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3' implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12' testImplementation 'junit:junit:4.13'
androidTestImplementation 'androidx.test.ext:junit:1.1.1' androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
} }
+2 -2
View File
@@ -1,13 +1,13 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules. // Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript { buildscript {
ext.kotlin_version = '1.3.61' ext.kotlin_version = '1.4.0'
repositories { repositories {
google() google()
jcenter() jcenter()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:3.5.3' classpath 'com.android.tools.build:gradle:4.0.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong // NOTE: Do not place your application dependencies here; they belong
+1
View File
@@ -1,6 +1,7 @@
org.gradle.parallel=true org.gradle.parallel=true
org.gradle.configureondemand=true org.gradle.configureondemand=true
org.gradle.caching=true org.gradle.caching=true
org.gradle.vfs.watch=true
# Enable Kotlin incremental compilation # Enable Kotlin incremental compilation
kotlin.incremental=true kotlin.incremental=true
+1 -1
View File
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.0.1-all.zip distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip