Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: add gh-actions workflow #215

Merged
merged 15 commits into from
Aug 28, 2021
Merged
81 changes: 81 additions & 0 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

name: Android Testsuite

on: [push, pull_request]

jobs:
test:
name: Android Latest Test
runs-on: macos-latest
dpogue marked this conversation as resolved.
Show resolved Hide resolved

# hoist configurations to top that are expected to be updated
env:
node-version: 16
java-version: 11
java-distro: 'adopt'
android-api: 30

# E.g. android-11 from the file: ./pr/local/android-11.config.json
target-test: android-11

timeout-minutes: 60

steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: ${{ env.node-version }}
- uses: actions/setup-java@v2
with:
distribution: ${{ env.java-distro }}
java-version: ${{ env.java-version }}

- name: Run Environment Information
run: |
node --version
npm --version
java -version

- name: Run npm install
run: |
export PATH="/usr/local/lib/android/sdk/platform-tools":$PATH
export JAVA_HOME=$JAVA_HOME_11_X64
npm i -g cordova
npm ci

- uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ env.android-api }}
target: google_apis
arch: x86_64
force-avd-creation: false
disable-animations: false
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim
script: echo "Pregenerate the AVD before running Paramedic"

- name: Run paramedic tests
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ env.android-api }}
target: google_apis
arch: x86_64
force-avd-creation: false
disable-animations: false
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim
script: node main.js --config ./pr/local/${{ env.target-test }}.config.json --plugin ./spec/testable-plugin/
45 changes: 45 additions & 0 deletions .github/workflows/chrome.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

name: Chrome Testsuite

on: [push, pull_request]

jobs:
test:
name: Chrome Latest Test
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 16

- name: Install xvfb
run: sudo apt-get install xvfb

- name: Environment Information
run: |
node --version
npm --version

- name: npm install and test
run: |
npm i -g cordova
npm ci
xvfb-run --auto-servernum node main.js --config ./pr/local/browser.config.json --plugin ./spec/testable-plugin/
53 changes: 53 additions & 0 deletions .github/workflows/ios.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

name: iOS Testsuite

on: [push, pull_request]

jobs:
test:
name: iOS ${{ matrix.versions.ios }}
runs-on: macos-latest
strategy:
matrix:
versions:
- ios: 13.6
xcode: 11.6

steps:
- uses: actions/checkout@v2

- uses: maxim-lobanov/setup-xcode@v1.1
with:
xcode-version: ${{ matrix.versions.xcode }}

- name: Use Node.js 12
uses: actions/setup-node@v1
with:
node-version: 12

- name: Environment Information
run: |
node --version
npm --version

- name: npm install and test
run: |
npm i -g cordova ios-deploy
npm ci
node main.js --config ./pr/local/ios-13.6.config.json --plugin ./spec/testable-plugin/
7 changes: 7 additions & 0 deletions conf/pr/local/android-11.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"platform": "android@nightly",
"action": "run",
"cleanUpAfterRun": true,
"verbose": true,
"skipAppiumTests": true
}
1 change: 0 additions & 1 deletion conf/pr/local/android-5.1.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@
"platform": "android@latest",
"action": "run",
"cleanUpAfterRun": true,
"target": "api22",
"verbose": true
}
7 changes: 7 additions & 0 deletions conf/pr/local/ios-11.4.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"platform": "ios@latest",
"action": "run",
"cleanUpAfterRun": true,
"target": "iPhone-8, 11.4",
"verbose": true
}
24 changes: 23 additions & 1 deletion lib/ParamedicApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ class ParamedicApp {
this.installPlugins();
this.setUpStartPage();
return this.installPlatform()
.then(() => this.checkPlatformRequirements());
.then(() => this.checkPlatformRequirements())
.then(() => this.checkDumpAndroidManifest())
.then(() => this.checkDumpAndroidConfigXml());
}

installPlugins () {
Expand Down Expand Up @@ -141,6 +143,26 @@ class ParamedicApp {
logger.info('cordova-paramedic: successfully finished checking the requirements for platform: ' + this.platformId);
});
}

checkDumpAndroidManifest () {
if (!this.isAndroid) return Q();

logger.normal('cordova-paramedic: start AndroidManifest.xml Dump');
return execPromise('cat ./platforms/android/app/src/main/AndroidManifest.xml')
.then(() => {
logger.normal('cordova-paramedic: end AndroidManifest.xml Dump');
});
}

checkDumpAndroidConfigXml () {
if (!this.isAndroid) return Q();

logger.normal('cordova-paramedic: start config.xml Dump');
return execPromise('cat ./platforms/android/app/src/main/res/xml/config.xml')
.then(() => {
logger.info('cordova-paramedic: end config.xml Dump');
});
}
}

module.exports = ParamedicApp;
4 changes: 2 additions & 2 deletions lib/ParamedicTargetChooser.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class ParamedicTargetChooser {
}

