Skip to content

Commit 02cf805

Browse files
committed
Merge branch 'main' into release/v2
* main: Prepare for release 2.14.0. Support specifying SD card path or size. Update npm packages. Replace usages of deprecated ANDROID_HOME with ANDROID_ROOT_SDK. Bump build tools to 30.0.3. Update test-fixture dependencies. Update Compose Samples URL
2 parents e08f702 + 045b7d8 commit 02cf805

25 files changed

+5282
-2755
lines changed

.github/workflows/workflow.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ jobs:
6868
target: ${{ matrix.target }}
6969
arch: x86
7070
profile: Nexus 6
71+
sdcard-path-or-size: 100M
7172
avd-name: test
7273
emulator-options: -no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim -camera-back none
7374
disable-animations: true

CHANGELOG.md

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

3+
## v2.14.0
4+
5+
* Support specifying SD card path or size via `sdcard-path-or-size`.
6+
* Update npm packages.
7+
* Remove usages of deprecated `$ANDROID_HOME`.
8+
39
## v2.13.0
410

511
* Updated to SDK command-line tools `3.0`.

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ jobs:
9292
| `target` | Optional | `default` | Target of the system image - `default`, `google_apis` or `playstore`. |
9393
| `arch` | Optional | `x86` | CPU architecture of the system image - `x86` or `x86_64`. Note that `x86_64` image is only available for API 21+. |
9494
| `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". |
95+
| `sdcard-path-or-size` | Optional | N/A | Path to the SD card image for this AVD or the size of a new SD card image to create for this AVD, in KB or MB, denoted with K or M. - e.g. `path/to/sdcard`, or `1000M`. |
9596
| `avd-name` | Optional | `test` | Custom AVD name used for creating the Android Virtual Device. |
9697
| `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`. |
9798
| `disable-animations` | Optional | `true` | Whether to disable animations - `true` or `false`. |
@@ -122,7 +123,7 @@ These are some of the open-source projects using (or used) **Android Emulator Ru
122123
- [natario1/Transcoder](https://github.com/natario1/Transcoder/tree/master/.github/workflows)
123124
- [chrisbanes/insetter](https://github.com/chrisbanes/insetter/tree/main/.github/workflows)
124125
- [slackhq/keeper](https://github.com/slackhq/keeper/tree/main/.github/workflows)
125-
- [android/compose-samples](https://github.com/android/compose-samples/blob/master/.github/workflows/ci.yaml)
126+
- [android/compose-samples](https://github.com/android/compose-samples/tree/main/.github/workflows)
126127
- [ReactiveCircus/streamlined](https://github.com/ReactiveCircus/streamlined/tree/main/.github/workflows)
127128
- [ReactiveCircus/FlowBinding](https://github.com/ReactiveCircus/FlowBinding)
128129
- [JakeWharton/RxBinding](https://github.com/JakeWharton/RxBinding/tree/master/.github/workflows)

action.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ inputs:
1616
default: 'x86'
1717
profile:
1818
description: 'hardware profile used for creating the AVD - e.g. `Nexus 6`'
19+
sdcard-path-or-size:
20+
description: 'path to the SD card image for this AVD or the size of a new SD card image to create for this AVD, in KB or MB, denoted with K or M. - e.g. `path/to/sdcard`, or `1000M`'
1921
avd-name:
2022
description: 'custom AVD name used for creating the Android Virtual Device'
2123
default: 'test'

lib/emulator-manager.js

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,24 +34,20 @@ const EMULATOR_BOOT_TIMEOUT_SECONDS = 600;
3434
/**
3535
* Creates and launches a new AVD instance with the specified configurations.
3636
*/
37-
function launchEmulator(apiLevel, target, arch, profile, avdName, emulatorOptions, disableAnimations) {
37+
function launchEmulator(apiLevel, target, arch, profile, sdcardPathOrSize, avdName, emulatorOptions, disableAnimations) {
3838
return __awaiter(this, void 0, void 0, function* () {
3939
// create a new AVD
40-
if (profile.trim() !== '') {
41-
console.log(`Creating AVD with custom profile ${profile}`);
42-
yield exec.exec(`avdmanager create avd --force -n "${avdName}" --abi "${target}/${arch}" --package "system-images;android-${apiLevel};${target};${arch}" --device "${profile}"`);
43-
}
44-
else {
45-
console.log(`Creating AVD without custom profile.`);
46-
yield exec.exec(`sh -c \\"echo no | avdmanager create avd --force -n "${avdName}" --abi '${target}/${arch}' --package 'system-images;android-${apiLevel};${target};${arch}'"`);
47-
}
40+
const profileOption = profile.trim() !== '' ? `--device "${profile}"` : '';
41+
const sdcardPathOrSizeOption = sdcardPathOrSize.trim() !== '' ? `--sdcard "${sdcardPathOrSize}"` : '';
42+
console.log(`Creating AVD.`);
43+
yield exec.exec(`avdmanager create avd --force -n "${avdName}" --abi "${target}/${arch}" --package "system-images;android-${apiLevel};${target};${arch}" ${profileOption} ${sdcardPathOrSizeOption}`);
4844
// start emulator
4945
console.log('Starting emulator.');
5046
// turn off hardware acceleration on Linux
5147
if (process.platform === 'linux') {
5248
emulatorOptions += ' -accel off';
5349
}
54-
yield exec.exec(`sh -c \\"${process.env.ANDROID_HOME}/emulator/emulator -avd "${avdName}" ${emulatorOptions} &"`, [], {
50+
yield exec.exec(`sh -c \\"${process.env.ANDROID_SDK_ROOT}/emulator/emulator -avd "${avdName}" ${emulatorOptions} &"`, [], {
5551
listeners: {
5652
stderr: (data) => {
5753
if (data.toString().includes('invalid command-line parameter')) {

lib/main.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ function run() {
6363
// Hardware profile used for creating the AVD
6464
const profile = core.getInput('profile');
6565
console.log(`Hardware profile: ${profile}`);
66+
// SD card path or size used for creating the AVD
67+
const sdcardPathOrSize = core.getInput('sdcard-path-or-size');
68+
console.log(`SD card path or size: ${sdcardPathOrSize}`);
6669
// custom name used for creating the AVD
6770
const avdName = core.getInput('avd-name');
6871
console.log(`AVD name: ${avdName}`);
@@ -109,7 +112,7 @@ function run() {
109112
// install SDK
110113
yield sdk_installer_1.installAndroidSdk(apiLevel, target, arch, emulatorBuild, ndkVersion, cmakeVersion);
111114
// launch an emulator
112-
yield emulator_manager_1.launchEmulator(apiLevel, target, arch, profile, avdName, emulatorOptions, disableAnimations);
115+
yield emulator_manager_1.launchEmulator(apiLevel, target, arch, profile, sdcardPathOrSize, avdName, emulatorOptions, disableAnimations);
113116
// execute the custom script
114117
try {
115118
// move to custom working directory if set

lib/sdk-installer.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const exec = __importStar(require("@actions/exec"));
3434
const io = __importStar(require("@actions/io"));
3535
const tc = __importStar(require("@actions/tool-cache"));
3636
const fs = __importStar(require("fs"));
37-
const BUILD_TOOLS_VERSION = '30.0.2';
37+
const BUILD_TOOLS_VERSION = '30.0.3';
3838
const CMDLINE_TOOLS_URL_MAC = 'https://dl.google.com/android/repository/commandlinetools-mac-6858069_latest.zip';
3939
const CMDLINE_TOOLS_URL_LINUX = 'https://dl.google.com/android/repository/commandlinetools-linux-6858069_latest.zip';
4040
/**
@@ -45,25 +45,25 @@ function installAndroidSdk(apiLevel, target, arch, emulatorBuild, ndkVersion, cm
4545
return __awaiter(this, void 0, void 0, function* () {
4646
const isOnMac = process.platform === 'darwin';
4747
if (!isOnMac) {
48-
yield exec.exec(`sh -c \\"sudo chown $USER:$USER ${process.env.ANDROID_HOME} -R`);
48+
yield exec.exec(`sh -c \\"sudo chown $USER:$USER ${process.env.ANDROID_SDK_ROOT} -R`);
4949
}
50-
const cmdlineToolsPath = `${process.env.ANDROID_HOME}/cmdline-tools`;
50+
const cmdlineToolsPath = `${process.env.ANDROID_SDK_ROOT}/cmdline-tools`;
5151
if (!fs.existsSync(cmdlineToolsPath)) {
5252
console.log('Installing new cmdline-tools.');
5353
const sdkUrl = isOnMac ? CMDLINE_TOOLS_URL_MAC : CMDLINE_TOOLS_URL_LINUX;
5454
const downloadPath = yield tc.downloadTool(sdkUrl);
5555
yield tc.extractZip(downloadPath, cmdlineToolsPath);
5656
yield io.mv(`${cmdlineToolsPath}/cmdline-tools`, `${cmdlineToolsPath}/latest`);
5757
// add paths for commandline-tools and platform-tools
58-
core.addPath(`${cmdlineToolsPath}/latest:${cmdlineToolsPath}/latest/bin:${process.env.ANDROID_HOME}/platform-tools`);
58+
core.addPath(`${cmdlineToolsPath}/latest:${cmdlineToolsPath}/latest/bin:${process.env.ANDROID_SDK_ROOT}/platform-tools`);
5959
}
6060
// additional permission and license requirements for Linux
61-
const sdkPreviewLicensePath = `${process.env.ANDROID_HOME}/licenses/android-sdk-preview-license`;
61+
const sdkPreviewLicensePath = `${process.env.ANDROID_SDK_ROOT}/licenses/android-sdk-preview-license`;
6262
if (!isOnMac && !fs.existsSync(sdkPreviewLicensePath)) {
6363
fs.writeFileSync(sdkPreviewLicensePath, '\n84831b9409646a918e30573bab4c9c91346d8abd');
6464
}
6565
// license required for API 30 system images
66-
const sdkArmDbtLicensePath = `${process.env.ANDROID_HOME}/licenses/android-sdk-arm-dbt-license`;
66+
const sdkArmDbtLicensePath = `${process.env.ANDROID_SDK_ROOT}/licenses/android-sdk-arm-dbt-license`;
6767
if (apiLevel == 30 && !fs.existsSync(sdkArmDbtLicensePath)) {
6868
fs.writeFileSync(sdkArmDbtLicensePath, '\n859f317696f67ef3d7f30a50a5560e7834b43903');
6969
}
@@ -72,8 +72,8 @@ function installAndroidSdk(apiLevel, target, arch, emulatorBuild, ndkVersion, cm
7272
if (emulatorBuild) {
7373
console.log(`Installing emulator build ${emulatorBuild}.`);
7474
yield exec.exec(`curl -fo emulator.zip https://dl.google.com/android/repository/emulator-${isOnMac ? 'darwin' : 'linux'}-${emulatorBuild}.zip`);
75-
yield io.rmRF(`${process.env.ANDROID_HOME}/emulator`);
76-
yield exec.exec(`unzip -q emulator.zip -d ${process.env.ANDROID_HOME}`);
75+
yield io.rmRF(`${process.env.ANDROID_SDK_ROOT}/emulator`);
76+
yield exec.exec(`unzip -q emulator.zip -d ${process.env.ANDROID_SDK_ROOT}`);
7777
yield io.rmRF('emulator.zip');
7878
}
7979
else {

node_modules/@actions/http-client/RELEASES.md

Lines changed: 7 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/@actions/http-client/index.d.ts

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

node_modules/@actions/http-client/index.js

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

node_modules/@actions/http-client/interfaces.d.ts

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/@actions/http-client/package.json

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

node_modules/@actions/http-client/proxy.d.ts

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

node_modules/@actions/http-client/proxy.js

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/@actions/tool-cache/LICENSE.md

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

0 commit comments

Comments
 (0)