Compare commits

..

8 Commits

Author SHA1 Message Date
Yang Chen 2174e7a027 Merge branch 'master' into release/v1
* master:
  Prepare for release 1.0.2
  Increase emulator boot timeout to 5 mins.
  Update npm packages.
2019-11-30 22:17:06 +11:00
Yang Chen 0d46bc07bd Prepare for release 1.0.2 2019-11-30 22:14:56 +11:00
Yang Chen 0fde7031bc Increase emulator boot timeout to 5 mins. 2019-11-30 22:02:47 +11:00
Yang Chen 8ab242c5c5 Update npm packages. 2019-11-24 18:10:16 +11:00
Yang Chen 6097e0ab6c Merge branch 'master' into release/v1
* master:
  Switch to sh.
  Update README.md
  Fix typos in docs.
2019-11-24 17:54:22 +11:00
Yang Chen b34584f4b0 Switch to sh. 2019-11-24 17:47:07 +11:00
ychescale9 616ba7a3c6 Update README.md 2019-11-23 20:57:10 +11:00
ychescale9 ee7a2b7011 Fix typos in docs. 2019-11-11 16:31:21 +11:00
9 changed files with 42 additions and 25 deletions
+2 -2
View File
@@ -29,8 +29,8 @@ jobs:
uses: ./ uses: ./
with: with:
api-level: ${{ matrix.api-level }} api-level: ${{ matrix.api-level }}
target: default target: google_apis
arch: x86 arch: x86_64
profile: Nexus 6 profile: Nexus 6
headless: true headless: true
disable-animations: true disable-animations: true
+14
View File
@@ -0,0 +1,14 @@
# Change Log
## v1.0.2
* Increased emulator boot timeout to **5 mins**.
## v1.0.1
* Fixed docs.
* Minor internal changes.
## v1.0.0
Initial release.
+8 -7
View File
@@ -8,22 +8,23 @@ A GitHub Action for installing, configuring and running Android Emulators on mac
The old ARM-based emulators were slow and are no longer supported by Google. The modern Intel Atom (x86 and x86_64) emulators require hardware acceleration (HAXM on Mac & Windows, QEMU on Linux) from the host to run fast. This presents a challenge on CI as to be able to run hardware accelerated emulators within a docker container, **KVM** must be supported by the host VM which isn't the case for cloud-based CI providers due to infrastructural limits. The old ARM-based emulators were slow and are no longer supported by Google. The modern Intel Atom (x86 and x86_64) emulators require hardware acceleration (HAXM on Mac & Windows, QEMU on Linux) from the host to run fast. This presents a challenge on CI as to be able to run hardware accelerated emulators within a docker container, **KVM** must be supported by the host VM which isn't the case for cloud-based CI providers due to infrastructural limits.
The **masOS** VM provided by **GitHub Actions** has **HAXM** installed so we are able to create a new AVD instance, launch an emulator with hardware acceleration, and run our Android instrumented tests directly on the VM. The **masOS** VM provided by **GitHub Actions** has **HAXM** installed so we are able to create a new AVD instance, launch an emulator with hardware acceleration, and run our Android
tests directly on the VM.
This Action automates the process by doing the following: This action automates the process by doing the following:
- Install / update the required **Android SDK** components including `build-tools`, `platform-tools`, `platform` (for the required API level), `emulator` and `system-images` (for the required API level). - Install / update the required **Android SDK** components including `build-tools`, `platform-tools`, `platform` (for the required API level), `emulator` and `system-images` (for the required API level).
- Create a new instance of **AVD** with the required [configurations](#configurations). - Create a new instance of **AVD** with the provided [configurations](#configurations).
- Launch a new Emulator with the required [configurations](#configurations). - Launch a new Emulator with the provided [configurations](#configurations).
- Wait until the Emulator is booted and ready for use. - Wait until the Emulator is booted and ready for use.
- Run a custom script provided by the user of the action - e.g. `./gradlew connectedCheck`. - Run a custom script provided by user once the Emulator is up and running - e.g. `./gradlew connectedCheck`.
- Kill the Emulator and the finish the action. - Kill the Emulator and finish the action.
## Usage ## Usage
Note that this action must be run on a **macOS** VM, e.g. `macOS-latest` or `macOS-10.14`. Note that this action must be run on a **macOS** VM, e.g. `macOS-latest` or `macOS-10.14`.
A workflow that uses **android-emulator-runner** to run your instrumented on **API 29**: A workflow that uses **android-emulator-runner** to run your instrumented tests on **API 29**:
``` ```
jobs: jobs:
+2
View File
@@ -5,6 +5,7 @@ Refer to the [recommendeations for versioning and releasing actions](https://git
## New major release ## New major release
- From `master` branch, run `npm run build && npm test --clean && npm run lint` to make sure `lib/*.js` are up-to-date. - From `master` branch, run `npm run build && npm test --clean && npm run lint` to make sure `lib/*.js` are up-to-date.
- Update `CHANGELOG.md`, push change with "Prepare for release X.Y.Z." (where X.Y.Z is the new version).
- Create a new branch e.g. `release/v1`, comment out `node_modules/` in `.gitignore`, commit the change (do not commit yet `node_modules`). - Create a new branch e.g. `release/v1`, comment out `node_modules/` in `.gitignore`, commit the change (do not commit yet `node_modules`).
- Run `npm prune --production`. - Run `npm prune --production`.
- Now commit the changes (the pruned `node_modules`). - Now commit the changes (the pruned `node_modules`).
@@ -17,6 +18,7 @@ Refer to the [recommendeations for versioning and releasing actions](https://git
## New minor / patch release ## New minor / patch release
- From `master` branch, run `npm run build && npm test --clean && npm run lint` to make sure `lib/*.js` are up-to-date. - From `master` branch, run `npm run build && npm test --clean && npm run lint` to make sure `lib/*.js` are up-to-date.
- Update `CHANGELOG.md`, push change with "Prepare for release X.Y.Z." (where X.Y.Z is the new version).
- Merge from `master` into the release branch e.g. `release/v1`. - Merge from `master` into the release branch e.g. `release/v1`.
- Run `npm prune --production`. - Run `npm prune --production`.
- Commit merged changes (and the pruned `node_modules`). - Commit merged changes (and the pruned `node_modules`).
+3 -3
View File
@@ -16,7 +16,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
}; };
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
const exec = __importStar(require("@actions/exec")); const exec = __importStar(require("@actions/exec"));
const EMULATOR_BOOT_TIMEOUT_SECONDS = 120; const EMULATOR_BOOT_TIMEOUT_SECONDS = 300;
const AVD_MANAGER_PATH = `${process.env.ANDROID_HOME}/tools/bin/avdmanager`; const AVD_MANAGER_PATH = `${process.env.ANDROID_HOME}/tools/bin/avdmanager`;
const ADB_PATH = `${process.env.ANDROID_HOME}/platform-tools/adb`; const ADB_PATH = `${process.env.ANDROID_HOME}/platform-tools/adb`;
/** /**
@@ -31,12 +31,12 @@ function launchEmulator(apiLevel, target, arch, profile, headless, disableAnimat
} }
else { else {
console.log(`Creating AVD without custom profile.`); console.log(`Creating AVD without custom profile.`);
yield exec.exec(`bash -c \\"echo no | ${AVD_MANAGER_PATH} create avd --force -n test --abi '${target}/${arch}' --package 'system-images;android-${apiLevel};${target};${arch}'"`); yield exec.exec(`sh -c \\"echo no | ${AVD_MANAGER_PATH} create avd --force -n test --abi '${target}/${arch}' --package 'system-images;android-${apiLevel};${target};${arch}'"`);
} }
// start emulator // start emulator
console.log('Starting emulator.'); console.log('Starting emulator.');
const noWindow = headless ? '-no-window' : ''; const noWindow = headless ? '-no-window' : '';
yield exec.exec(`bash -c \\"${process.env.ANDROID_HOME}/emulator/emulator -avd test ${noWindow} -no-snapshot -noaudio -no-boot-anim &"`); yield exec.exec(`sh -c \\"${process.env.ANDROID_HOME}/emulator/emulator -avd test ${noWindow} -no-snapshot -noaudio -no-boot-anim &"`);
// wait for emulator to complete booting // wait for emulator to complete booting
yield waitForDevice(); yield waitForDevice();
yield exec.exec(`${ADB_PATH} shell input keyevent 82`); yield exec.exec(`${ADB_PATH} shell input keyevent 82`);
+2 -2
View File
@@ -25,9 +25,9 @@ function installAndroidSdk(apiLevel, target, arch) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
const sdkmangerPath = `${process.env.ANDROID_HOME}/tools/bin/sdkmanager`; const sdkmangerPath = `${process.env.ANDROID_HOME}/tools/bin/sdkmanager`;
console.log('Installing latest build tools, platform tools, platform, and emulator.'); console.log('Installing latest build tools, platform tools, platform, and emulator.');
yield exec.exec(`bash -c \\"${sdkmangerPath} --install 'build-tools;${BUILD_TOOLS_VERSION}' platform-tools 'platforms;android-${apiLevel}' emulator > /dev/null"`); yield exec.exec(`sh -c \\"${sdkmangerPath} --install 'build-tools;${BUILD_TOOLS_VERSION}' platform-tools 'platforms;android-${apiLevel}' emulator > /dev/null"`);
console.log('Installing system images.'); console.log('Installing system images.');
yield exec.exec(`bash -c \\"${sdkmangerPath} --install 'system-images;android-${apiLevel};${target};${arch}' > /dev/null"`); yield exec.exec(`sh -c \\"${sdkmangerPath} --install 'system-images;android-${apiLevel};${target};${arch}' > /dev/null"`);
}); });
} }
exports.installAndroidSdk = installAndroidSdk; exports.installAndroidSdk = installAndroidSdk;
+6 -6
View File
@@ -2800,9 +2800,9 @@
"dev": true "dev": true
}, },
"handlebars": { "handlebars": {
"version": "4.5.1", "version": "4.5.3",
"resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.5.1.tgz", "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.5.3.tgz",
"integrity": "sha512-C29UoFzHe9yM61lOsIlCE5/mQVGrnIOrOq7maQl76L7tYPCgC1og0Ajt6uWnX4ZTxBPnjw+CUvawphwCfJgUnA==", "integrity": "sha512-3yPecJoJHK/4c6aZhSvxOyG4vJKDshV36VHp0iVCDVh7o9w2vwi3NSnL2MMPj3YdduqaBcu7cGbggJQM0br9xA==",
"dev": true, "dev": true,
"requires": { "requires": {
"neo-async": "^2.6.0", "neo-async": "^2.6.0",
@@ -5868,9 +5868,9 @@
"dev": true "dev": true
}, },
"uglify-js": { "uglify-js": {
"version": "3.6.7", "version": "3.6.9",
"resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.6.7.tgz", "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.6.9.tgz",
"integrity": "sha512-4sXQDzmdnoXiO+xvmTzQsfIiwrjUCSA95rSP4SEd8tDb51W2TiDOlL76Hl+Kw0Ie42PSItCW8/t6pBNCF2R48A==", "integrity": "sha512-pcnnhaoG6RtrvHJ1dFncAe8Od6Nuy30oaJ82ts6//sGSXOP5UjBMEthiProjXmMNHOfd93sqlkztifFMcb+4yw==",
"dev": true, "dev": true,
"optional": true, "optional": true,
"requires": { "requires": {
+3 -3
View File
@@ -1,6 +1,6 @@
import * as exec from '@actions/exec'; import * as exec from '@actions/exec';
const EMULATOR_BOOT_TIMEOUT_SECONDS = 120; const EMULATOR_BOOT_TIMEOUT_SECONDS = 300;
const AVD_MANAGER_PATH = `${process.env.ANDROID_HOME}/tools/bin/avdmanager`; const AVD_MANAGER_PATH = `${process.env.ANDROID_HOME}/tools/bin/avdmanager`;
const ADB_PATH = `${process.env.ANDROID_HOME}/platform-tools/adb`; const ADB_PATH = `${process.env.ANDROID_HOME}/platform-tools/adb`;
@@ -14,13 +14,13 @@ export async function launchEmulator(apiLevel: number, target: string, arch: str
await exec.exec(`${AVD_MANAGER_PATH} create avd --force -n test --abi "${target}/${arch}" --package "system-images;android-${apiLevel};${target};${arch}" --device "${profile}"`); await exec.exec(`${AVD_MANAGER_PATH} create avd --force -n test --abi "${target}/${arch}" --package "system-images;android-${apiLevel};${target};${arch}" --device "${profile}"`);
} else { } else {
console.log(`Creating AVD without custom profile.`); console.log(`Creating AVD without custom profile.`);
await exec.exec(`bash -c \\"echo no | ${AVD_MANAGER_PATH} create avd --force -n test --abi '${target}/${arch}' --package 'system-images;android-${apiLevel};${target};${arch}'"`); await exec.exec(`sh -c \\"echo no | ${AVD_MANAGER_PATH} create avd --force -n test --abi '${target}/${arch}' --package 'system-images;android-${apiLevel};${target};${arch}'"`);
} }
// start emulator // start emulator
console.log('Starting emulator.'); console.log('Starting emulator.');
const noWindow = headless ? '-no-window' : ''; const noWindow = headless ? '-no-window' : '';
await exec.exec(`bash -c \\"${process.env.ANDROID_HOME}/emulator/emulator -avd test ${noWindow} -no-snapshot -noaudio -no-boot-anim &"`); await exec.exec(`sh -c \\"${process.env.ANDROID_HOME}/emulator/emulator -avd test ${noWindow} -no-snapshot -noaudio -no-boot-anim &"`);
// wait for emulator to complete booting // wait for emulator to complete booting
await waitForDevice(); await waitForDevice();
+2 -2
View File
@@ -9,7 +9,7 @@ const BUILD_TOOLS_VERSION = '29.0.2';
export async function installAndroidSdk(apiLevel: number, target: string, arch: string): Promise<void> { export async function installAndroidSdk(apiLevel: number, target: string, arch: string): Promise<void> {
const sdkmangerPath = `${process.env.ANDROID_HOME}/tools/bin/sdkmanager`; const sdkmangerPath = `${process.env.ANDROID_HOME}/tools/bin/sdkmanager`;
console.log('Installing latest build tools, platform tools, platform, and emulator.'); console.log('Installing latest build tools, platform tools, platform, and emulator.');
await exec.exec(`bash -c \\"${sdkmangerPath} --install 'build-tools;${BUILD_TOOLS_VERSION}' platform-tools 'platforms;android-${apiLevel}' emulator > /dev/null"`); await exec.exec(`sh -c \\"${sdkmangerPath} --install 'build-tools;${BUILD_TOOLS_VERSION}' platform-tools 'platforms;android-${apiLevel}' emulator > /dev/null"`);
console.log('Installing system images.'); console.log('Installing system images.');
await exec.exec(`bash -c \\"${sdkmangerPath} --install 'system-images;android-${apiLevel};${target};${arch}' > /dev/null"`); await exec.exec(`sh -c \\"${sdkmangerPath} --install 'system-images;android-${apiLevel};${target};${arch}' > /dev/null"`);
} }