mirror of
https://github.com/reactivecircus/android-emulator-runner.git
synced 2026-08-31 17:49:33 +00:00
Update to Node 24. (#466)
This commit is contained in:
@@ -9,5 +9,5 @@ jobs:
|
|||||||
validate-typings:
|
validate-typings:
|
||||||
runs-on: "ubuntu-latest"
|
runs-on: "ubuntu-latest"
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v6
|
||||||
- uses: krzema12/github-actions-typing@v0
|
- uses: krzema12/github-actions-typing@v2
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: checkout
|
- name: checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v6
|
||||||
|
|
||||||
- name: build, test and lint
|
- name: build, test and lint
|
||||||
run: |
|
run: |
|
||||||
@@ -56,12 +56,12 @@ jobs:
|
|||||||
npm run lint
|
npm run lint
|
||||||
npm test
|
npm test
|
||||||
|
|
||||||
- uses: actions/setup-java@v4
|
- uses: actions/setup-java@v5
|
||||||
with:
|
with:
|
||||||
distribution: 'zulu'
|
distribution: 'zulu'
|
||||||
java-version: 25
|
java-version: 25
|
||||||
|
|
||||||
- uses: actions/cache@v4
|
- uses: actions/cache@v5
|
||||||
id: avd-cache
|
id: avd-cache
|
||||||
with:
|
with:
|
||||||
path: |
|
path: |
|
||||||
@@ -70,7 +70,7 @@ jobs:
|
|||||||
~/.android/debug.keystore
|
~/.android/debug.keystore
|
||||||
key: avd-${{ matrix.api-level }}-${{ matrix.os }}-${{ matrix.target }}-${{ matrix.arch }}
|
key: avd-${{ matrix.api-level }}-${{ matrix.os }}-${{ matrix.target }}-${{ matrix.arch }}
|
||||||
|
|
||||||
- uses: gradle/actions/setup-gradle@v4
|
- uses: gradle/actions/setup-gradle@v5
|
||||||
|
|
||||||
- name: assemble tests
|
- name: assemble tests
|
||||||
working-directory: test-fixture
|
working-directory: test-fixture
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: checkout
|
- name: checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v6
|
||||||
|
|
||||||
- name: build, test and lint
|
- name: build, test and lint
|
||||||
run: |
|
run: |
|
||||||
@@ -50,12 +50,12 @@ jobs:
|
|||||||
npm run lint
|
npm run lint
|
||||||
npm test
|
npm test
|
||||||
|
|
||||||
- uses: actions/setup-java@v4
|
- uses: actions/setup-java@v5
|
||||||
with:
|
with:
|
||||||
distribution: 'zulu'
|
distribution: 'zulu'
|
||||||
java-version: 25
|
java-version: 25
|
||||||
|
|
||||||
- uses: gradle/actions/setup-gradle@v4
|
- uses: gradle/actions/setup-gradle@v5
|
||||||
|
|
||||||
- name: enable KVM for linux runners
|
- name: enable KVM for linux runners
|
||||||
if: runner.os == 'Linux'
|
if: runner.os == 'Linux'
|
||||||
|
|||||||
@@ -2,6 +2,9 @@
|
|||||||
|
|
||||||
## Unreleased
|
## Unreleased
|
||||||
|
|
||||||
|
* Run action on Node 24. - [#466](https://github.com/ReactiveCircus/android-emulator-runner/pull/466)
|
||||||
|
* Update Node and npm packages. - [#466](https://github.com/ReactiveCircus/android-emulator-runner/pull/466)
|
||||||
|
|
||||||
## v2.36.0
|
## v2.36.0
|
||||||
|
|
||||||
* Remove `--abi` option to better support 16-KB-based system images (#456).
|
* Remove `--abi` option to better support 16-KB-based system images (#456).
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: checkout
|
- name: checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v6
|
||||||
|
|
||||||
- name: Enable KVM
|
- name: Enable KVM
|
||||||
run: |
|
run: |
|
||||||
@@ -76,7 +76,7 @@ jobs:
|
|||||||
target: [default, google_apis]
|
target: [default, google_apis]
|
||||||
steps:
|
steps:
|
||||||
- name: checkout
|
- name: checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v6
|
||||||
|
|
||||||
- name: Enable KVM
|
- name: Enable KVM
|
||||||
run: |
|
run: |
|
||||||
@@ -102,7 +102,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: checkout
|
- name: checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v6
|
||||||
|
|
||||||
- name: Enable KVM
|
- name: Enable KVM
|
||||||
run: |
|
run: |
|
||||||
@@ -127,7 +127,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: checkout
|
- name: checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v6
|
||||||
|
|
||||||
- name: Enable KVM
|
- name: Enable KVM
|
||||||
run: |
|
run: |
|
||||||
@@ -146,8 +146,8 @@ jobs:
|
|||||||
|
|
||||||
We can significantly reduce emulator startup time by setting up AVD snapshot caching:
|
We can significantly reduce emulator startup time by setting up AVD snapshot caching:
|
||||||
|
|
||||||
1. add a `gradle/actions/setup-gradle@v4` step for caching Gradle, more details see [#229](https://github.com/ReactiveCircus/android-emulator-runner/issues/229)
|
1. add a `gradle/actions/setup-gradle@v5` step for caching Gradle, more details see [#229](https://github.com/ReactiveCircus/android-emulator-runner/issues/229)
|
||||||
2. add an `actions/cache@v4` step for caching the `avd`
|
2. add an `actions/cache@v5` step for caching the `avd`
|
||||||
3. add a `reactivecircus/android-emulator-runner@v2` step to generate a clean snapshot - specify `emulator-options` without `no-snapshot`
|
3. add a `reactivecircus/android-emulator-runner@v2` step to generate a clean snapshot - specify `emulator-options` without `no-snapshot`
|
||||||
4. add another `reactivecircus/android-emulator-runner@v2` step to run your tests using existing AVD / snapshot - specify `emulator-options` with `no-snapshot-save`
|
4. add another `reactivecircus/android-emulator-runner@v2` step to run your tests using existing AVD / snapshot - specify `emulator-options` with `no-snapshot-save`
|
||||||
|
|
||||||
@@ -160,7 +160,7 @@ jobs:
|
|||||||
api-level: [21, 23, 29]
|
api-level: [21, 23, 29]
|
||||||
steps:
|
steps:
|
||||||
- name: checkout
|
- name: checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v6
|
||||||
|
|
||||||
- name: Enable KVM
|
- name: Enable KVM
|
||||||
run: |
|
run: |
|
||||||
@@ -169,10 +169,10 @@ jobs:
|
|||||||
sudo udevadm trigger --name-match=kvm
|
sudo udevadm trigger --name-match=kvm
|
||||||
|
|
||||||
- name: Gradle cache
|
- name: Gradle cache
|
||||||
uses: gradle/actions/setup-gradle@v3
|
uses: gradle/actions/setup-gradle@v5
|
||||||
|
|
||||||
- name: AVD cache
|
- name: AVD cache
|
||||||
uses: actions/cache@v4
|
uses: actions/cache@v5
|
||||||
id: avd-cache
|
id: avd-cache
|
||||||
with:
|
with:
|
||||||
path: |
|
path: |
|
||||||
|
|||||||
+1
-1
@@ -74,5 +74,5 @@ inputs:
|
|||||||
pre-emulator-launch-script:
|
pre-emulator-launch-script:
|
||||||
description: 'custom script to run after creating the AVD and before launching the emulator - e.g. `./adjust-emulator-configs.sh`'
|
description: 'custom script to run after creating the AVD and before launching the emulator - e.g. `./adjust-emulator-configs.sh`'
|
||||||
runs:
|
runs:
|
||||||
using: 'node20'
|
using: 'node24'
|
||||||
main: 'lib/main.js'
|
main: 'lib/main.js'
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.getChannelId = void 0;
|
exports.getChannelId = getChannelId;
|
||||||
function getChannelId(channelName) {
|
function getChannelId(channelName) {
|
||||||
if (channelName === 'stable') {
|
if (channelName === 'stable') {
|
||||||
return 0;
|
return 0;
|
||||||
@@ -18,4 +18,3 @@ function getChannelId(channelName) {
|
|||||||
throw new Error(`Unexpected channel name: '${channelName}'.`);
|
throw new Error(`Unexpected channel name: '${channelName}'.`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.getChannelId = getChannelId;
|
|
||||||
|
|||||||
+35
-45
@@ -15,31 +15,33 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|||||||
}) : function(o, v) {
|
}) : function(o, v) {
|
||||||
o["default"] = v;
|
o["default"] = v;
|
||||||
});
|
});
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
var __importStar = (this && this.__importStar) || (function () {
|
||||||
|
var ownKeys = function(o) {
|
||||||
|
ownKeys = Object.getOwnPropertyNames || function (o) {
|
||||||
|
var ar = [];
|
||||||
|
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
||||||
|
return ar;
|
||||||
|
};
|
||||||
|
return ownKeys(o);
|
||||||
|
};
|
||||||
|
return 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 (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
||||||
__setModuleDefault(result, 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 = exports.createAvd = void 0;
|
exports.createAvd = createAvd;
|
||||||
|
exports.launchEmulator = launchEmulator;
|
||||||
|
exports.killEmulator = killEmulator;
|
||||||
const exec = __importStar(require("@actions/exec"));
|
const exec = __importStar(require("@actions/exec"));
|
||||||
const fs = __importStar(require("fs"));
|
const fs = __importStar(require("fs"));
|
||||||
/**
|
/**
|
||||||
* Creates a new AVD instance with the specified configurations.
|
* Creates a new AVD instance with the specified configurations.
|
||||||
*/
|
*/
|
||||||
function createAvd(arch, avdName, cores, diskSize, enableHardwareKeyboard, forceAvdCreation, heapSize, profile, ramSize, sdcardPathOrSize, systemImageApiLevel, target) {
|
async function createAvd(arch, avdName, cores, diskSize, enableHardwareKeyboard, forceAvdCreation, heapSize, profile, ramSize, sdcardPathOrSize, systemImageApiLevel, target) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
try {
|
try {
|
||||||
console.log(`::group::Create AVD`);
|
console.log(`::group::Create AVD`);
|
||||||
// create a new AVD if AVD directory does not already exist or forceAvdCreation is true
|
// create a new AVD if AVD directory does not already exist or forceAvdCreation is true
|
||||||
@@ -48,7 +50,7 @@ function createAvd(arch, avdName, cores, diskSize, enableHardwareKeyboard, force
|
|||||||
const profileOption = profile.trim() !== '' ? `--device '${profile}'` : '';
|
const profileOption = profile.trim() !== '' ? `--device '${profile}'` : '';
|
||||||
const sdcardPathOrSizeOption = sdcardPathOrSize.trim() !== '' ? `--sdcard '${sdcardPathOrSize}'` : '';
|
const sdcardPathOrSizeOption = sdcardPathOrSize.trim() !== '' ? `--sdcard '${sdcardPathOrSize}'` : '';
|
||||||
console.log(`Creating AVD.`);
|
console.log(`Creating AVD.`);
|
||||||
yield exec.exec(`sh -c \\"echo no | avdmanager create avd --force -n "${avdName}" --package 'system-images;android-${systemImageApiLevel};${target};${arch}' ${profileOption} ${sdcardPathOrSizeOption}"`);
|
await exec.exec(`sh -c \\"echo no | avdmanager create avd --force -n "${avdName}" --package 'system-images;android-${systemImageApiLevel};${target};${arch}' ${profileOption} ${sdcardPathOrSizeOption}"`);
|
||||||
}
|
}
|
||||||
if (cores || ramSize || heapSize || enableHardwareKeyboard || diskSize) {
|
if (cores || ramSize || heapSize || enableHardwareKeyboard || diskSize) {
|
||||||
const configEntries = [];
|
const configEntries = [];
|
||||||
@@ -69,21 +71,18 @@ function createAvd(arch, avdName, cores, diskSize, enableHardwareKeyboard, force
|
|||||||
}
|
}
|
||||||
if (configEntries.length > 0) {
|
if (configEntries.length > 0) {
|
||||||
const configContent = configEntries.join('\\n') + '\\n';
|
const configContent = configEntries.join('\\n') + '\\n';
|
||||||
yield exec.exec(`sh -c \\"printf '${configContent}' >> ${process.env.ANDROID_AVD_HOME}/"${avdName}".avd"/config.ini"`);
|
await exec.exec(`sh -c \\"printf '${configContent}' >> ${process.env.ANDROID_AVD_HOME}/"${avdName}".avd"/config.ini"`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
console.log(`::endgroup::`);
|
console.log(`::endgroup::`);
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
}
|
||||||
exports.createAvd = createAvd;
|
|
||||||
/**
|
/**
|
||||||
* Launches an existing AVD instance with the specified configurations.
|
* Launches an existing AVD instance with the specified configurations.
|
||||||
*/
|
*/
|
||||||
function launchEmulator(avdName, disableAnimations, disableLinuxHardwareAcceleration, disableSpellChecker, emulatorBootTimeout, emulatorOptions, enableHardwareKeyboard, port) {
|
async function launchEmulator(avdName, disableAnimations, disableLinuxHardwareAcceleration, disableSpellChecker, emulatorBootTimeout, emulatorOptions, enableHardwareKeyboard, port) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
try {
|
try {
|
||||||
console.log(`::group::Launch Emulator`);
|
console.log(`::group::Launch Emulator`);
|
||||||
// turn off hardware acceleration on Linux
|
// turn off hardware acceleration on Linux
|
||||||
@@ -93,7 +92,7 @@ function launchEmulator(avdName, disableAnimations, disableLinuxHardwareAccelera
|
|||||||
}
|
}
|
||||||
// start emulator
|
// start emulator
|
||||||
console.log('Starting emulator.');
|
console.log('Starting emulator.');
|
||||||
yield exec.exec(`sh -c \\"${process.env.ANDROID_HOME}/emulator/emulator -port ${port} -avd "${avdName}" ${emulatorOptions} &"`, [], {
|
await exec.exec(`sh -c \\"${process.env.ANDROID_HOME}/emulator/emulator -port ${port} -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')) {
|
||||||
@@ -103,35 +102,32 @@ function launchEmulator(avdName, disableAnimations, disableLinuxHardwareAccelera
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
// wait for emulator to complete booting
|
// wait for emulator to complete booting
|
||||||
yield waitForDevice(port, emulatorBootTimeout);
|
await waitForDevice(port, emulatorBootTimeout);
|
||||||
yield adb(port, `shell input keyevent 82`);
|
await adb(port, `shell input keyevent 82`);
|
||||||
if (disableAnimations) {
|
if (disableAnimations) {
|
||||||
console.log('Disabling animations.');
|
console.log('Disabling animations.');
|
||||||
yield adb(port, `shell settings put global window_animation_scale 0.0`);
|
await adb(port, `shell settings put global window_animation_scale 0.0`);
|
||||||
yield adb(port, `shell settings put global transition_animation_scale 0.0`);
|
await adb(port, `shell settings put global transition_animation_scale 0.0`);
|
||||||
yield adb(port, `shell settings put global animator_duration_scale 0.0`);
|
await adb(port, `shell settings put global animator_duration_scale 0.0`);
|
||||||
}
|
}
|
||||||
if (disableSpellChecker) {
|
if (disableSpellChecker) {
|
||||||
yield adb(port, `shell settings put secure spell_checker_enabled 0`);
|
await adb(port, `shell settings put secure spell_checker_enabled 0`);
|
||||||
}
|
}
|
||||||
if (enableHardwareKeyboard) {
|
if (enableHardwareKeyboard) {
|
||||||
yield adb(port, `shell settings put secure show_ime_with_hard_keyboard 0`);
|
await adb(port, `shell settings put secure show_ime_with_hard_keyboard 0`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
console.log(`::endgroup::`);
|
console.log(`::endgroup::`);
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
}
|
||||||
exports.launchEmulator = launchEmulator;
|
|
||||||
/**
|
/**
|
||||||
* Kills the running emulator on the default port.
|
* Kills the running emulator on the default port.
|
||||||
*/
|
*/
|
||||||
function killEmulator(port) {
|
async function killEmulator(port) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
try {
|
try {
|
||||||
console.log(`::group::Terminate Emulator`);
|
console.log(`::group::Terminate Emulator`);
|
||||||
yield adb(port, `emu kill`);
|
await adb(port, `emu kill`);
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
console.log(error instanceof Error ? error.message : error);
|
console.log(error instanceof Error ? error.message : error);
|
||||||
@@ -139,19 +135,14 @@ function killEmulator(port) {
|
|||||||
finally {
|
finally {
|
||||||
console.log(`::endgroup::`);
|
console.log(`::endgroup::`);
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
}
|
||||||
exports.killEmulator = killEmulator;
|
async function adb(port, command) {
|
||||||
function adb(port, command) {
|
return await exec.exec(`adb -s emulator-${port} ${command}`);
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
return yield exec.exec(`adb -s emulator-${port} ${command}`);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Wait for emulator to boot.
|
* Wait for emulator to boot.
|
||||||
*/
|
*/
|
||||||
function waitForDevice(port, emulatorBootTimeout) {
|
async function waitForDevice(port, emulatorBootTimeout) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
let booted = false;
|
let booted = false;
|
||||||
let attempts = 0;
|
let attempts = 0;
|
||||||
const retryInterval = 2; // retry every 2 seconds
|
const retryInterval = 2; // retry every 2 seconds
|
||||||
@@ -159,7 +150,7 @@ function waitForDevice(port, emulatorBootTimeout) {
|
|||||||
while (!booted) {
|
while (!booted) {
|
||||||
try {
|
try {
|
||||||
let result = '';
|
let result = '';
|
||||||
yield exec.exec(`adb -s emulator-${port} shell getprop sys.boot_completed`, [], {
|
await exec.exec(`adb -s emulator-${port} shell getprop sys.boot_completed`, [], {
|
||||||
listeners: {
|
listeners: {
|
||||||
stdout: (data) => {
|
stdout: (data) => {
|
||||||
result += data.toString();
|
result += data.toString();
|
||||||
@@ -176,14 +167,13 @@ function waitForDevice(port, emulatorBootTimeout) {
|
|||||||
console.warn(error instanceof Error ? error.message : error);
|
console.warn(error instanceof Error ? error.message : error);
|
||||||
}
|
}
|
||||||
if (attempts < maxAttempts) {
|
if (attempts < maxAttempts) {
|
||||||
yield delay(retryInterval * 1000);
|
await delay(retryInterval * 1000);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
throw new Error(`Timeout waiting for emulator to boot.`);
|
throw new Error(`Timeout waiting for emulator to boot.`);
|
||||||
}
|
}
|
||||||
attempts++;
|
attempts++;
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
}
|
||||||
function delay(ms) {
|
function delay(ms) {
|
||||||
return new Promise((resolve) => setTimeout(resolve, ms));
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
||||||
|
|||||||
+12
-12
@@ -1,6 +1,17 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.checkDiskSize = exports.checkEmulatorBuild = exports.checkEnableHardwareKeyboard = exports.checkDisableLinuxHardwareAcceleration = exports.checkDisableSpellchecker = exports.checkDisableAnimations = exports.checkPort = exports.checkForceAvdCreation = exports.checkChannel = exports.checkArch = exports.playstoreTargetSubstitution = exports.MAX_PORT = exports.MIN_PORT = exports.VALID_CHANNELS = exports.VALID_ARCHS = exports.MIN_API_LEVEL = void 0;
|
exports.MAX_PORT = exports.MIN_PORT = exports.VALID_CHANNELS = exports.VALID_ARCHS = exports.MIN_API_LEVEL = void 0;
|
||||||
|
exports.playstoreTargetSubstitution = playstoreTargetSubstitution;
|
||||||
|
exports.checkArch = checkArch;
|
||||||
|
exports.checkChannel = checkChannel;
|
||||||
|
exports.checkForceAvdCreation = checkForceAvdCreation;
|
||||||
|
exports.checkPort = checkPort;
|
||||||
|
exports.checkDisableAnimations = checkDisableAnimations;
|
||||||
|
exports.checkDisableSpellchecker = checkDisableSpellchecker;
|
||||||
|
exports.checkDisableLinuxHardwareAcceleration = checkDisableLinuxHardwareAcceleration;
|
||||||
|
exports.checkEnableHardwareKeyboard = checkEnableHardwareKeyboard;
|
||||||
|
exports.checkEmulatorBuild = checkEmulatorBuild;
|
||||||
|
exports.checkDiskSize = checkDiskSize;
|
||||||
exports.MIN_API_LEVEL = 15;
|
exports.MIN_API_LEVEL = 15;
|
||||||
exports.VALID_ARCHS = ['x86', 'x86_64', 'arm64-v8a'];
|
exports.VALID_ARCHS = ['x86', 'x86_64', 'arm64-v8a'];
|
||||||
exports.VALID_CHANNELS = ['stable', 'beta', 'dev', 'canary'];
|
exports.VALID_CHANNELS = ['stable', 'beta', 'dev', 'canary'];
|
||||||
@@ -15,25 +26,21 @@ function playstoreTargetSubstitution(target) {
|
|||||||
return 'google_apis_playstore_ps16k';
|
return 'google_apis_playstore_ps16k';
|
||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
exports.playstoreTargetSubstitution = playstoreTargetSubstitution;
|
|
||||||
function checkArch(arch) {
|
function checkArch(arch) {
|
||||||
if (!exports.VALID_ARCHS.includes(arch)) {
|
if (!exports.VALID_ARCHS.includes(arch)) {
|
||||||
throw new Error(`Value for input.arch '${arch}' is unknown. Supported options: ${exports.VALID_ARCHS}.`);
|
throw new Error(`Value for input.arch '${arch}' is unknown. Supported options: ${exports.VALID_ARCHS}.`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.checkArch = checkArch;
|
|
||||||
function checkChannel(channel) {
|
function checkChannel(channel) {
|
||||||
if (!exports.VALID_CHANNELS.includes(channel)) {
|
if (!exports.VALID_CHANNELS.includes(channel)) {
|
||||||
throw new Error(`Value for input.channel '${channel}' is unknown. Supported options: ${exports.VALID_CHANNELS}.`);
|
throw new Error(`Value for input.channel '${channel}' is unknown. Supported options: ${exports.VALID_CHANNELS}.`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.checkChannel = checkChannel;
|
|
||||||
function checkForceAvdCreation(forceAvdCreation) {
|
function checkForceAvdCreation(forceAvdCreation) {
|
||||||
if (!isValidBoolean(forceAvdCreation)) {
|
if (!isValidBoolean(forceAvdCreation)) {
|
||||||
throw new Error(`Input for input.force-avd-creation should be either 'true' or 'false'.`);
|
throw new Error(`Input for input.force-avd-creation should be either 'true' or 'false'.`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.checkForceAvdCreation = checkForceAvdCreation;
|
|
||||||
function checkPort(port) {
|
function checkPort(port) {
|
||||||
if (port < exports.MIN_PORT || port > exports.MAX_PORT) {
|
if (port < exports.MIN_PORT || port > exports.MAX_PORT) {
|
||||||
throw new Error(`Emulator port is outside of the supported port range [${exports.MIN_PORT}, ${exports.MAX_PORT}], was ${port}`);
|
throw new Error(`Emulator port is outside of the supported port range [${exports.MIN_PORT}, ${exports.MAX_PORT}], was ${port}`);
|
||||||
@@ -42,37 +49,31 @@ function checkPort(port) {
|
|||||||
throw new Error(`Emulator port has to be even, was ${port}`);
|
throw new Error(`Emulator port has to be even, was ${port}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.checkPort = checkPort;
|
|
||||||
function checkDisableAnimations(disableAnimations) {
|
function checkDisableAnimations(disableAnimations) {
|
||||||
if (!isValidBoolean(disableAnimations)) {
|
if (!isValidBoolean(disableAnimations)) {
|
||||||
throw new Error(`Input for input.disable-animations should be either 'true' or 'false'.`);
|
throw new Error(`Input for input.disable-animations should be either 'true' or 'false'.`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.checkDisableAnimations = checkDisableAnimations;
|
|
||||||
function checkDisableSpellchecker(disableSpellchecker) {
|
function checkDisableSpellchecker(disableSpellchecker) {
|
||||||
if (!isValidBoolean(disableSpellchecker)) {
|
if (!isValidBoolean(disableSpellchecker)) {
|
||||||
throw new Error(`Input for input.disable-spellchecker should be either 'true' or 'false'.`);
|
throw new Error(`Input for input.disable-spellchecker should be either 'true' or 'false'.`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.checkDisableSpellchecker = checkDisableSpellchecker;
|
|
||||||
function checkDisableLinuxHardwareAcceleration(disableLinuxHardwareAcceleration) {
|
function checkDisableLinuxHardwareAcceleration(disableLinuxHardwareAcceleration) {
|
||||||
if (!(isValidBoolean(disableLinuxHardwareAcceleration) || disableLinuxHardwareAcceleration === 'auto')) {
|
if (!(isValidBoolean(disableLinuxHardwareAcceleration) || disableLinuxHardwareAcceleration === 'auto')) {
|
||||||
throw new Error(`Input for input.disable-linux-hw-accel should be either 'true' or 'false' or 'auto'.`);
|
throw new Error(`Input for input.disable-linux-hw-accel should be either 'true' or 'false' or 'auto'.`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.checkDisableLinuxHardwareAcceleration = checkDisableLinuxHardwareAcceleration;
|
|
||||||
function checkEnableHardwareKeyboard(enableHardwareKeyboard) {
|
function checkEnableHardwareKeyboard(enableHardwareKeyboard) {
|
||||||
if (!isValidBoolean(enableHardwareKeyboard)) {
|
if (!isValidBoolean(enableHardwareKeyboard)) {
|
||||||
throw new Error(`Input for input.enable-hw-keyboard should be either 'true' or 'false'.`);
|
throw new Error(`Input for input.enable-hw-keyboard should be either 'true' or 'false'.`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.checkEnableHardwareKeyboard = checkEnableHardwareKeyboard;
|
|
||||||
function checkEmulatorBuild(emulatorBuild) {
|
function checkEmulatorBuild(emulatorBuild) {
|
||||||
if (isNaN(Number(emulatorBuild)) || !Number.isInteger(Number(emulatorBuild))) {
|
if (isNaN(Number(emulatorBuild)) || !Number.isInteger(Number(emulatorBuild))) {
|
||||||
throw new Error(`Unexpected emulator build: '${emulatorBuild}'.`);
|
throw new Error(`Unexpected emulator build: '${emulatorBuild}'.`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.checkEmulatorBuild = checkEmulatorBuild;
|
|
||||||
function isValidBoolean(value) {
|
function isValidBoolean(value) {
|
||||||
return value === 'true' || value === 'false';
|
return value === 'true' || value === 'false';
|
||||||
}
|
}
|
||||||
@@ -92,4 +93,3 @@ function checkDiskSize(diskSize) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.checkDiskSize = checkDiskSize;
|
|
||||||
|
|||||||
+27
-28
@@ -15,22 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|||||||
}) : function(o, v) {
|
}) : function(o, v) {
|
||||||
o["default"] = v;
|
o["default"] = v;
|
||||||
});
|
});
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
var __importStar = (this && this.__importStar) || (function () {
|
||||||
|
var ownKeys = function(o) {
|
||||||
|
ownKeys = Object.getOwnPropertyNames || function (o) {
|
||||||
|
var ar = [];
|
||||||
|
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
||||||
|
return ar;
|
||||||
|
};
|
||||||
|
return ownKeys(o);
|
||||||
|
};
|
||||||
|
return 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 (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
||||||
__setModuleDefault(result, 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");
|
||||||
@@ -40,8 +41,7 @@ const exec = __importStar(require("@actions/exec"));
|
|||||||
const script_parser_1 = require("./script-parser");
|
const script_parser_1 = require("./script-parser");
|
||||||
const channel_id_mapper_1 = require("./channel-id-mapper");
|
const channel_id_mapper_1 = require("./channel-id-mapper");
|
||||||
const fs_1 = require("fs");
|
const fs_1 = require("fs");
|
||||||
function run() {
|
async function run() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
let port = input_validator_1.MIN_PORT;
|
let port = input_validator_1.MIN_PORT;
|
||||||
try {
|
try {
|
||||||
console.log(`::group::Configure emulator`);
|
console.log(`::group::Configure emulator`);
|
||||||
@@ -53,7 +53,7 @@ function run() {
|
|||||||
(0, fs_1.accessSync)('/dev/kvm', fs_1.constants.R_OK | fs_1.constants.W_OK);
|
(0, fs_1.accessSync)('/dev/kvm', fs_1.constants.R_OK | fs_1.constants.W_OK);
|
||||||
linuxSupportKVM = true;
|
linuxSupportKVM = true;
|
||||||
}
|
}
|
||||||
catch (_a) {
|
catch {
|
||||||
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.`);
|
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.`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -169,21 +169,21 @@ function run() {
|
|||||||
const scriptInput = core.getInput('script', { required: true });
|
const scriptInput = core.getInput('script', { required: true });
|
||||||
const scripts = (0, script_parser_1.parseScript)(scriptInput);
|
const scripts = (0, script_parser_1.parseScript)(scriptInput);
|
||||||
console.log(`Script:`);
|
console.log(`Script:`);
|
||||||
scripts.forEach((script) => __awaiter(this, void 0, void 0, function* () {
|
scripts.forEach(async (script) => {
|
||||||
console.log(`${script}`);
|
console.log(`${script}`);
|
||||||
}));
|
});
|
||||||
// custom pre emulator launch script
|
// custom pre emulator launch script
|
||||||
const preEmulatorLaunchScriptInput = core.getInput('pre-emulator-launch-script');
|
const preEmulatorLaunchScriptInput = core.getInput('pre-emulator-launch-script');
|
||||||
const preEmulatorLaunchScripts = !preEmulatorLaunchScriptInput ? undefined : (0, script_parser_1.parseScript)(preEmulatorLaunchScriptInput);
|
const preEmulatorLaunchScripts = !preEmulatorLaunchScriptInput ? undefined : (0, script_parser_1.parseScript)(preEmulatorLaunchScriptInput);
|
||||||
console.log(`Pre emulator launch script:`);
|
console.log(`Pre emulator launch script:`);
|
||||||
preEmulatorLaunchScripts === null || preEmulatorLaunchScripts === void 0 ? void 0 : preEmulatorLaunchScripts.forEach((script) => __awaiter(this, void 0, void 0, function* () {
|
preEmulatorLaunchScripts?.forEach(async (script) => {
|
||||||
console.log(`${script}`);
|
console.log(`${script}`);
|
||||||
}));
|
});
|
||||||
console.log(`::endgroup::`);
|
console.log(`::endgroup::`);
|
||||||
// install SDK
|
// install SDK
|
||||||
yield (0, sdk_installer_1.installAndroidSdk)(apiLevel, systemImageApiLevel, target, arch, channelId, emulatorBuild, ndkVersion, cmakeVersion);
|
await (0, sdk_installer_1.installAndroidSdk)(apiLevel, systemImageApiLevel, target, arch, channelId, emulatorBuild, ndkVersion, cmakeVersion);
|
||||||
// create AVD
|
// create AVD
|
||||||
yield (0, emulator_manager_1.createAvd)(arch, avdName, cores, diskSize, enableHardwareKeyboard, forceAvdCreation, heapSize, profile, ramSize, sdcardPathOrSize, systemImageApiLevel, target);
|
await (0, emulator_manager_1.createAvd)(arch, avdName, cores, diskSize, enableHardwareKeyboard, forceAvdCreation, heapSize, profile, ramSize, sdcardPathOrSize, systemImageApiLevel, target);
|
||||||
// execute pre emulator launch script if set
|
// execute pre emulator launch script if set
|
||||||
if (preEmulatorLaunchScripts !== undefined) {
|
if (preEmulatorLaunchScripts !== undefined) {
|
||||||
console.log(`::group::Run pre emulator launch script`);
|
console.log(`::group::Run pre emulator launch script`);
|
||||||
@@ -191,7 +191,7 @@ function run() {
|
|||||||
for (const preEmulatorLaunchScript of preEmulatorLaunchScripts) {
|
for (const preEmulatorLaunchScript of preEmulatorLaunchScripts) {
|
||||||
// use array form to avoid various quote escaping problems
|
// use array form to avoid various quote escaping problems
|
||||||
// caused by exec(`sh -c "${preEmulatorLaunchScript}"`)
|
// caused by exec(`sh -c "${preEmulatorLaunchScript}"`)
|
||||||
yield exec.exec('sh', ['-c', preEmulatorLaunchScript], {
|
await exec.exec('sh', ['-c', preEmulatorLaunchScript], {
|
||||||
cwd: workingDirectory,
|
cwd: workingDirectory,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -202,7 +202,7 @@ function run() {
|
|||||||
console.log(`::endgroup::`);
|
console.log(`::endgroup::`);
|
||||||
}
|
}
|
||||||
// launch an emulator
|
// launch an emulator
|
||||||
yield (0, emulator_manager_1.launchEmulator)(avdName, disableAnimations, disableLinuxHardwareAcceleration, disableSpellchecker, emulatorBootTimeout, emulatorOptions, enableHardwareKeyboard, port);
|
await (0, emulator_manager_1.launchEmulator)(avdName, disableAnimations, disableLinuxHardwareAcceleration, disableSpellchecker, emulatorBootTimeout, emulatorOptions, enableHardwareKeyboard, port);
|
||||||
// execute the custom script
|
// execute the custom script
|
||||||
try {
|
try {
|
||||||
// move to custom working directory if set
|
// move to custom working directory if set
|
||||||
@@ -212,8 +212,8 @@ function run() {
|
|||||||
for (const script of scripts) {
|
for (const script of scripts) {
|
||||||
// use array form to avoid various quote escaping problems
|
// use array form to avoid various quote escaping problems
|
||||||
// caused by exec(`sh -c "${script}"`)
|
// caused by exec(`sh -c "${script}"`)
|
||||||
yield exec.exec('sh', ['-c', script], {
|
await exec.exec('sh', ['-c', script], {
|
||||||
env: Object.assign(Object.assign({}, process.env), { EMULATOR_PORT: `${port}`, ANDROID_SERIAL: `emulator-${port}` }),
|
env: { ...process.env, EMULATOR_PORT: `${port}`, ANDROID_SERIAL: `emulator-${port}` },
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -221,13 +221,12 @@ function run() {
|
|||||||
core.setFailed(error instanceof Error ? error.message : error);
|
core.setFailed(error instanceof Error ? error.message : error);
|
||||||
}
|
}
|
||||||
// finally kill the emulator
|
// finally kill the emulator
|
||||||
yield (0, emulator_manager_1.killEmulator)(port);
|
await (0, emulator_manager_1.killEmulator)(port);
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
// kill the emulator so the action can exit
|
// kill the emulator so the action can exit
|
||||||
yield (0, emulator_manager_1.killEmulator)(port);
|
await (0, emulator_manager_1.killEmulator)(port);
|
||||||
core.setFailed(error instanceof Error ? error.message : error);
|
core.setFailed(error instanceof Error ? error.message : error);
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
}
|
||||||
run();
|
run();
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.parseScript = void 0;
|
exports.parseScript = parseScript;
|
||||||
/**
|
/**
|
||||||
* 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).
|
||||||
*/
|
*/
|
||||||
@@ -17,4 +17,3 @@ function parseScript(rawScript) {
|
|||||||
}
|
}
|
||||||
return scripts;
|
return scripts;
|
||||||
}
|
}
|
||||||
exports.parseScript = parseScript;
|
|
||||||
|
|||||||
+28
-30
@@ -15,24 +15,25 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|||||||
}) : function(o, v) {
|
}) : function(o, v) {
|
||||||
o["default"] = v;
|
o["default"] = v;
|
||||||
});
|
});
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
var __importStar = (this && this.__importStar) || (function () {
|
||||||
|
var ownKeys = function(o) {
|
||||||
|
ownKeys = Object.getOwnPropertyNames || function (o) {
|
||||||
|
var ar = [];
|
||||||
|
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
||||||
|
return ar;
|
||||||
|
};
|
||||||
|
return ownKeys(o);
|
||||||
|
};
|
||||||
|
return 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 (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
||||||
__setModuleDefault(result, 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;
|
exports.installAndroidSdk = installAndroidSdk;
|
||||||
const core = __importStar(require("@actions/core"));
|
const core = __importStar(require("@actions/core"));
|
||||||
const exec = __importStar(require("@actions/exec"));
|
const exec = __importStar(require("@actions/exec"));
|
||||||
const io = __importStar(require("@actions/io"));
|
const io = __importStar(require("@actions/io"));
|
||||||
@@ -46,8 +47,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,
|
* 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, systemImageApiLevel, target, arch, channelId, emulatorBuild, ndkVersion, cmakeVersion) {
|
async function installAndroidSdk(apiLevel, systemImageApiLevel, target, arch, channelId, emulatorBuild, ndkVersion, cmakeVersion) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
try {
|
try {
|
||||||
console.log(`::group::Install Android SDK`);
|
console.log(`::group::Install Android SDK`);
|
||||||
const isOnMac = process.platform === 'darwin';
|
const isOnMac = process.platform === 'darwin';
|
||||||
@@ -56,21 +56,21 @@ function installAndroidSdk(apiLevel, systemImageApiLevel, target, arch, channelI
|
|||||||
if (!fs.existsSync(cmdlineToolsPath)) {
|
if (!fs.existsSync(cmdlineToolsPath)) {
|
||||||
console.log('Installing new cmdline-tools.');
|
console.log('Installing new cmdline-tools.');
|
||||||
const sdkUrl = isOnMac ? CMDLINE_TOOLS_URL_MAC : CMDLINE_TOOLS_URL_LINUX;
|
const sdkUrl = isOnMac ? CMDLINE_TOOLS_URL_MAC : CMDLINE_TOOLS_URL_LINUX;
|
||||||
const downloadPath = yield tc.downloadTool(sdkUrl);
|
const downloadPath = await tc.downloadTool(sdkUrl);
|
||||||
yield tc.extractZip(downloadPath, cmdlineToolsPath);
|
await tc.extractZip(downloadPath, cmdlineToolsPath);
|
||||||
yield io.mv(`${cmdlineToolsPath}/cmdline-tools`, `${cmdlineToolsPath}/latest`);
|
await io.mv(`${cmdlineToolsPath}/cmdline-tools`, `${cmdlineToolsPath}/latest`);
|
||||||
}
|
}
|
||||||
// add paths for commandline-tools and platform-tools
|
// add paths for commandline-tools and platform-tools
|
||||||
core.addPath(`${cmdlineToolsPath}/latest:${cmdlineToolsPath}/latest/bin:${process.env.ANDROID_HOME}/platform-tools`);
|
core.addPath(`${cmdlineToolsPath}/latest:${cmdlineToolsPath}/latest/bin:${process.env.ANDROID_HOME}/platform-tools`);
|
||||||
// set standard AVD path
|
// set standard AVD path
|
||||||
yield io.mkdirP(`${process.env.HOME}/.android/avd`);
|
await io.mkdirP(`${process.env.HOME}/.android/avd`);
|
||||||
core.exportVariable('ANDROID_AVD_HOME', `${process.env.HOME}/.android/avd`);
|
core.exportVariable('ANDROID_AVD_HOME', `${process.env.HOME}/.android/avd`);
|
||||||
// accept all Android SDK licenses
|
// accept all Android SDK licenses
|
||||||
yield exec.exec(`sh -c \\"yes | sdkmanager --licenses > /dev/null"`);
|
await exec.exec(`sh -c \\"yes | sdkmanager --licenses > /dev/null"`);
|
||||||
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 \\"sdkmanager --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"`);
|
||||||
console.log('Installing latest emulator.');
|
console.log('Installing latest emulator.');
|
||||||
yield exec.exec(`sh -c \\"sdkmanager --install emulator --channel=${channelId} > /dev/null"`);
|
await exec.exec(`sh -c \\"sdkmanager --install emulator --channel=${channelId} > /dev/null"`);
|
||||||
if (emulatorBuild) {
|
if (emulatorBuild) {
|
||||||
console.log(`Installing emulator build ${emulatorBuild}.`);
|
console.log(`Installing emulator build ${emulatorBuild}.`);
|
||||||
// TODO find out the correct download URLs for all build ids
|
// TODO find out the correct download URLs for all build ids
|
||||||
@@ -90,24 +90,22 @@ function installAndroidSdk(apiLevel, systemImageApiLevel, target, arch, channelI
|
|||||||
else {
|
else {
|
||||||
downloadUrlSuffix = `-${emulatorBuild}`;
|
downloadUrlSuffix = `-${emulatorBuild}`;
|
||||||
}
|
}
|
||||||
yield exec.exec(`curl -fo emulator.zip https://dl.google.com/android/repository/emulator-${isOnMac ? 'darwin' : 'linux'}${downloadUrlSuffix}.zip`);
|
await exec.exec(`curl -fo emulator.zip https://dl.google.com/android/repository/emulator-${isOnMac ? 'darwin' : 'linux'}${downloadUrlSuffix}.zip`);
|
||||||
yield exec.exec(`unzip -o -q emulator.zip -d ${process.env.ANDROID_HOME}`);
|
await exec.exec(`unzip -o -q emulator.zip -d ${process.env.ANDROID_HOME}`);
|
||||||
yield io.rmRF('emulator.zip');
|
await io.rmRF('emulator.zip');
|
||||||
}
|
}
|
||||||
console.log('Installing system images.');
|
console.log('Installing system images.');
|
||||||
yield exec.exec(`sh -c \\"sdkmanager --install 'system-images;android-${systemImageApiLevel};${target};${arch}' --channel=${channelId} > /dev/null"`);
|
await exec.exec(`sh -c \\"sdkmanager --install 'system-images;android-${systemImageApiLevel};${target};${arch}' --channel=${channelId} > /dev/null"`);
|
||||||
if (ndkVersion) {
|
if (ndkVersion) {
|
||||||
console.log(`Installing NDK ${ndkVersion}.`);
|
console.log(`Installing NDK ${ndkVersion}.`);
|
||||||
yield exec.exec(`sh -c \\"sdkmanager --install 'ndk;${ndkVersion}' --channel=${channelId} > /dev/null"`);
|
await exec.exec(`sh -c \\"sdkmanager --install 'ndk;${ndkVersion}' --channel=${channelId} > /dev/null"`);
|
||||||
}
|
}
|
||||||
if (cmakeVersion) {
|
if (cmakeVersion) {
|
||||||
console.log(`Installing CMake ${cmakeVersion}.`);
|
console.log(`Installing CMake ${cmakeVersion}.`);
|
||||||
yield exec.exec(`sh -c \\"sdkmanager --install 'cmake;${cmakeVersion}' --channel=${channelId} > /dev/null"`);
|
await exec.exec(`sh -c \\"sdkmanager --install 'cmake;${cmakeVersion}' --channel=${channelId} > /dev/null"`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
console.log(`::endgroup::`);
|
console.log(`::endgroup::`);
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
}
|
||||||
exports.installAndroidSdk = installAndroidSdk;
|
|
||||||
|
|||||||
Generated
+3975
-3116
File diff suppressed because it is too large
Load Diff
+14
-14
@@ -19,7 +19,7 @@
|
|||||||
"setup"
|
"setup"
|
||||||
],
|
],
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=20"
|
"node": ">=24"
|
||||||
},
|
},
|
||||||
"author": "Reactive Circus",
|
"author": "Reactive Circus",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
@@ -31,18 +31,18 @@
|
|||||||
"set-value": "^4.1.0"
|
"set-value": "^4.1.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/jest": "^29.2.0",
|
"@types/jest": "^29.5.12",
|
||||||
"@types/node": "^20.11.0",
|
"@types/node": "^24.1.0",
|
||||||
"@typescript-eslint/eslint-plugin": "^5.41.0",
|
"@typescript-eslint/eslint-plugin": "^8.57.0",
|
||||||
"@typescript-eslint/parser": "^5.41.0",
|
"@typescript-eslint/parser": "^8.57.0",
|
||||||
"eslint": "^8.26.0",
|
"eslint": "^8.57.0",
|
||||||
"eslint-config-prettier": "^8.5.0",
|
"eslint-config-prettier": "^9.1.0",
|
||||||
"eslint-plugin-import": "^2.26.0",
|
"eslint-plugin-import": "^2.29.1",
|
||||||
"eslint-plugin-prettier": "^4.2.1",
|
"eslint-plugin-prettier": "^5.1.3",
|
||||||
"jest": "^29.2.2",
|
"jest": "^29.7.0",
|
||||||
"jest-circus": "^29.2.2",
|
"jest-circus": "^29.7.0",
|
||||||
"prettier": "^2.7.1",
|
"prettier": "^3.3.3",
|
||||||
"ts-jest": "^29.0.3",
|
"ts-jest": "^29.2.5",
|
||||||
"typescript": "^4.8.4"
|
"typescript": "^5.5.4"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ export async function createAvd(
|
|||||||
ramSize: string,
|
ramSize: string,
|
||||||
sdcardPathOrSize: string,
|
sdcardPathOrSize: string,
|
||||||
systemImageApiLevel: string,
|
systemImageApiLevel: string,
|
||||||
target: string
|
target: string,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
try {
|
try {
|
||||||
console.log(`::group::Create AVD`);
|
console.log(`::group::Create AVD`);
|
||||||
@@ -27,7 +27,7 @@ export async function createAvd(
|
|||||||
const sdcardPathOrSizeOption = sdcardPathOrSize.trim() !== '' ? `--sdcard '${sdcardPathOrSize}'` : '';
|
const sdcardPathOrSizeOption = sdcardPathOrSize.trim() !== '' ? `--sdcard '${sdcardPathOrSize}'` : '';
|
||||||
console.log(`Creating AVD.`);
|
console.log(`Creating AVD.`);
|
||||||
await exec.exec(
|
await exec.exec(
|
||||||
`sh -c \\"echo no | avdmanager create avd --force -n "${avdName}" --package 'system-images;android-${systemImageApiLevel};${target};${arch}' ${profileOption} ${sdcardPathOrSizeOption}"`
|
`sh -c \\"echo no | avdmanager create avd --force -n "${avdName}" --package 'system-images;android-${systemImageApiLevel};${target};${arch}' ${profileOption} ${sdcardPathOrSizeOption}"`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -71,7 +71,7 @@ export async function launchEmulator(
|
|||||||
emulatorBootTimeout: number,
|
emulatorBootTimeout: number,
|
||||||
emulatorOptions: string,
|
emulatorOptions: string,
|
||||||
enableHardwareKeyboard: boolean,
|
enableHardwareKeyboard: boolean,
|
||||||
port: number
|
port: number,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
try {
|
try {
|
||||||
console.log(`::group::Launch Emulator`);
|
console.log(`::group::Launch Emulator`);
|
||||||
|
|||||||
+1
-1
@@ -33,7 +33,7 @@ async function run() {
|
|||||||
linuxSupportKVM = true;
|
linuxSupportKVM = true;
|
||||||
} catch {
|
} catch {
|
||||||
console.warn(
|
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.`
|
`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 {
|
} else {
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ export async function installAndroidSdk(
|
|||||||
channelId: number,
|
channelId: number,
|
||||||
emulatorBuild?: string,
|
emulatorBuild?: string,
|
||||||
ndkVersion?: string,
|
ndkVersion?: string,
|
||||||
cmakeVersion?: string
|
cmakeVersion?: string,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
try {
|
try {
|
||||||
console.log(`::group::Install Android SDK`);
|
console.log(`::group::Install Android SDK`);
|
||||||
|
|||||||
+3
-2
@@ -2,7 +2,7 @@
|
|||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
/* Basic Options */
|
/* Basic Options */
|
||||||
// "incremental": true, /* Enable incremental compilation */
|
// "incremental": true, /* Enable incremental compilation */
|
||||||
"target": "es6", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
|
"target": "es2022", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
|
||||||
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
|
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
|
||||||
// "allowJs": true, /* Allow javascript files to be compiled. */
|
// "allowJs": true, /* Allow javascript files to be compiled. */
|
||||||
// "checkJs": true, /* Report errors in .js files. */
|
// "checkJs": true, /* Report errors in .js files. */
|
||||||
@@ -45,7 +45,8 @@
|
|||||||
// "typeRoots": [], /* List of folders to include type definitions from. */
|
// "typeRoots": [], /* List of folders to include type definitions from. */
|
||||||
// "types": [], /* Type declaration files to be included in compilation. */
|
// "types": [], /* Type declaration files to be included in compilation. */
|
||||||
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
|
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
|
||||||
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
|
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
|
||||||
|
"skipLibCheck": true
|
||||||
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
|
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
|
||||||
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
|
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user