mirror of
https://github.com/reactivecircus/android-emulator-runner.git
synced 2026-08-31 17:49:33 +00:00
Support specifying versions of NDK and CMake to install.
This commit is contained in:
@@ -67,6 +67,25 @@ jobs:
|
||||
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
|
||||
|
||||
| | **Required** | **Default** | **Description** |
|
||||
@@ -79,6 +98,8 @@ jobs:
|
||||
| `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. |
|
||||
| `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` |
|
||||
|
||||
Default `emulator-options`: `-no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim`.
|
||||
|
||||
+8
-2
@@ -15,7 +15,7 @@ inputs:
|
||||
description: 'CPU architecture of the system image - x86 or x86_64'
|
||||
default: 'x86'
|
||||
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`.'
|
||||
emulator-options:
|
||||
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'
|
||||
@@ -23,7 +23,13 @@ inputs:
|
||||
description: 'whether to disable animations - true or false'
|
||||
default: 'true'
|
||||
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:
|
||||
description: 'custom script to run - e.g. `./gradlew connectedCheck`'
|
||||
required: true
|
||||
|
||||
+13
-1
@@ -70,6 +70,18 @@ function run() {
|
||||
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
|
||||
const scriptInput = core.getInput('script', { required: true });
|
||||
const scripts = script_parser_1.parseScript(scriptInput);
|
||||
@@ -78,7 +90,7 @@ function run() {
|
||||
console.log(`${script}`);
|
||||
}));
|
||||
// install SDK
|
||||
yield sdk_installer_1.installAndroidSdk(apiLevel, target, arch, emulatorBuild);
|
||||
yield sdk_installer_1.installAndroidSdk(apiLevel, target, arch, emulatorBuild, ndkVersion, cmakeVersion);
|
||||
// launch an emulator
|
||||
yield emulator_manager_1.launchEmulator(apiLevel, target, arch, profile, emulatorOptions, disableAnimations);
|
||||
// execute the custom script
|
||||
|
||||
@@ -24,7 +24,7 @@ const CMDLINE_TOOLS_URL_LINUX = 'https://dl.google.com/android/repository/comman
|
||||
* 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.
|
||||
*/
|
||||
function installAndroidSdk(apiLevel, target, arch, emulatorBuild) {
|
||||
function installAndroidSdk(apiLevel, target, arch, emulatorBuild, ndkVersion, cmakeVersion) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const isOnMac = process.platform === 'darwin';
|
||||
console.log('Installing new cmdline-tools.');
|
||||
@@ -55,6 +55,14 @@ function installAndroidSdk(apiLevel, target, arch, emulatorBuild) {
|
||||
}
|
||||
console.log('Installing system images.');
|
||||
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;
|
||||
|
||||
+15
-1
@@ -63,6 +63,20 @@ async function run() {
|
||||
}
|
||||
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
|
||||
const scriptInput = core.getInput('script', { required: true });
|
||||
const scripts = parseScript(scriptInput);
|
||||
@@ -72,7 +86,7 @@ async function run() {
|
||||
});
|
||||
|
||||
// install SDK
|
||||
await installAndroidSdk(apiLevel, target, arch, emulatorBuild);
|
||||
await installAndroidSdk(apiLevel, target, arch, emulatorBuild, ndkVersion, cmakeVersion);
|
||||
|
||||
// launch an emulator
|
||||
await launchEmulator(apiLevel, target, arch, profile, emulatorOptions, disableAnimations);
|
||||
|
||||
+10
-1
@@ -9,7 +9,7 @@ const CMDLINE_TOOLS_URL_LINUX = 'https://dl.google.com/android/repository/comman
|
||||
* 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.
|
||||
*/
|
||||
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 isOnMac = process.platform === 'darwin';
|
||||
console.log('Installing new cmdline-tools.');
|
||||
const sdkUrl = isOnMac ? CMDLINE_TOOLS_URL_MAC : CMDLINE_TOOLS_URL_LINUX;
|
||||
@@ -42,4 +42,13 @@ export async function installAndroidSdk(apiLevel: number, target: string, arch:
|
||||
}
|
||||
console.log('Installing system images.');
|
||||
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"`);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user