mirror of
https://github.com/reactivecircus/android-emulator-runner.git
synced 2026-09-03 10:59:32 +00:00
Compare commits
5 Commits
v2
...
yc/windows-support
| Author | SHA1 | Date | |
|---|---|---|---|
| f3572f51f0 | |||
| 7f954888fa | |||
| f9ac2a7b31 | |||
| 098ef337be | |||
| b7eed610b6 |
@@ -4,35 +4,20 @@ on:
|
|||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
|
- 'yc/windows-support'
|
||||||
paths-ignore:
|
paths-ignore:
|
||||||
- '**.md'
|
- '**.md'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
test:
|
test:
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: windows-latest
|
||||||
env:
|
env:
|
||||||
JAVA_TOOL_OPTIONS: -Xmx4g
|
JAVA_TOOL_OPTIONS: -Xmx4g
|
||||||
timeout-minutes: 15
|
timeout-minutes: 15
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
os: [macos-latest, ubuntu-latest]
|
|
||||||
api-level: [16, 23, 29]
|
api-level: [16, 23, 29]
|
||||||
target: [default, google_apis]
|
target: [default, google_apis]
|
||||||
exclude:
|
|
||||||
- os: ubuntu-latest
|
|
||||||
api-level: 23
|
|
||||||
- os: ubuntu-latest
|
|
||||||
api-level: 29
|
|
||||||
- target: google_apis
|
|
||||||
api-level: 16
|
|
||||||
- target: google_apis
|
|
||||||
api-level: 23
|
|
||||||
- target: google_apis
|
|
||||||
api-level: 29
|
|
||||||
include:
|
|
||||||
- os: macos-latest
|
|
||||||
api-level: 30
|
|
||||||
target: google_apis
|
|
||||||
steps:
|
steps:
|
||||||
- name: checkout
|
- name: checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
|
|||||||
+2
-8
@@ -37,14 +37,8 @@ const script_parser_1 = require("./script-parser");
|
|||||||
function run() {
|
function run() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
try {
|
try {
|
||||||
// only support running on macOS or Linux
|
if (process.platform === 'linux') {
|
||||||
if (process.platform !== 'darwin') {
|
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.`);
|
||||||
if (process.platform === 'linux') {
|
|
||||||
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.`);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
throw new Error('Unsupported virtual machine: please use either macos or ubuntu VM.');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// API level of the platform and system image
|
// API level of the platform and system image
|
||||||
const apiLevelInput = core.getInput('api-level', { required: true });
|
const apiLevelInput = core.getInput('api-level', { required: true });
|
||||||
|
|||||||
+18
-15
@@ -32,9 +32,11 @@ exports.installAndroidSdk = void 0;
|
|||||||
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"));
|
||||||
|
const tc = __importStar(require("@actions/tool-cache"));
|
||||||
const fs = __importStar(require("fs"));
|
const fs = __importStar(require("fs"));
|
||||||
const BUILD_TOOLS_VERSION = '30.0.2';
|
const BUILD_TOOLS_VERSION = '30.0.2';
|
||||||
const CMDLINE_TOOLS_URL_MAC = 'https://dl.google.com/android/repository/commandlinetools-mac-6609375_latest.zip';
|
const CMDLINE_TOOLS_URL_MAC = 'https://dl.google.com/android/repository/commandlinetools-mac-6609375_latest.zip';
|
||||||
|
const CMDLINE_TOOLS_URL_WIN = 'https://dl.google.com/android/repository/commandlinetools-win-6609375_latest.zip';
|
||||||
const CMDLINE_TOOLS_URL_LINUX = 'https://dl.google.com/android/repository/commandlinetools-linux-6609375_latest.zip';
|
const CMDLINE_TOOLS_URL_LINUX = 'https://dl.google.com/android/repository/commandlinetools-linux-6609375_latest.zip';
|
||||||
/**
|
/**
|
||||||
* 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,
|
||||||
@@ -42,24 +44,25 @@ const CMDLINE_TOOLS_URL_LINUX = 'https://dl.google.com/android/repository/comman
|
|||||||
*/
|
*/
|
||||||
function installAndroidSdk(apiLevel, target, arch, emulatorBuild, ndkVersion, cmakeVersion) {
|
function installAndroidSdk(apiLevel, target, arch, emulatorBuild, ndkVersion, cmakeVersion) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
const isOnMac = process.platform === 'darwin';
|
const IS_MAC = process.platform === 'darwin';
|
||||||
if (!isOnMac) {
|
const IS_WINDOWS = process.platform === 'win32';
|
||||||
|
const IS_LINUX = process.platform === 'linux';
|
||||||
|
if (IS_LINUX) {
|
||||||
yield exec.exec(`sh -c \\"sudo chown $USER:$USER ${process.env.ANDROID_HOME} -R`);
|
yield exec.exec(`sh -c \\"sudo chown $USER:$USER ${process.env.ANDROID_HOME} -R`);
|
||||||
}
|
}
|
||||||
const cmdlineToolsPath = `${process.env.ANDROID_HOME}/cmdline-tools`;
|
const cmdlineToolsPath = `${process.env.ANDROID_HOME}/cmdline-tools`;
|
||||||
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;
|
|
||||||
yield io.mkdirP(`${process.env.ANDROID_HOME}/cmdline-tools`);
|
yield io.mkdirP(`${process.env.ANDROID_HOME}/cmdline-tools`);
|
||||||
yield exec.exec(`curl -fo commandlinetools.zip ${sdkUrl}`);
|
const sdkUrl = IS_MAC ? CMDLINE_TOOLS_URL_MAC : IS_WINDOWS ? CMDLINE_TOOLS_URL_WIN : CMDLINE_TOOLS_URL_LINUX;
|
||||||
yield exec.exec(`unzip -q commandlinetools.zip -d ${cmdlineToolsPath}`);
|
const downloadPath = yield tc.downloadTool(sdkUrl);
|
||||||
yield io.rmRF('commandlinetools.zip');
|
yield tc.extractZip(downloadPath, cmdlineToolsPath);
|
||||||
// add paths for commandline-tools and platform-tools
|
// add paths for commandline-tools and platform-tools
|
||||||
core.addPath(`${cmdlineToolsPath}/tools:${cmdlineToolsPath}/tools/bin:${process.env.ANDROID_HOME}/platform-tools`);
|
core.addPath(`${cmdlineToolsPath}/tools:${cmdlineToolsPath}/tools/bin:${process.env.ANDROID_HOME}/platform-tools`);
|
||||||
}
|
}
|
||||||
// additional permission and license requirements for Linux
|
// additional permission and license requirements for Linux
|
||||||
const sdkPreviewLicensePath = `${process.env.ANDROID_HOME}/licenses/android-sdk-preview-license`;
|
const sdkPreviewLicensePath = `${process.env.ANDROID_HOME}/licenses/android-sdk-preview-license`;
|
||||||
if (!isOnMac && !fs.existsSync(sdkPreviewLicensePath)) {
|
if (IS_LINUX && !fs.existsSync(sdkPreviewLicensePath)) {
|
||||||
fs.writeFileSync(sdkPreviewLicensePath, '\n84831b9409646a918e30573bab4c9c91346d8abd');
|
fs.writeFileSync(sdkPreviewLicensePath, '\n84831b9409646a918e30573bab4c9c91346d8abd');
|
||||||
}
|
}
|
||||||
// license required for API 30 system images
|
// license required for API 30 system images
|
||||||
@@ -68,27 +71,27 @@ function installAndroidSdk(apiLevel, target, arch, emulatorBuild, ndkVersion, cm
|
|||||||
fs.writeFileSync(sdkArmDbtLicensePath, '\n859f317696f67ef3d7f30a50a5560e7834b43903');
|
fs.writeFileSync(sdkArmDbtLicensePath, '\n859f317696f67ef3d7f30a50a5560e7834b43903');
|
||||||
}
|
}
|
||||||
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"`);
|
const sdkmanagerExec = IS_WINDOWS ? 'sdkmanager.bat' : 'sdkmanager';
|
||||||
|
yield exec.exec(`sh -c \\"${sdkmanagerExec} --install 'build-tools;${BUILD_TOOLS_VERSION}' platform-tools 'platforms;android-${apiLevel}' > /dev/null"`);
|
||||||
if (emulatorBuild) {
|
if (emulatorBuild) {
|
||||||
console.log(`Installing emulator build ${emulatorBuild}.`);
|
console.log(`Installing emulator build ${emulatorBuild}.`);
|
||||||
yield exec.exec(`curl -fo emulator.zip https://dl.google.com/android/repository/emulator-${isOnMac ? 'darwin' : 'linux'}-${emulatorBuild}.zip`);
|
|
||||||
yield io.rmRF(`${process.env.ANDROID_HOME}/emulator`);
|
yield io.rmRF(`${process.env.ANDROID_HOME}/emulator`);
|
||||||
yield exec.exec(`unzip -q emulator.zip -d ${process.env.ANDROID_HOME}`);
|
const downloadPath = yield tc.downloadTool(`https://dl.google.com/android/repository/emulator-${IS_MAC ? 'darwin' : IS_WINDOWS ? 'windows' : 'linux'}-${emulatorBuild}.zip`);
|
||||||
yield io.rmRF('emulator.zip');
|
yield tc.extractZip(downloadPath, process.env.ANDROID_HOME);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
console.log('Installing latest emulator.');
|
console.log('Installing latest emulator.');
|
||||||
yield exec.exec(`sh -c \\"sdkmanager --install emulator > /dev/null"`);
|
yield exec.exec(`sh -c \\"${sdkmanagerExec} --install emulator > /dev/null"`);
|
||||||
}
|
}
|
||||||
console.log('Installing system images.');
|
console.log('Installing system images.');
|
||||||
yield exec.exec(`sh -c \\"sdkmanager --install 'system-images;android-${apiLevel};${target};${arch}' > /dev/null"`);
|
yield exec.exec(`sh -c \\"${sdkmanagerExec} --install 'system-images;android-${apiLevel};${target};${arch}' > /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}' > /dev/null"`);
|
yield exec.exec(`sh -c \\"${sdkmanagerExec} --install 'ndk;${ndkVersion}' > /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}' > /dev/null"`);
|
yield exec.exec(`sh -c \\"${sdkmanagerExec} --install 'cmake;${cmakeVersion}' > /dev/null"`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-9
@@ -7,15 +7,10 @@ import { parseScript } from './script-parser';
|
|||||||
|
|
||||||
async function run() {
|
async function run() {
|
||||||
try {
|
try {
|
||||||
// only support running on macOS or Linux
|
if (process.platform === 'linux') {
|
||||||
if (process.platform !== 'darwin') {
|
console.warn(
|
||||||
if (process.platform === 'linux') {
|
`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.`
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
throw new Error('Unsupported virtual machine: please use either macos or ubuntu VM.');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// API level of the platform and system image
|
// API level of the platform and system image
|
||||||
|
|||||||
+19
-15
@@ -1,10 +1,12 @@
|
|||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
import * as exec from '@actions/exec';
|
import * as exec from '@actions/exec';
|
||||||
import * as io from '@actions/io';
|
import * as io from '@actions/io';
|
||||||
|
import * as tc from '@actions/tool-cache';
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
|
|
||||||
const BUILD_TOOLS_VERSION = '30.0.2';
|
const BUILD_TOOLS_VERSION = '30.0.2';
|
||||||
const CMDLINE_TOOLS_URL_MAC = 'https://dl.google.com/android/repository/commandlinetools-mac-6609375_latest.zip';
|
const CMDLINE_TOOLS_URL_MAC = 'https://dl.google.com/android/repository/commandlinetools-mac-6609375_latest.zip';
|
||||||
|
const CMDLINE_TOOLS_URL_WIN = 'https://dl.google.com/android/repository/commandlinetools-win-6609375_latest.zip';
|
||||||
const CMDLINE_TOOLS_URL_LINUX = 'https://dl.google.com/android/repository/commandlinetools-linux-6609375_latest.zip';
|
const CMDLINE_TOOLS_URL_LINUX = 'https://dl.google.com/android/repository/commandlinetools-linux-6609375_latest.zip';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -12,20 +14,21 @@ 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, emulatorBuild?: string, ndkVersion?: string, cmakeVersion?: string): Promise<void> {
|
export async function installAndroidSdk(apiLevel: number, target: string, arch: string, emulatorBuild?: string, ndkVersion?: string, cmakeVersion?: string): Promise<void> {
|
||||||
const isOnMac = process.platform === 'darwin';
|
const IS_MAC = process.platform === 'darwin';
|
||||||
|
const IS_WINDOWS = process.platform === 'win32';
|
||||||
|
const IS_LINUX = process.platform === 'linux';
|
||||||
|
|
||||||
if (!isOnMac) {
|
if (IS_LINUX) {
|
||||||
await exec.exec(`sh -c \\"sudo chown $USER:$USER ${process.env.ANDROID_HOME} -R`);
|
await exec.exec(`sh -c \\"sudo chown $USER:$USER ${process.env.ANDROID_HOME} -R`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const cmdlineToolsPath = `${process.env.ANDROID_HOME}/cmdline-tools`;
|
const cmdlineToolsPath = `${process.env.ANDROID_HOME}/cmdline-tools`;
|
||||||
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;
|
|
||||||
await io.mkdirP(`${process.env.ANDROID_HOME}/cmdline-tools`);
|
await io.mkdirP(`${process.env.ANDROID_HOME}/cmdline-tools`);
|
||||||
await exec.exec(`curl -fo commandlinetools.zip ${sdkUrl}`);
|
const sdkUrl = IS_MAC ? CMDLINE_TOOLS_URL_MAC : IS_WINDOWS ? CMDLINE_TOOLS_URL_WIN : CMDLINE_TOOLS_URL_LINUX;
|
||||||
await exec.exec(`unzip -q commandlinetools.zip -d ${cmdlineToolsPath}`);
|
const downloadPath = await tc.downloadTool(sdkUrl);
|
||||||
await io.rmRF('commandlinetools.zip');
|
await tc.extractZip(downloadPath, cmdlineToolsPath);
|
||||||
|
|
||||||
// add paths for commandline-tools and platform-tools
|
// add paths for commandline-tools and platform-tools
|
||||||
core.addPath(`${cmdlineToolsPath}/tools:${cmdlineToolsPath}/tools/bin:${process.env.ANDROID_HOME}/platform-tools`);
|
core.addPath(`${cmdlineToolsPath}/tools:${cmdlineToolsPath}/tools/bin:${process.env.ANDROID_HOME}/platform-tools`);
|
||||||
@@ -33,7 +36,7 @@ export async function installAndroidSdk(apiLevel: number, target: string, arch:
|
|||||||
|
|
||||||
// additional permission and license requirements for Linux
|
// additional permission and license requirements for Linux
|
||||||
const sdkPreviewLicensePath = `${process.env.ANDROID_HOME}/licenses/android-sdk-preview-license`;
|
const sdkPreviewLicensePath = `${process.env.ANDROID_HOME}/licenses/android-sdk-preview-license`;
|
||||||
if (!isOnMac && !fs.existsSync(sdkPreviewLicensePath)) {
|
if (IS_LINUX && !fs.existsSync(sdkPreviewLicensePath)) {
|
||||||
fs.writeFileSync(sdkPreviewLicensePath, '\n84831b9409646a918e30573bab4c9c91346d8abd');
|
fs.writeFileSync(sdkPreviewLicensePath, '\n84831b9409646a918e30573bab4c9c91346d8abd');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -45,26 +48,27 @@ export async function installAndroidSdk(apiLevel: number, target: string, arch:
|
|||||||
|
|
||||||
console.log('Installing latest build tools, platform tools, and platform.');
|
console.log('Installing latest build tools, platform tools, and platform.');
|
||||||
|
|
||||||
await exec.exec(`sh -c \\"sdkmanager --install 'build-tools;${BUILD_TOOLS_VERSION}' platform-tools 'platforms;android-${apiLevel}' > /dev/null"`);
|
const sdkmanagerExec = IS_WINDOWS ? 'sdkmanager.bat' : 'sdkmanager';
|
||||||
|
|
||||||
|
await exec.exec(`sh -c \\"${sdkmanagerExec} --install 'build-tools;${BUILD_TOOLS_VERSION}' platform-tools 'platforms;android-${apiLevel}' > /dev/null"`);
|
||||||
if (emulatorBuild) {
|
if (emulatorBuild) {
|
||||||
console.log(`Installing emulator build ${emulatorBuild}.`);
|
console.log(`Installing emulator build ${emulatorBuild}.`);
|
||||||
await exec.exec(`curl -fo emulator.zip https://dl.google.com/android/repository/emulator-${isOnMac ? 'darwin' : 'linux'}-${emulatorBuild}.zip`);
|
|
||||||
await io.rmRF(`${process.env.ANDROID_HOME}/emulator`);
|
await io.rmRF(`${process.env.ANDROID_HOME}/emulator`);
|
||||||
await exec.exec(`unzip -q emulator.zip -d ${process.env.ANDROID_HOME}`);
|
const downloadPath = await tc.downloadTool(`https://dl.google.com/android/repository/emulator-${IS_MAC ? 'darwin' : IS_WINDOWS ? 'windows' : 'linux'}-${emulatorBuild}.zip`);
|
||||||
await io.rmRF('emulator.zip');
|
await tc.extractZip(downloadPath, process.env.ANDROID_HOME);
|
||||||
} else {
|
} else {
|
||||||
console.log('Installing latest emulator.');
|
console.log('Installing latest emulator.');
|
||||||
await exec.exec(`sh -c \\"sdkmanager --install emulator > /dev/null"`);
|
await exec.exec(`sh -c \\"${sdkmanagerExec} --install emulator > /dev/null"`);
|
||||||
}
|
}
|
||||||
console.log('Installing system images.');
|
console.log('Installing system images.');
|
||||||
await exec.exec(`sh -c \\"sdkmanager --install 'system-images;android-${apiLevel};${target};${arch}' > /dev/null"`);
|
await exec.exec(`sh -c \\"${sdkmanagerExec} --install 'system-images;android-${apiLevel};${target};${arch}' > /dev/null"`);
|
||||||
|
|
||||||
if (ndkVersion) {
|
if (ndkVersion) {
|
||||||
console.log(`Installing NDK ${ndkVersion}.`);
|
console.log(`Installing NDK ${ndkVersion}.`);
|
||||||
await exec.exec(`sh -c \\"sdkmanager --install 'ndk;${ndkVersion}' > /dev/null"`);
|
await exec.exec(`sh -c \\"${sdkmanagerExec} --install 'ndk;${ndkVersion}' > /dev/null"`);
|
||||||
}
|
}
|
||||||
if (cmakeVersion) {
|
if (cmakeVersion) {
|
||||||
console.log(`Installing CMake ${cmakeVersion}.`);
|
console.log(`Installing CMake ${cmakeVersion}.`);
|
||||||
await exec.exec(`sh -c \\"sdkmanager --install 'cmake;${cmakeVersion}' > /dev/null"`);
|
await exec.exec(`sh -c \\"${sdkmanagerExec} --install 'cmake;${cmakeVersion}' > /dev/null"`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user