Skip to content

Commit 21d991b

Browse files
committed
chore: setup testing android version on BrowserStack
1 parent 31b1eee commit 21d991b

File tree

7 files changed

+68
-5
lines changed

7 files changed

+68
-5
lines changed

.github/workflows/ci.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ jobs:
3636

3737
build-android:
3838
runs-on: ubuntu-latest
39+
env:
40+
BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }}
41+
BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }}
3942
steps:
4043
- uses: actions/checkout@v1
4144
- name: Install Node.js ${{ env.nodejs }}
@@ -53,4 +56,8 @@ jobs:
5356
- name: Add workaround for mipsel reference
5457
run: sudo mkdir -p $ANDROID_HOME/ndk-bundle/toolchains/mips64el-linux-android-4.9/prebuilt/linux-x86_64
5558
- name: Build test app
56-
run: scripts/build-test-app.sh --android --emulator
59+
run: scripts/build-test-app.sh --android --device
60+
- name: Upload artifact to BrowserStack
61+
run: scripts/upload-browserstack.sh --android
62+
- name: Run e2e tests
63+
run: scripts/test-app.sh --android --device

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ matrix:
2727
- npm run testjs &&
2828
npm run updatecert &&
2929
scripts/build-test-app.sh --ios --emulator &&
30-
scripts/upload-artifact.sh --ios &&
30+
scripts/upload-saucelabs.sh --ios &&
3131
scripts/test-app.sh --ios --emulator;
3232

3333
- name: "Android Build & Test"
@@ -55,5 +55,5 @@ matrix:
5555
- npm run testjs &&
5656
npm run updatecert &&
5757
scripts/build-test-app.sh --android --emulator &&
58-
scripts/upload-artifact.sh --android &&
58+
scripts/upload-saucelabs.sh --android &&
5959
scripts/test-app.sh --android --emulator;

scripts/upload-browserstack.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
4+
PLATFORM=$([[ "${@#--android}" = "$@" ]] && echo "ios" || echo "android")
5+
ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )"; cd ..; pwd )"
6+
TEMP=$ROOT/temp
7+
8+
if [ -z $BROWSERSTACK_USERNAME ] || [ -z $BROWSERSTACK_ACCESS_KEY ]; then
9+
echo "Skipping uploading artifact, because BrowserStack credentials are not set.";
10+
exit 0;
11+
fi
12+
13+
if [ $PLATFORM = "android" ]; then
14+
curl -u $BROWSERSTACK_USERNAME:$BROWSERSTACK_ACCESS_KEY \
15+
-X POST \
16+
https://api-cloud.browserstack.com/app-automate/upload \
17+
-F "file=@$TEMP/platforms/android/app/build/outputs/apk/debug/app-debug.apk" \
18+
-F "data={\"custom_id\": \"HttpTestAppAndroid\"}"
19+
else
20+
rm -rf $TEMP/HttpDemo.ipa
21+
pushd $TEMP/platforms/ios/build/emulator
22+
rm -rf ./Payload
23+
mkdir -p ./Payload
24+
cp -r ./HttpDemo.app ./Payload/HttpDemo.app
25+
zip -r $TEMP/HttpDemo.ipa ./Payload
26+
popd
27+
28+
curl -u $BROWSERSTACK_USERNAME:$BROWSERSTACK_ACCESS_KEY \
29+
-X POST \
30+
https://api-cloud.browserstack.com/app-automate/upload \
31+
-F "file=@$TEMP/HttpDemo.ipa" \
32+
-F "data={\"custom_id\": \"HttpTestAppIos\"}"
33+
fi
File renamed without changes.

test/e2e-tooling/caps.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,28 @@ const configs = {
5656
deviceName: 'Android Emulator',
5757
autoWebview: true,
5858
app: 'sauce-storage:HttpDemo.apk'
59+
},
60+
61+
// testing on BrowserStack
62+
browserstackIosDevice: {
63+
device: 'iPhone 7',
64+
os_version: '10',
65+
project: 'HTTP Test App',
66+
autoWebview: true,
67+
app: 'HttpTestAppAndroid'
68+
},
69+
browserstackAndroidDevice: {
70+
device: 'Google Nexus 9',
71+
os_version: '5.1',
72+
project: 'HTTP Test App',
73+
autoWebview: true,
74+
app: 'HttpTestAppAndroid'
5975
}
6076
};
6177

6278
function getCaps(environment, os, runtime) {
6379
const key = environment.toLowerCase() + capitalize(os) + capitalize(runtime);
80+
console.log(key);
6481
const caps = configs[key];
6582

6683
caps.name = `cordova-plugin-advanced-http (${os})`;

test/e2e-tooling/server.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ const configs = {
99
host: 'ondemand.saucelabs.com',
1010
port: 80,
1111
auth: process.env.SAUCE_USERNAME + ":" + process.env.SAUCE_ACCESS_KEY
12+
},
13+
browserstack: {
14+
host: 'hub-cloud.browserstack.com',
15+
port: 80,
16+
auth: process.env.BROWSERSTACK_USERNAME + ":" + process.env.BROWSERSTACK_ACCESS_KEY
1217
}
1318
}
1419

test/e2e-tooling/test.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@ global.should = chai.should();
1212

1313
describe('Advanced HTTP e2e test suite', function () {
1414
const isSauceLabs = !!process.env.SAUCE_USERNAME;
15+
const isBrowserStack = !!process.env.BROWSERSTACK_USERNAME;
1516
const isVerbose = process.argv.includes('--verbose');
1617
const isDevice = process.argv.includes('--device');
1718
const isAndroid = process.argv.includes('--android');
1819

19-
const targetInfo = { isSauceLabs, isDevice, isAndroid };
20-
const environment = isSauceLabs ? 'saucelabs' : 'local';
20+
const targetInfo = { isSauceLabs, isBrowserStack, isDevice, isAndroid };
21+
const environment = isSauceLabs ? 'saucelabs' : isBrowserStack ? 'browserstack' : 'local';
2122

2223
let driver;
2324
let allPassed = true;

0 commit comments

Comments
 (0)