Skip to content

Commit 2f678a7

Browse files
committed
Merge branch 'master' into release/v2
* master: Prepare for release 2.7.0. Security audit. Support specifying versions of NDK and CMake to install.
2 parents e4eb880 + 33176ea commit 2f678a7

File tree

8 files changed

+84
-18
lines changed

8 files changed

+84
-18
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Change Log
22

3+
## v2.7.0
4+
5+
* Added support for specifying versions of **NDK** and **CMake** to install.
6+
37
## v2.6.2
48

59
* Fixed an issue where the Linux command-line tools binary is used for `macos`.

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,25 @@ jobs:
6767
script: ./gradlew connectedCheck
6868
```
6969

70+
If you need specific versions of **NDK** and **CMake** installed:
71+
72+
```
73+
jobs:
74+
test:
75+
runs-on: macos-latest
76+
steps:
77+
- name: checkout
78+
uses: actions/checkout@v2
79+
80+
- name: run tests
81+
uses: reactivecircus/android-emulator-runner@v2
82+
with:
83+
api-level: 29
84+
ndk: 21.0.6113669
85+
cmake: 3.10.2.4988404
86+
script: ./gradlew connectedCheck
87+
```
88+
7089
## Configurations
7190

7291
| | **Required** | **Default** | **Description** |
@@ -79,6 +98,8 @@ jobs:
7998
| `disable-animations` | Optional | `true` | Whether to disable animations - `true` or `false`. |
8099
| `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. |
81100
| `working-directory` | Optional | `./` | A custom working directory - e.g. `./android` if your root Gradle project is under the `./android` sub-directory within your repository. |
101+
| `ndk` | Optional | N/A | Version of NDK to install - e.g. `21.0.6113669` |
102+
| `cmake` | Optional | N/A | Version of CMake to install - e.g. `3.10.2.4988404` |
82103
| `script` | Required | N/A | Custom script to run - e.g. to run Android instrumented tests on the emulator: `./gradlew connectedCheck` |
83104

84105
Default `emulator-options`: `-no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim`.

action.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,21 @@ inputs:
1515
description: 'CPU architecture of the system image - x86 or x86_64'
1616
default: 'x86'
1717
profile:
18-
description: 'Hardware profile used for creating the AVD - e.g. `Nexus 6`.'
18+
description: 'hardware profile used for creating the AVD - e.g. `Nexus 6`.'
1919
emulator-options:
2020
description: 'command-line options used when launching the emulator - e.g. `-no-window -no-snapshot -camera-back emulated`.'
2121
default: '-no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim'
2222
disable-animations:
2323
description: 'whether to disable animations - true or false'
2424
default: 'true'
2525
emulator-build:
26-
description: 'build number of a specific version of the emulator binary to use e.g. `6061023` for emulator v29.3.0.0.'
26+
description: 'build number of a specific version of the emulator binary to use - e.g. `6061023` for emulator v29.3.0.0.'
27+
working-directory:
28+
description: 'A custom working directory - e.g. `./android` if your root Gradle project is under the `./android` sub-directory within your repository.'
29+
ndk:
30+
description: 'version of NDK to install - e.g. 21.0.6113669'
31+
cmake:
32+
description: 'version of CMake to install - e.g. 3.10.2.4988404'
2733
script:
2834
description: 'custom script to run - e.g. `./gradlew connectedCheck`'
2935
required: true

lib/main.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,18 @@ function run() {
7070
console.log(`custom working directory: ${workingDirectoryInput}`);
7171
}
7272
const workingDirectory = !workingDirectoryInput ? undefined : workingDirectoryInput;
73+
// version of NDK to install
74+
const ndkInput = core.getInput('ndk');
75+
if (ndkInput) {
76+
console.log(`version of NDK to install: ${ndkInput}`);
77+
}
78+
const ndkVersion = !ndkInput ? undefined : ndkInput;
79+
// version of CMake to install
80+
const cmakeInput = core.getInput('cmake');
81+
if (cmakeInput) {
82+
console.log(`version of CMake to install: ${cmakeInput}`);
83+
}
84+
const cmakeVersion = !cmakeInput ? undefined : cmakeInput;
7385
// custom script to run
7486
const scriptInput = core.getInput('script', { required: true });
7587
const scripts = script_parser_1.parseScript(scriptInput);
@@ -78,7 +90,7 @@ function run() {
7890
console.log(`${script}`);
7991
}));
8092
// install SDK
81-
yield sdk_installer_1.installAndroidSdk(apiLevel, target, arch, emulatorBuild);
93+
yield sdk_installer_1.installAndroidSdk(apiLevel, target, arch, emulatorBuild, ndkVersion, cmakeVersion);
8294
// launch an emulator
8395
yield emulator_manager_1.launchEmulator(apiLevel, target, arch, profile, emulatorOptions, disableAnimations);
8496
// execute the custom script

