mirror of
https://github.com/reactivecircus/android-emulator-runner.git
synced 2026-09-05 19:39:32 +00:00
Add GHA commands to group logs (#224)
This commit is contained in:
@@ -23,6 +23,8 @@ export async function launchEmulator(
|
|||||||
disableLinuxHardwareAcceleration: boolean,
|
disableLinuxHardwareAcceleration: boolean,
|
||||||
enableHardwareKeyboard: boolean
|
enableHardwareKeyboard: boolean
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
|
try {
|
||||||
|
console.log(`::group::Launch Emulator`);
|
||||||
// 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
|
||||||
const avdPath = `${process.env.ANDROID_AVD_HOME}/${avdName}.avd`;
|
const avdPath = `${process.env.ANDROID_AVD_HOME}/${avdName}.avd`;
|
||||||
if (!fs.existsSync(avdPath) || forceAvdCreation) {
|
if (!fs.existsSync(avdPath) || forceAvdCreation) {
|
||||||
@@ -85,6 +87,9 @@ export async function launchEmulator(
|
|||||||
if (enableHardwareKeyboard) {
|
if (enableHardwareKeyboard) {
|
||||||
await exec.exec(`adb shell settings put secure show_ime_with_hard_keyboard 0`);
|
await exec.exec(`adb shell settings put secure show_ime_with_hard_keyboard 0`);
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
|
console.log(`::endgroup::`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -92,9 +97,12 @@ export async function launchEmulator(
|
|||||||
*/
|
*/
|
||||||
export async function killEmulator(): Promise<void> {
|
export async function killEmulator(): Promise<void> {
|
||||||
try {
|
try {
|
||||||
|
console.log(`::group::Terminate Emulator`);
|
||||||
await exec.exec(`adb -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);
|
||||||
|
} finally {
|
||||||
|
console.log(`::endgroup::`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import { getChannelId } from './channel-id-mapper';
|
|||||||
|
|
||||||
async function run() {
|
async function run() {
|
||||||
try {
|
try {
|
||||||
|
console.log(`::group::Configure emulator`);
|
||||||
// only support running on macOS or Linux
|
// only support running on macOS or Linux
|
||||||
if (process.platform !== 'darwin') {
|
if (process.platform !== 'darwin') {
|
||||||
if (process.platform === 'linux') {
|
if (process.platform === 'linux') {
|
||||||
@@ -148,6 +149,7 @@ async function run() {
|
|||||||
scripts.forEach(async (script: string) => {
|
scripts.forEach(async (script: string) => {
|
||||||
console.log(`${script}`);
|
console.log(`${script}`);
|
||||||
});
|
});
|
||||||
|
console.log(`::endgroup::`);
|
||||||
|
|
||||||
// install SDK
|
// install SDK
|
||||||
await installAndroidSdk(apiLevel, target, arch, channelId, emulatorBuild, ndkVersion, cmakeVersion);
|
await installAndroidSdk(apiLevel, target, arch, channelId, emulatorBuild, ndkVersion, cmakeVersion);
|
||||||
|
|||||||
@@ -13,6 +13,8 @@ const CMDLINE_TOOLS_URL_LINUX = 'https://dl.google.com/android/repository/comman
|
|||||||
* 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, channelId: number, emulatorBuild?: string, ndkVersion?: string, cmakeVersion?: string): Promise<void> {
|
export async function installAndroidSdk(apiLevel: number, target: string, arch: string, channelId: number, emulatorBuild?: string, ndkVersion?: string, cmakeVersion?: string): Promise<void> {
|
||||||
|
try {
|
||||||
|
console.log(`::group::Install Android SDK`);
|
||||||
const isOnMac = process.platform === 'darwin';
|
const isOnMac = process.platform === 'darwin';
|
||||||
|
|
||||||
if (!isOnMac) {
|
if (!isOnMac) {
|
||||||
@@ -63,4 +65,7 @@ export async function installAndroidSdk(apiLevel: number, target: string, arch:
|
|||||||
console.log(`Installing CMake ${cmakeVersion}.`);
|
console.log(`Installing CMake ${cmakeVersion}.`);
|
||||||
await 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 {
|
||||||
|
console.log(`::endgroup::`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user