Add GHA commands to group logs (#224)

This commit is contained in:
Michael Kaye
2022-02-17 09:03:29 +00:00
committed by GitHub
parent 3045dbfaba
commit 1e2ef7249a
3 changed files with 105 additions and 90 deletions
+8
View File
@@ -23,6 +23,8 @@ export async function launchEmulator(
disableLinuxHardwareAcceleration: boolean,
enableHardwareKeyboard: boolean
): Promise<void> {
try {
console.log(`::group::Launch Emulator`);
// create a new AVD if AVD directory does not already exist or forceAvdCreation is true
const avdPath = `${process.env.ANDROID_AVD_HOME}/${avdName}.avd`;
if (!fs.existsSync(avdPath) || forceAvdCreation) {
@@ -85,6 +87,9 @@ export async function launchEmulator(
if (enableHardwareKeyboard) {
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> {
try {
console.log(`::group::Terminate Emulator`);
await exec.exec(`adb -s emulator-5554 emu kill`);
} catch (error) {
console.log(error.message);
} finally {
console.log(`::endgroup::`);
}
}
+2
View File
@@ -20,6 +20,7 @@ import { getChannelId } from './channel-id-mapper';
async function run() {
try {
console.log(`::group::Configure emulator`);
// only support running on macOS or Linux
if (process.platform !== 'darwin') {
if (process.platform === 'linux') {
@@ -148,6 +149,7 @@ async function run() {
scripts.forEach(async (script: string) => {
console.log(`${script}`);
});
console.log(`::endgroup::`);
// install SDK
await installAndroidSdk(apiLevel, target, arch, channelId, emulatorBuild, ndkVersion, cmakeVersion);
+5
View File
@@ -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.
*/
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';
if (!isOnMac) {
@@ -63,4 +65,7 @@ export async function installAndroidSdk(apiLevel: number, target: string, arch:
console.log(`Installing CMake ${cmakeVersion}.`);
await exec.exec(`sh -c \\"sdkmanager --install 'cmake;${cmakeVersion}' --channel=${channelId} > /dev/null"`);
}
} finally {
console.log(`::endgroup::`);
}
}