ci: enable GH Actions
This adds a working example for iOS
The Chrome tests could work in theory.
The Android testsuite currently times out for unknown reasons.
diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml
new file mode 100644
index 0000000..cb58c4f
--- /dev/null
+++ b/.github/workflows/android.yml
@@ -0,0 +1,59 @@
+# 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: NodeJS ${{ matrix.node-version }} on ${{ matrix.os }}
+ runs-on: ${{ matrix.os }}
+ strategy:
+ matrix:
+ node-version: [12.x]
+ os: [ubuntu-latest]
+
+ steps:
+ - uses: actions/checkout@v2
+
+ - name: Set up JDK 1.8
+ uses: actions/setup-java@v1
+ with:
+ java-version: 1.8
+
+ - name: Use Node.js ${{ matrix.node-version }}
+ uses: actions/setup-node@v1
+ with:
+ node-version: ${{ matrix.node-version }}
+
+ - name: Environment Information
+ run: |
+ node --version
+ npm --version
+
+ - name: npm install
+ run: |
+ export PATH="/usr/local/lib/android/sdk/platform-tools":$PATH
+ npm i -g cordova
+ npm ci
+
+ - name: npm test
+ uses: reactivecircus/android-emulator-runner@v2
+ with:
+ api-level: 28
+ script: node main.js --config ./pr/local/android-5.1.config.json --plugin ./spec/testable-plugin/
diff --git a/.github/workflows/chrome.yml b/.github/workflows/chrome.yml
new file mode 100644
index 0000000..d57525a
--- /dev/null
+++ b/.github/workflows/chrome.yml
@@ -0,0 +1,50 @@
+# 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
+
+ - name: Install Chrome
+ run: |
+ wget -q https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
+ sudo dpkg -i google-chrome-stable_current_amd64.deb
+ sudo alias chrome="google-chrome"
+
+ - 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
+ npm ci
+ node main.js --config ./pr/local/browser.config.json --plugin ./spec/testable-plugin/
diff --git a/.github/workflows/ios.yml b/.github/workflows/ios.yml
new file mode 100644
index 0000000..771e61c
--- /dev/null
+++ b/.github/workflows/ios.yml
@@ -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/
diff --git a/conf/pr/local/android-5.1.config.json b/conf/pr/local/android-5.1.config.json
index 51ffab8..1bca536 100644
--- a/conf/pr/local/android-5.1.config.json
+++ b/conf/pr/local/android-5.1.config.json
@@ -2,6 +2,5 @@
"platform": "android@latest",
"action": "run",
"cleanUpAfterRun": true,
- "target": "api22",
"verbose": true
}
diff --git a/conf/pr/local/ios-11.4.config.json b/conf/pr/local/ios-11.4.config.json
new file mode 100644
index 0000000..27bbc9e
--- /dev/null
+++ b/conf/pr/local/ios-11.4.config.json
@@ -0,0 +1,7 @@
+{
+ "platform": "ios@latest",
+ "action": "run",
+ "cleanUpAfterRun": true,
+ "target": "iPhone-8, 11.4",
+ "verbose": true
+}
diff --git a/lib/ParamedicTargetChooser.js b/lib/ParamedicTargetChooser.js
index 8b4665b..6816c5c 100644
--- a/lib/ParamedicTargetChooser.js
+++ b/lib/ParamedicTargetChooser.js
@@ -32,7 +32,7 @@
}
chooseTarget (emulator, target) {
- let targetObj = '';
+ let targetObj = Q();
switch (this.platform) {
case utilities.ANDROID:
@@ -59,7 +59,7 @@
if (target) {
logger.info('cordova-paramedic: Target defined as: ' + target);
- return { target };
+ return Q({ target });
}
return this.startAnAndroidEmulator(target).then(emulatorId => ({ target: emulatorId }));
diff --git a/lib/paramedic.js b/lib/paramedic.js
index 677ccbb..1ca768d 100644
--- a/lib/paramedic.js
+++ b/lib/paramedic.js
@@ -424,7 +424,7 @@
}
// 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 => {
diff --git a/lib/utils/utilities.js b/lib/utils/utilities.js
index 72f63cd..3248cd2 100644
--- a/lib/utils/utilities.js
+++ b/lib/utils/utilities.js
@@ -88,9 +88,14 @@
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();
}