Skip to content

Commit f71c6d1

Browse files
committed
Merge branch 'main' into release/v2
* main: Prepare for release 2.20.0. Update manual workflow. Support choosing channel to download SDK components from. build-tools to 31.0.0; SDK cmd-line tools to 5.0. (ReactiveCircus#174) Fix macos-11 VM label. Realm JavaScript is using Android Emulator Runner (ReactiveCircus#182) Add MobileRT to the list of projects (ReactiveCircus#181) Support non-mobile targets (Wear OS, TV) (ReactiveCircus#180) Bump path-parse from 1.0.6 to 1.0.7
2 parents 5de26e4 + 511d462 commit f71c6d1

21 files changed

+268
-51
lines changed

.github/workflows/workflow.yml renamed to .github/workflows/main.yml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ jobs:
1818
os: [macos-latest, ubuntu-latest]
1919
api-level: [16, 23, 29]
2020
target: [default, google_apis]
21+
arch: [x86]
2122
exclude:
2223
- os: ubuntu-latest
2324
api-level: 23
@@ -30,15 +31,18 @@ jobs:
3031
- target: google_apis
3132
api-level: 29
3233
include:
33-
- os: macos-11.0
34-
api-level: 30
35-
target: google_apis
3634
- os: macos-latest
3735
api-level: 24
3836
target: playstore
37+
arch: x86
3938
- os: macos-latest
4039
api-level: 28
4140
target: google_apis
41+
arch: x86
42+
- os: macos-11
43+
api-level: 31
44+
target: google_apis
45+
arch: x86_64
4246

4347
steps:
4448
- name: checkout
@@ -84,7 +88,7 @@ jobs:
8488
with:
8589
api-level: ${{ matrix.api-level }}
8690
target: ${{ matrix.target }}
87-
arch: x86
91+
arch: ${{ matrix.arch }}
8892
profile: Galaxy Nexus
8993
cores: 2
9094
sdcard-path-or-size: 100M
@@ -100,7 +104,7 @@ jobs:
100104
with:
101105
api-level: ${{ matrix.api-level }}
102106
target: ${{ matrix.target }}
103-
arch: x86
107+
arch: ${{ matrix.arch }}
104108
profile: Galaxy Nexus
105109
cores: 2
106110
ram-size: 2048M

.github/workflows/manually.yml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: Manually triggered workflow
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
os:
6+
description: 'OS'
7+
required: true
8+
default: 'macos-latest'
9+
api-level:
10+
description: 'API level of the platform and system image'
11+
required: true
12+
default: '30'
13+
target:
14+
description: 'target of the system image - default, google_apis, google_apis_playstore, android-wear, android-wear-cn, android-tv or google-tv'
15+
required: true
16+
default: 'default'
17+
arch:
18+
description: 'CPU architecture of the system image - x86, x86_64 or arm64-v8a'
19+
default: 'x86'
20+
emulator-options:
21+
description: 'command-line options used when launching the emulator'
22+
default: '-no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim'
23+
emulator-build:
24+
description: 'build number of a specific version of the emulator binary to use'
25+
channel:
26+
description: 'Channel to download the SDK components from - `stable`, `beta`, `dev`, `canary`'
27+
default: 'stable'
28+
script:
29+
description: 'custom script to run - e.g. `./gradlew connectedCheck`'
30+
required: true
31+
default: './gradlew connectedDebugAndroidTest'
32+
33+
jobs:
34+
test:
35+
runs-on: ${{ github.event.inputs.os }}
36+
env:
37+
JAVA_TOOL_OPTIONS: -Xmx4g
38+
timeout-minutes: 15
39+
40+
steps:
41+
- name: checkout
42+
uses: actions/checkout@v2
43+
44+
- name: validate gradle wrapper
45+
uses: gradle/wrapper-validation-action@v1
46+
47+
- name: build, test and lint
48+
run: |
49+
npm install
50+
npm run build
51+
npm run lint
52+
npm test
53+
54+
- name: Java 15
55+
uses: actions/setup-java@v1
56+
with:
57+
java-version: 15
58+
- uses: actions/cache@v2
59+
with:
60+
path: |
61+
~/.gradle/caches
62+
~/.gradle/wrapper
63+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
64+
65+
- name: run action
66+
uses: ./
67+
with:
68+
api-level: ${{ github.event.inputs.api-level }}
69+
target: ${{ github.event.inputs.target }}
70+
arch: ${{ github.event.inputs.arch }}
71+
profile: Galaxy Nexus
72+
emulator-options: ${{ github.event.inputs.emulator-options }}
73+
emulator-build: ${{ github.event.inputs.emulator-build }}
74+
channel: ${{ github.event.inputs.channel }}
75+
working-directory: ./test-fixture/
76+
script: ${{ github.event.inputs.script }}

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Change Log
22

3+
## v2.20.0
4+
5+
* Support non-mobile targets: `android-wear`, `android-wear-cn`, `android-tv` and `google-tv`. - [#180](https://github.com/ReactiveCircus/android-emulator-runner/pull/180) @alexvanyo.
6+
* Update SDK command-line tools to `5.0`. - [#174](https://github.com/ReactiveCircus/android-emulator-runner/pull/174)
7+
* Update build tools to `31.0.0`. - [#174](https://github.com/ReactiveCircus/android-emulator-runner/pull/174)
8+
* Add option to specify the `channel` to download SDK components from: `stable` (default), `beta`, `dev` and `canary`. - [#185](https://github.com/ReactiveCircus/android-emulator-runner/pull/185)
9+
310
## v2.19.1
411

512
* Accept all Android SDL Licenses to fix `sdkmanager` installation. - [#172](https://github.com/ReactiveCircus/android-emulator-runner/pull/172) @marcuspridham.

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ jobs:
159159
| `working-directory` | Optional | `./` | A custom working directory - e.g. `./android` if your root Gradle project is under the `./android` sub-directory within your repository. |
160160
| `ndk` | Optional | N/A | Version of NDK to install - e.g. `21.0.6113669` |
161161
| `cmake` | Optional | N/A | Version of CMake to install - e.g. `3.10.2.4988404` |
162+
| `channel` | Optional | stable | Channel to download the SDK components from - `stable`, `beta`, `dev`, `canary` |
162163
| `script` | Required | N/A | Custom script to run - e.g. to run Android instrumented tests on the emulator: `./gradlew connectedCheck` |
163164

164165
Default `emulator-options`: `-no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim`.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import * as mapper from '../src/channel-id-mapper';
2+
3+
describe('channel id mapper tests', () => {
4+
it('Throws if channelName is unknown', () => {
5+
const func = () => {
6+
mapper.getChannelId('unknown-channel');
7+
};
8+
expect(func).toThrowError(`Unexpected channel name: 'unknown-channel'.`);
9+
});
10+
11+
it('Returns expected channelId from channelName', () => {
12+
expect(mapper.getChannelId('stable')).toBe(0);
13+
expect(mapper.getChannelId('beta')).toBe(1);
14+
expect(mapper.getChannelId('dev')).toBe(2);
15+
expect(mapper.getChannelId('canary')).toBe(3);
16+
});
17+
});

__tests__/input-validator.test.ts

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,29 @@ describe('target validator tests', () => {
5555
expect(func2).not.toThrow();
5656

5757
const func3 = () => {
58-
validator.checkTarget('google_apis');
58+
validator.checkTarget('google_apis_playstore');
5959
};
6060
expect(func3).not.toThrow();
61+
62+
const func4 = () => {
63+
validator.checkTarget('android-wear');
64+
};
65+
expect(func4).not.toThrow();
66+
67+
const func5 = () => {
68+
validator.checkTarget('android-wear-cn');
69+
};
70+
expect(func5).not.toThrow();
71+
72+
const func6 = () => {
73+
validator.checkTarget('android-tv');
74+
};
75+
expect(func6).not.toThrow();
76+
77+
const func7 = () => {
78+
validator.checkTarget('google-tv');
79+
};
80+
expect(func7).not.toThrow();
6181
});
6282
});
6383

@@ -82,6 +102,37 @@ describe('arch validator tests', () => {
82102
});
83103
});
84104

105+
describe('channel validator tests', () => {
106+
it('Throws if channel is unknown', () => {
107+
const func = () => {
108+
validator.checkChannel('some-channel');
109+
};
110+
expect(func).toThrowError(`Value for input.channel 'some-channel' is unknown. Supported options: ${validator.VALID_CHANNELS}`);
111+
});
112+
113+
it('Validates successfully with valid channel', () => {
114+
const func1 = () => {
115+
validator.checkChannel('stable');
116+
};
117+
expect(func1).not.toThrow();
118+
119+
const func2 = () => {
120+
validator.checkChannel('beta');
121+
};
122+
expect(func2).not.toThrow();
123+
124+
const func3 = () => {
125+
validator.checkChannel('dev');
126+
};
127+
expect(func3).not.toThrow();
128+
129+
const func4 = () => {
130+
validator.checkChannel('canary');
131+
};
132+
expect(func4).not.toThrow();
133+
});
134+
});
135+
85136
describe('force-avd-creation validator tests', () => {
86137
it('Throws if force-avd-creation is not a boolean', () => {
87138
const func = () => {

action.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ inputs:
99
description: 'API level of the platform and system image - e.g. 23 for Android Marshmallow, 29 for Android 10'
1010
required: true
1111
target:
12-
description: 'target of the system image - default, google_apis or playstore'
12+
description: 'target of the system image - default, google_apis, google_apis_playstore, android-wear, android-wear-cn, android-tv or google-tv'
1313
default: 'default'
1414
arch:
1515
description: 'CPU architecture of the system image - x86, x86_64 or arm64-v8a'
@@ -49,6 +49,9 @@ inputs:
4949
description: 'version of NDK to install - e.g. 21.0.6113669'
5050
cmake:
5151
description: 'version of CMake to install - e.g. 3.10.2.4988404'
52+
channel:
53+
description: 'Channel to download the SDK components from - `stable`, `beta`, `dev`, `canary`'
54+
default: 'stable'
5255
script:
5356
description: 'custom script to run - e.g. `./gradlew connectedCheck`'
5457
required: true

lib/channel-id-mapper.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
"use strict";
2+
Object.defineProperty(exports, "__esModule", { value: true });
3+
exports.getChannelId = void 0;
4+
function getChannelId(channelName) {
5+
if (channelName === 'stable') {
6+
return 0;
7+
}
8+
else if (channelName === 'beta') {
9+
return 1;
10+
}
11+
else if (channelName === 'dev') {
12+
return 2;
13+
}
14+
else if (channelName === 'canary') {
15+
return 3;
16+
}
17+
else {
18+
throw new Error(`Unexpected channel name: '${channelName}'.`);
19+
}
20+
}
21+
exports.getChannelId = getChannelId;

lib/input-validator.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
"use strict";
22
Object.defineProperty(exports, "__esModule", { value: true });
3-
exports.checkEmulatorBuild = exports.checkDisableLinuxHardwareAcceleration = exports.checkDisableSpellchecker = exports.checkDisableAnimations = exports.checkForceAvdCreation = exports.checkArch = exports.checkTarget = exports.checkApiLevel = exports.VALID_ARCHS = exports.VALID_TARGETS = exports.MIN_API_LEVEL = void 0;
3+
exports.checkEmulatorBuild = exports.checkDisableLinuxHardwareAcceleration = exports.checkDisableSpellchecker = exports.checkDisableAnimations = exports.checkForceAvdCreation = exports.checkChannel = exports.checkArch = exports.checkTarget = exports.checkApiLevel = exports.VALID_CHANNELS = exports.VALID_ARCHS = exports.VALID_TARGETS = exports.MIN_API_LEVEL = void 0;
44
exports.MIN_API_LEVEL = 15;
5-
exports.VALID_TARGETS = ['default', 'google_apis', 'google_apis_playstore'];
5+
exports.VALID_TARGETS = ['default', 'google_apis', 'google_apis_playstore', 'android-wear', 'android-wear-cn', 'android-tv', 'google-tv'];
66
exports.VALID_ARCHS = ['x86', 'x86_64', 'arm64-v8a'];
7+
exports.VALID_CHANNELS = ['stable', 'beta', 'dev', 'canary'];
78
function checkApiLevel(apiLevel) {
89
if (isNaN(Number(apiLevel)) || !Number.isInteger(Number(apiLevel))) {
910
throw new Error(`Unexpected API level: '${apiLevel}'.`);
@@ -25,6 +26,12 @@ function checkArch(arch) {
2526
}
2627
}
2728
exports.checkArch = checkArch;
29+
function checkChannel(channel) {
30+
if (!exports.VALID_CHANNELS.includes(channel)) {
31+
throw new Error(`Value for input.channel '${channel}' is unknown. Supported options: ${exports.VALID_CHANNELS}.`);
32+
}
33+
}
34+
exports.checkChannel = checkChannel;
2835
function checkForceAvdCreation(forceAvdCreation) {
2936
if (!isValidBoolean(forceAvdCreation)) {
3037
throw new Error(`Input for input.force-avd-creation should be either 'true' or 'false'.`);

lib/main.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ const input_validator_1 = require("./input-validator");
3434
const emulator_manager_1 = require("./emulator-manager");
3535
const exec = __importStar(require("@actions/exec"));
3636
const script_parser_1 = require("./script-parser");
37+
const channel_id_mapper_1 = require("./channel-id-mapper");
3738
function run() {
3839
return __awaiter(this, void 0, void 0, function* () {
3940
try {
@@ -123,6 +124,11 @@ function run() {
123124
console.log(`version of CMake to install: ${cmakeInput}`);
124125
}
125126
const cmakeVersion = !cmakeInput ? undefined : cmakeInput;
127+
// channelId (up to and including) to download the SDK packages from
128+
const channelName = core.getInput('channel');
129+
input_validator_1.checkChannel(channelName);
130+
const channelId = channel_id_mapper_1.getChannelId(channelName);
131+
console.log(`Channel: ${channelId} (${channelName})`);
126132
// custom script to run
127133
const scriptInput = core.getInput('script', { required: true });
128134
const scripts = script_parser_1.parseScript(scriptInput);
@@ -131,7 +137,7 @@ function run() {
131137
console.log(`${script}`);
132138
}));
133139
// install SDK
134-
yield sdk_installer_1.installAndroidSdk(apiLevel, target, arch, emulatorBuild, ndkVersion, cmakeVersion);
140+
yield sdk_installer_1.installAndroidSdk(apiLevel, target, arch, channelId, emulatorBuild, ndkVersion, cmakeVersion);
135141
// launch an emulator
136142
yield emulator_manager_1.launchEmulator(apiLevel, target, arch, profile, cores, ramSize, sdcardPathOrSize, avdName, forceAvdCreation, emulatorOptions, disableAnimations, disableSpellchecker, disableLinuxHardwareAcceleration);
137143
// execute the custom script

0 commit comments

Comments
 (0)