chooseTarget (emulator, target) {
let targetObj = '';
let targetObj = Q();

switch (this.platform) {
case utilities.ANDROID:
Expand All @@ -59,7 +59,7 @@ class ParamedicTargetChooser {

if (target) {
logger.info('cordova-paramedic: Target defined as: ' + target);
return { target };
return Q({ target });
}

return this.startAnAndroidEmulator(target).then(emulatorId => ({ target: emulatorId }));
Expand Down
2 changes: 2 additions & 0 deletions lib/appium/AppiumRunner.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ class AppiumRunner {
// compose a command to run the Appium server
switch (this.options.platform) {
case utilities.ANDROID:
additionalArgs += ' --allow-insecure chromedriver_autodownload'
break;

case utilities.IOS:
Expand Down Expand Up @@ -339,6 +340,7 @@ function getPackagePath (options) {
case utilities.ANDROID:
let packagePath = null;
const maybePackagePaths = [
path.join(fullAppPath, 'platforms', 'android', 'app', 'build', 'outputs', 'apk', 'debug', 'app-debug.apk'),
path.join(fullAppPath, 'platforms', 'android', 'app', 'build', 'outputs', 'apk', 'android-debug.apk'),
path.join(fullAppPath, 'platforms', 'android', 'build', 'outputs', 'apk', 'debug', 'app-debug.apk')
];
Expand Down
5 changes: 4 additions & 1 deletion lib/appium/helpers/wdHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,20 @@ const { utilities } = require('../../utils');

module.exports.getDriver = function (platform) {
let normalizedPlatform;
let automationName;
let driverConfig = {};
let serverConfig = {};
let driver;

switch (platform.toLowerCase()) {
case utilities.ANDROID:
normalizedPlatform = 'Android';
automationName = 'Appium';
break;

case utilities.IOS:
normalizedPlatform = 'iOS';
automationName = 'XCUITest';
break;

default:
Expand Down Expand Up @@ -79,7 +82,7 @@ module.exports.getDriver = function (platform) {
deviceName: global.DEVICE_NAME || '',
app: global.PACKAGE_PATH,
autoAcceptAlerts: true,
automationName: 'XCUITest'
automationName
};

if (global.UDID) {
Expand Down
2 changes: 1 addition & 1 deletion lib/paramedic.js
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ class ParamedicRunner {
}

// For now we always trying to run test app on emulator
return (new ParamedicTargetChooser(this.tempFolder.name, this.config)).chooseTarget(
return new ParamedicTargetChooser(this.tempFolder.name, this.config).chooseTarget(
true, // useEmulator
this.config.getTarget() // preferredTarget
).then(targetObj => {
Expand Down
11 changes: 8 additions & 3 deletions lib/utils/utilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,14 @@ function getSimulatorModelId (cli, target) {
logger.info(`Filtering for Targeted Emulator: ${target}`);

// Return the individual target that is filtered from the known simulators/emulators based on provided target name. (default: ^iPhone)
return result.stdout
.split('\n')
.filter(i => i.match(target))
const allSimulators = result.stdout
.split('\n');
const matchingSimulators = allSimulators.filter(i => i.match(target));
if (!matchingSimulators.length) {
logger.warn('Unable to find requested simulator, falling back to the first available!');
return allSimulators.filter(i => i.match(/^iPhone/))[0].trim();
}
return matchingSimulators
.pop()
.trim();
}
Expand Down
9 changes: 3 additions & 6 deletions paramedic-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,8 @@
"license": "Apache 2.0",
"description": "Cordova Paramedic Plugin is responsible for the test results reporting",
"main": "paramedic.js",
"engines" : {
"node" : ">=0.11.2"
"engines": {
"node": ">=12.0.0"
},
"repository": {
"type": "git",
"url": "git://github.com/apache/cordova-paramedic.git"
}
"repository": "github:apache/cordova-paramedic"
}
23 changes: 22 additions & 1 deletion paramedic-plugin/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
-->

<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
id="cordova-plugin-paramedic"
xmlns:android="http://schemas.android.com/apk/res/android"
id="cordova-plugin-paramedic"
version="1.2.1-dev">

<name>Paramedic</name>
Expand All @@ -34,4 +35,24 @@
<runs/>
</js-module>

<platform name="ios">
<config-file target="config.xml" parent="/*">
<preference name="scheme" value="app" />
<preference name="hostname" value="localhost" />
</config-file>
</platform>

<platform name="android">
<config-file target="config.xml" parent="/*">
<!-- <preference name="AndroidInsecureFileModeEnabled" value="true" /> -->
<!-- the logging server is http so force the webview to also be http -->
<preference name="scheme" value="http" />
<!-- <preference name="localhost" value="apptest.cordova.apache.org" /> -->
</config-file>

<edit-config file="AndroidManifest.xml" target="/manifest/application" mode="merge">
<!-- Cleartext Traffic should be avoided. Currently the way paramedic proxy the results, cleartext is needed, even when the scheme is set to http. -->
<application android:usesCleartextTraffic="true" />
</edit-config>
</platform>
</plugin>