mirror of
https://github.com/reactivecircus/android-emulator-runner.git
synced 2026-09-03 19:09:32 +00:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2754675516 | |||
| aaa1121ed1 | |||
| ff311e8a7d | |||
| d0fa6c63f8 | |||
| bdf1f83901 | |||
| d3a226f97f | |||
| 4082c705ad |
@@ -28,9 +28,6 @@ jobs:
|
|||||||
npm run lint
|
npm run lint
|
||||||
npm test
|
npm test
|
||||||
|
|
||||||
- name: Prepare test fixture
|
|
||||||
run: cp -a ./test-fixture/* ./
|
|
||||||
|
|
||||||
- name: Java 13
|
- name: Java 13
|
||||||
uses: actions/setup-java@v1
|
uses: actions/setup-java@v1
|
||||||
with:
|
with:
|
||||||
@@ -45,6 +42,8 @@ jobs:
|
|||||||
profile: Nexus 6
|
profile: Nexus 6
|
||||||
emulator-options: -no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim -camera-back none
|
emulator-options: -no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim -camera-back none
|
||||||
disable-animations: true
|
disable-animations: true
|
||||||
|
working-directory: ./test-fixture/
|
||||||
script: |
|
script: |
|
||||||
|
echo $GITHUB_REPOSITORY
|
||||||
./gradlew help
|
./gradlew help
|
||||||
./gradlew connectedDebugAndroidTest
|
./gradlew connectedDebugAndroidTest
|
||||||
|
|||||||
@@ -1,5 +1,13 @@
|
|||||||
# Change Log
|
# Change Log
|
||||||
|
|
||||||
|
## v2.4.0
|
||||||
|
|
||||||
|
* Added support for setting custom `working-directory` - e.g. `./android` if your root Gradle project is under the `./android` sub-directory within your repository.
|
||||||
|
|
||||||
|
## v2.3.2
|
||||||
|
|
||||||
|
* Fixed an issue where environment variables are escaped in script.
|
||||||
|
|
||||||
## v2.3.1
|
## v2.3.1
|
||||||
|
|
||||||
* Bumped Android Build tools to 29.0.3.
|
* Bumped Android Build tools to 29.0.3.
|
||||||
|
|||||||
@@ -76,6 +76,7 @@ jobs:
|
|||||||
| `emulator-options` | Optional | See below | Command-line options used when launching the emulator (replacing all default options) - e.g. `-no-window -no-snapshot -camera-back emulated`. |
|
| `emulator-options` | Optional | See below | Command-line options used when launching the emulator (replacing all default options) - e.g. `-no-window -no-snapshot -camera-back emulated`. |
|
||||||
| `disable-animations` | Optional | `true` | Whether to disable animations - `true` or `false`. |
|
| `disable-animations` | Optional | `true` | Whether to disable animations - `true` or `false`. |
|
||||||
| `emulator-build` | Optional | N/A | Build number of a specific version of the emulator binary to use e.g. `6061023` for emulator v29.3.0.0. |
|
| `emulator-build` | Optional | N/A | Build number of a specific version of the emulator binary to use e.g. `6061023` for emulator v29.3.0.0. |
|
||||||
|
| `working-directory` | Optional | `./` | A custom working directory - e.g. `./android` if your root Gradle project is under the `./android` sub-directory within your repository. |
|
||||||
| `script` | Required | N/A | Custom script to run - e.g. to run Android instrumented tests on the emulator: `./gradlew connectedCheck` |
|
| `script` | Required | N/A | Custom script to run - e.g. to run Android instrumented tests on the emulator: `./gradlew connectedCheck` |
|
||||||
|
|
||||||
Default `emulator-options`: `-no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim`.
|
Default `emulator-options`: `-no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim`.
|
||||||
|
|||||||
+11
-1
@@ -60,6 +60,12 @@ function run() {
|
|||||||
console.log(`using emulator build: ${emulatorBuildInput}`);
|
console.log(`using emulator build: ${emulatorBuildInput}`);
|
||||||
}
|
}
|
||||||
const emulatorBuild = !emulatorBuildInput ? undefined : emulatorBuildInput;
|
const emulatorBuild = !emulatorBuildInput ? undefined : emulatorBuildInput;
|
||||||
|
// custom working directory
|
||||||
|
const workingDirectoryInput = core.getInput('working-directory');
|
||||||
|
if (workingDirectoryInput) {
|
||||||
|
console.log(`custom working directory: ${workingDirectoryInput}`);
|
||||||
|
}
|
||||||
|
const workingDirectory = !workingDirectoryInput ? undefined : workingDirectoryInput;
|
||||||
// custom script to run
|
// custom script to run
|
||||||
const scriptInput = core.getInput('script', { required: true });
|
const scriptInput = core.getInput('script', { required: true });
|
||||||
const scripts = script_parser_1.parseScript(scriptInput);
|
const scripts = script_parser_1.parseScript(scriptInput);
|
||||||
@@ -83,8 +89,12 @@ function run() {
|
|||||||
java_version_manager_1.setJavaHome(defaultJavaHome);
|
java_version_manager_1.setJavaHome(defaultJavaHome);
|
||||||
// execute the custom script
|
// execute the custom script
|
||||||
try {
|
try {
|
||||||
|
// move to custom working directory if set
|
||||||
|
if (workingDirectory) {
|
||||||
|
process.chdir(workingDirectory);
|
||||||
|
}
|
||||||
for (const script of scripts) {
|
for (const script of scripts) {
|
||||||
yield exec.exec(`${script}`);
|
yield exec.exec(`sh -c \\"${script}"`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
|
|||||||
@@ -23,9 +23,9 @@ const BUILD_TOOLS_VERSION = '29.0.3';
|
|||||||
*/
|
*/
|
||||||
function installAndroidSdk(apiLevel, target, arch, emulatorBuild) {
|
function installAndroidSdk(apiLevel, target, arch, emulatorBuild) {
|
||||||
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 sdkmanagerPath = `${process.env.ANDROID_HOME}/tools/bin/sdkmanager`;
|
||||||
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 \\"${sdkmangerPath} --install 'build-tools;${BUILD_TOOLS_VERSION}' platform-tools 'platforms;android-${apiLevel}' > /dev/null"`);
|
yield exec.exec(`sh -c \\"${sdkmanagerPath} --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-darwin-${emulatorBuild}.zip`);
|
yield exec.exec(`curl -fo emulator.zip https://dl.google.com/android/repository/emulator-darwin-${emulatorBuild}.zip`);
|
||||||
@@ -35,10 +35,10 @@ function installAndroidSdk(apiLevel, target, arch, emulatorBuild) {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
console.log('Installing latest emulator.');
|
console.log('Installing latest emulator.');
|
||||||
yield exec.exec(`sh -c \\"${sdkmangerPath} --install emulator > /dev/null"`);
|
yield exec.exec(`sh -c \\"${sdkmanagerPath} --install emulator > /dev/null"`);
|
||||||
}
|
}
|
||||||
console.log('Installing system images.');
|
console.log('Installing system images.');
|
||||||
yield exec.exec(`sh -c \\"${sdkmangerPath} --install 'system-images;android-${apiLevel};${target};${arch}' > /dev/null"`);
|
yield exec.exec(`sh -c \\"${sdkmanagerPath} --install 'system-images;android-${apiLevel};${target};${arch}' > /dev/null"`);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.installAndroidSdk = installAndroidSdk;
|
exports.installAndroidSdk = installAndroidSdk;
|
||||||
|
|||||||
+12
-1
@@ -51,6 +51,13 @@ async function run() {
|
|||||||
}
|
}
|
||||||
const emulatorBuild = !emulatorBuildInput ? undefined : emulatorBuildInput;
|
const emulatorBuild = !emulatorBuildInput ? undefined : emulatorBuildInput;
|
||||||
|
|
||||||
|
// custom working directory
|
||||||
|
const workingDirectoryInput = core.getInput('working-directory');
|
||||||
|
if (workingDirectoryInput) {
|
||||||
|
console.log(`custom working directory: ${workingDirectoryInput}`);
|
||||||
|
}
|
||||||
|
const workingDirectory = !workingDirectoryInput ? undefined : workingDirectoryInput;
|
||||||
|
|
||||||
// custom script to run
|
// custom script to run
|
||||||
const scriptInput = core.getInput('script', { required: true });
|
const scriptInput = core.getInput('script', { required: true });
|
||||||
const scripts = parseScript(scriptInput);
|
const scripts = parseScript(scriptInput);
|
||||||
@@ -78,8 +85,12 @@ async function run() {
|
|||||||
|
|
||||||
// execute the custom script
|
// execute the custom script
|
||||||
try {
|
try {
|
||||||
|
// move to custom working directory if set
|
||||||
|
if (workingDirectory) {
|
||||||
|
process.chdir(workingDirectory);
|
||||||
|
}
|
||||||
for (const script of scripts) {
|
for (const script of scripts) {
|
||||||
await exec.exec(`${script}`);
|
await exec.exec(`sh -c \\"${script}"`);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
core.setFailed(error.message);
|
core.setFailed(error.message);
|
||||||
|
|||||||
@@ -7,9 +7,9 @@ const BUILD_TOOLS_VERSION = '29.0.3';
|
|||||||
* 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): Promise<void> {
|
export async function installAndroidSdk(apiLevel: number, target: string, arch: string, emulatorBuild?: string): Promise<void> {
|
||||||
const sdkmangerPath = `${process.env.ANDROID_HOME}/tools/bin/sdkmanager`;
|
const sdkmanagerPath = `${process.env.ANDROID_HOME}/tools/bin/sdkmanager`;
|
||||||
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 \\"${sdkmangerPath} --install 'build-tools;${BUILD_TOOLS_VERSION}' platform-tools 'platforms;android-${apiLevel}' > /dev/null"`);
|
await exec.exec(`sh -c \\"${sdkmanagerPath} --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-darwin-${emulatorBuild}.zip`);
|
await exec.exec(`curl -fo emulator.zip https://dl.google.com/android/repository/emulator-darwin-${emulatorBuild}.zip`);
|
||||||
@@ -18,8 +18,8 @@ export async function installAndroidSdk(apiLevel: number, target: string, arch:
|
|||||||
await exec.exec(`rm -f emulator.zip`);
|
await exec.exec(`rm -f emulator.zip`);
|
||||||
} else {
|
} else {
|
||||||
console.log('Installing latest emulator.');
|
console.log('Installing latest emulator.');
|
||||||
await exec.exec(`sh -c \\"${sdkmangerPath} --install emulator > /dev/null"`);
|
await exec.exec(`sh -c \\"${sdkmanagerPath} --install emulator > /dev/null"`);
|
||||||
}
|
}
|
||||||
console.log('Installing system images.');
|
console.log('Installing system images.');
|
||||||
await exec.exec(`sh -c \\"${sdkmangerPath} --install 'system-images;android-${apiLevel};${target};${arch}' > /dev/null"`);
|
await exec.exec(`sh -c \\"${sdkmanagerPath} --install 'system-images;android-${apiLevel};${target};${arch}' > /dev/null"`);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user