Skip to content

Commit

Permalink
chore: setup testing android version on BrowserStack
Browse files Browse the repository at this point in the history
  • Loading branch information
silkimen committed Dec 14, 2019
1 parent 31b1eee commit 21d991b
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 5 deletions.
9 changes: 8 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ jobs:

build-android:
runs-on: ubuntu-latest
env:
BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }}
BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }}
steps:
- uses: actions/checkout@v1
- name: Install Node.js ${{ env.nodejs }}
Expand All @@ -53,4 +56,8 @@ jobs:
- name: Add workaround for mipsel reference
run: sudo mkdir -p $ANDROID_HOME/ndk-bundle/toolchains/mips64el-linux-android-4.9/prebuilt/linux-x86_64
- name: Build test app
run: scripts/build-test-app.sh --android --emulator
run: scripts/build-test-app.sh --android --device
- name: Upload artifact to BrowserStack
run: scripts/upload-browserstack.sh --android
- name: Run e2e tests
run: scripts/test-app.sh --android --device
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ matrix:
- npm run testjs &&
npm run updatecert &&
scripts/build-test-app.sh --ios --emulator &&
scripts/upload-artifact.sh --ios &&
scripts/upload-saucelabs.sh --ios &&
scripts/test-app.sh --ios --emulator;

- name: "Android Build & Test"
Expand Down Expand Up @@ -55,5 +55,5 @@ matrix:
- npm run testjs &&
npm run updatecert &&
scripts/build-test-app.sh --android --emulator &&
scripts/upload-artifact.sh --android &&
scripts/upload-saucelabs.sh --android &&
scripts/test-app.sh --android --emulator;
33 changes: 33 additions & 0 deletions scripts/upload-browserstack.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env bash
set -e

PLATFORM=$([[ "${@#--android}" = "$@" ]] && echo "ios" || echo "android")
ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )"; cd ..; pwd )"
TEMP=$ROOT/temp

if [ -z $BROWSERSTACK_USERNAME ] || [ -z $BROWSERSTACK_ACCESS_KEY ]; then
echo "Skipping uploading artifact, because BrowserStack credentials are not set.";
exit 0;
fi

if [ $PLATFORM = "android" ]; then
curl -u $BROWSERSTACK_USERNAME:$BROWSERSTACK_ACCESS_KEY \
-X POST \
https://api-cloud.browserstack.com/app-automate/upload \
-F "file=@$TEMP/platforms/android/app/build/outputs/apk/debug/app-debug.apk" \
-F "data={\"custom_id\": \"HttpTestAppAndroid\"}"
else
rm -rf $TEMP/HttpDemo.ipa
pushd $TEMP/platforms/ios/build/emulator
rm -rf ./Payload
mkdir -p ./Payload
cp -r ./HttpDemo.app ./Payload/HttpDemo.app
zip -r $TEMP/HttpDemo.ipa ./Payload
popd

curl -u $BROWSERSTACK_USERNAME:$BROWSERSTACK_ACCESS_KEY \
-X POST \
https://api-cloud.browserstack.com/app-automate/upload \
-F "file=@$TEMP/HttpDemo.ipa" \
-F "data={\"custom_id\": \"HttpTestAppIos\"}"
fi
File renamed without changes.
17 changes: 17 additions & 0 deletions test/e2e-tooling/caps.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,28 @@ const configs = {
deviceName: 'Android Emulator',
autoWebview: true,
app: 'sauce-storage:HttpDemo.apk'
},

// testing on BrowserStack
browserstackIosDevice: {
device: 'iPhone 7',
os_version: '10',
project: 'HTTP Test App',
autoWebview: true,
app: 'HttpTestAppAndroid'
},
browserstackAndroidDevice: {
device: 'Google Nexus 9',
os_version: '5.1',
project: 'HTTP Test App',
autoWebview: true,
app: 'HttpTestAppAndroid'
}
};

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

caps.name = `cordova-plugin-advanced-http (${os})`;
Expand Down
5 changes: 5 additions & 0 deletions test/e2e-tooling/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ const configs = {
host: 'ondemand.saucelabs.com',
port: 80,
auth: process.env.SAUCE_USERNAME + ":" + process.env.SAUCE_ACCESS_KEY
},
browserstack: {
host: 'hub-cloud.browserstack.com',
port: 80,
auth: process.env.BROWSERSTACK_USERNAME + ":" + process.env.BROWSERSTACK_ACCESS_KEY
}
}

Expand Down
5 changes: 3 additions & 2 deletions test/e2e-tooling/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ global.should = chai.should();

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

const targetInfo = { isSauceLabs, isDevice, isAndroid };
const environment = isSauceLabs ? 'saucelabs' : 'local';
const targetInfo = { isSauceLabs, isBrowserStack, isDevice, isAndroid };
const environment = isSauceLabs ? 'saucelabs' : isBrowserStack ? 'browserstack' : 'local';

let driver;
let allPassed = true;
Expand Down

0 comments on commit 21d991b

Please sign in to comment.