mirror of
https://github.com/reactivecircus/android-emulator-runner.git
synced 2026-09-05 11:39:31 +00:00
Implement sdk-installer. Add test pipeline with job matrix.
This commit is contained in:
@@ -8,16 +8,27 @@ on:
|
|||||||
jobs:
|
jobs:
|
||||||
test:
|
test:
|
||||||
runs-on: macOS-latest
|
runs-on: macOS-latest
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
api-level: [21, 22, 23, 24, 25, 26, 27, 28, 29]
|
||||||
|
target: [default, google_apis]
|
||||||
|
abi: [x86, x86_64]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v1
|
- name: checkout
|
||||||
|
uses: actions/checkout@v1
|
||||||
with:
|
with:
|
||||||
fetch-depth: 1
|
fetch-depth: 1
|
||||||
- run: npm install
|
|
||||||
- run: npm run build
|
- name: build and test
|
||||||
- run: npm test
|
run: |
|
||||||
- uses: ./
|
npm install
|
||||||
|
npm run build
|
||||||
|
npm test
|
||||||
|
|
||||||
|
- name: run action
|
||||||
|
uses: ./
|
||||||
with:
|
with:
|
||||||
api-level: 23
|
api-level: ${{ matrix.api-level }}
|
||||||
target: google_apis
|
target: ${{ matrix.target }}
|
||||||
abi: x86
|
abi: ${{ matrix.abi }}
|
||||||
headless: true
|
headless: true
|
||||||
|
|||||||
+4
-4
@@ -15,28 +15,28 @@ async function run() {
|
|||||||
// TODO use InputOptions {true}
|
// TODO use InputOptions {true}
|
||||||
const apiLevel = core.getInput('api-level');
|
const apiLevel = core.getInput('api-level');
|
||||||
// TODO check apiLevel is number and within valid range
|
// TODO check apiLevel is number and within valid range
|
||||||
console.log(`API level - ${apiLevel}`);
|
console.log(`API level: ${apiLevel}`);
|
||||||
|
|
||||||
// target is optional with default
|
// target is optional with default
|
||||||
const target = core.getInput('target');
|
const target = core.getInput('target');
|
||||||
if (target !== 'default' && target !== 'google_apis') {
|
if (target !== 'default' && target !== 'google_apis') {
|
||||||
throw new Error(`Target ${target} is unknown. Please use either 'default' or 'google_apis'.`);
|
throw new Error(`Target ${target} is unknown. Please use either 'default' or 'google_apis'.`);
|
||||||
}
|
}
|
||||||
console.log(`target - ${target}`);
|
console.log(`target: ${target}`);
|
||||||
|
|
||||||
// abi is optional with default
|
// abi is optional with default
|
||||||
const abi = core.getInput('abi');
|
const abi = core.getInput('abi');
|
||||||
if (abi !== 'x86' && abi !== 'x86_64') {
|
if (abi !== 'x86' && abi !== 'x86_64') {
|
||||||
throw new Error(`abi ${abi} is unknown (ARM-based emulators are not supported). Please use either 'x86' or 'x86_64'.`);
|
throw new Error(`abi ${abi} is unknown (ARM-based emulators are not supported). Please use either 'x86' or 'x86_64'.`);
|
||||||
}
|
}
|
||||||
console.log(`cpu/abi - ${abi}`);
|
console.log(`cpu/abi: ${abi}`);
|
||||||
|
|
||||||
// headless is optional with default
|
// headless is optional with default
|
||||||
const headless = core.getInput('headless');
|
const headless = core.getInput('headless');
|
||||||
if (headless !== 'true' && headless !== 'false') {
|
if (headless !== 'true' && headless !== 'false') {
|
||||||
throw new Error(`Input 'headless' should be either 'true' or 'false'.`);
|
throw new Error(`Input 'headless' should be either 'true' or 'false'.`);
|
||||||
}
|
}
|
||||||
console.log(`headless mode - ${headless}`);
|
console.log(`headless mode: ${headless}`);
|
||||||
|
|
||||||
// install SDK
|
// install SDK
|
||||||
await installAndroidSdk(Number(apiLevel), target, abi);
|
await installAndroidSdk(Number(apiLevel), target, abi);
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ const SDK_URL = 'https://dl.google.com/android/repository/sdk-tools-darwin-43337
|
|||||||
* Downloads and installs the Android SDK for the macOS platform, including SDK platform for the chosen API level, latest build tools, platform tools, Android Emulator,
|
* Downloads and installs 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/abi, and target.
|
* and the system image for the chosen API level, cpu/abi, and target.
|
||||||
*/
|
*/
|
||||||
export async function installAndroidSdk(apiLevel: number, abi: string, target: string): Promise<void> {
|
export async function installAndroidSdk(apiLevel: number, target: string, abi: string): Promise<void> {
|
||||||
// download Android SDK if not already installed
|
// download Android SDK if not already installed
|
||||||
if (fs.existsSync(`${process.env.ANDROID_HOME}/tools/bin/sdkmanager`)) {
|
if (fs.existsSync(`${process.env.ANDROID_HOME}/tools/bin/sdkmanager`)) {
|
||||||
console.log('Android SDK already installed.');
|
console.log('Android SDK already installed.');
|
||||||
@@ -21,8 +21,7 @@ export async function installAndroidSdk(apiLevel: number, abi: string, target: s
|
|||||||
|
|
||||||
// install specific SDK tools
|
// install specific SDK tools
|
||||||
console.log('Installing build tools, platform tools, platform and system image.');
|
console.log('Installing build tools, platform tools, platform and system image.');
|
||||||
await exec.exec(`yes | ${process.env.ANDROID_HOME}/tools/bin/sdkmanager --licenses`);
|
await exec.exec(`echo "y" | ${process.env.ANDROID_HOME}/tools/bin/sdkmanager --licenses > /dev/null`);
|
||||||
await exec.exec(`${process.env.ANDROID_HOME}/tools/bin/sdkmanager --update`);
|
|
||||||
await exec.exec(`${process.env.ANDROID_HOME}/tools/bin/sdkmanager "build-tools;${BUILD_TOOLS_VERSION}"`);
|
await exec.exec(`${process.env.ANDROID_HOME}/tools/bin/sdkmanager "build-tools;${BUILD_TOOLS_VERSION}"`);
|
||||||
await exec.exec(`${process.env.ANDROID_HOME}/tools/bin/sdkmanager "platform-tools"`);
|
await exec.exec(`${process.env.ANDROID_HOME}/tools/bin/sdkmanager "platform-tools"`);
|
||||||
await exec.exec(`${process.env.ANDROID_HOME}/tools/bin/sdkmanager "platforms;android-${apiLevel}"`);
|
await exec.exec(`${process.env.ANDROID_HOME}/tools/bin/sdkmanager "platforms;android-${apiLevel}"`);
|
||||||
|
|||||||
Reference in New Issue
Block a user