lib/sdk-installer.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const CMDLINE_TOOLS_URL_LINUX = 'https://dl.google.com/android/repository/comman
2424
* Installs & updates the Android SDK for the macOS platform, including SDK platform for the chosen API level, latest build tools, platform tools, Android Emulator,
2525
* and the system image for the chosen API level, CPU arch, and target.
2626
*/
27-
function installAndroidSdk(apiLevel, target, arch, emulatorBuild) {
27+
function installAndroidSdk(apiLevel, target, arch, emulatorBuild, ndkVersion, cmakeVersion) {
2828
return __awaiter(this, void 0, void 0, function* () {
2929
const isOnMac = process.platform === 'darwin';
3030
console.log('Installing new cmdline-tools.');
@@ -55,6 +55,14 @@ function installAndroidSdk(apiLevel, target, arch, emulatorBuild) {
5555
}
5656
console.log('Installing system images.');
5757
yield exec.exec(`sh -c \\"sdkmanager --install 'system-images;android-${apiLevel};${target};${arch}' > /dev/null"`);
58+
if (ndkVersion) {
59+
console.log(`Installing NDK ${ndkVersion}.`);
60+
yield exec.exec(`sh -c \\"sdkmanager --install 'ndk;${ndkVersion}' > /dev/null"`);
61+
}
62+
if (cmakeVersion) {
63+
console.log(`Installing CMake ${cmakeVersion}.`);
64+
yield exec.exec(`sh -c \\"sdkmanager --install 'cmake;${cmakeVersion}' > /dev/null"`);
65+
}
5866
});
5967
}
6068
exports.installAndroidSdk = installAndroidSdk;

package-lock.json

Lines changed: 4 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,20 @@ async function run() {
6363
}
6464
const workingDirectory = !workingDirectoryInput ? undefined : workingDirectoryInput;
6565

66+
// version of NDK to install
67+
const ndkInput = core.getInput('ndk');
68+
if (ndkInput) {
69+
console.log(`version of NDK to install: ${ndkInput}`);
70+
}
71+
const ndkVersion = !ndkInput ? undefined : ndkInput;
72+
73+
// version of CMake to install
74+
const cmakeInput = core.getInput('cmake');
75+
if (cmakeInput) {
76+
console.log(`version of CMake to install: ${cmakeInput}`);
77+
}
78+
const cmakeVersion = !cmakeInput ? undefined : cmakeInput;
79+
6680
// custom script to run
6781
const scriptInput = core.getInput('script', { required: true });
6882
const scripts = parseScript(scriptInput);
@@ -72,7 +86,7 @@ async function run() {
7286
});
7387

7488
// install SDK
75-
await installAndroidSdk(apiLevel, target, arch, emulatorBuild);
89+
await installAndroidSdk(apiLevel, target, arch, emulatorBuild, ndkVersion, cmakeVersion);
7690

7791
// launch an emulator
7892
await launchEmulator(apiLevel, target, arch, profile, emulatorOptions, disableAnimations);

src/sdk-installer.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const CMDLINE_TOOLS_URL_LINUX = 'https://dl.google.com/android/repository/comman
99
* Installs & updates the Android SDK for the macOS platform, including SDK platform for the chosen API level, latest build tools, platform tools, Android Emulator,
1010
* and the system image for the chosen API level, CPU arch, and target.
1111
*/
12-
export async function installAndroidSdk(apiLevel: number, target: string, arch: string, emulatorBuild?: string): Promise<void> {
12+
export async function installAndroidSdk(apiLevel: number, target: string, arch: string, emulatorBuild?: string, ndkVersion?: string, cmakeVersion?: string): Promise<void> {
1313
const isOnMac = process.platform === 'darwin';
1414
console.log('Installing new cmdline-tools.');
1515
const sdkUrl = isOnMac ? CMDLINE_TOOLS_URL_MAC : CMDLINE_TOOLS_URL_LINUX;
@@ -42,4 +42,13 @@ export async function installAndroidSdk(apiLevel: number, target: string, arch:
4242
}
4343
console.log('Installing system images.');
4444
await exec.exec(`sh -c \\"sdkmanager --install 'system-images;android-${apiLevel};${target};${arch}' > /dev/null"`);
45+
46+
if (ndkVersion) {
47+
console.log(`Installing NDK ${ndkVersion}.`);
48+
await exec.exec(`sh -c \\"sdkmanager --install 'ndk;${ndkVersion}' > /dev/null"`);
49+
}
50+
if (cmakeVersion) {
51+
console.log(`Installing CMake ${cmakeVersion}.`);
52+
await exec.exec(`sh -c \\"sdkmanager --install 'cmake;${cmakeVersion}' > /dev/null"`);
53+
}
4554
}

0 commit comments

Comments
 (0)