appium-automation #142
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: appium-automation | |
on: | |
workflow_dispatch: | |
pull_request: | |
types: [ opened, synchronize, reopened ] | |
env: | |
ACCESS_KEY: ${{ secrets.S3_ACCESS_KEY }} | |
SECRET_KEY: ${{ secrets.S3_SECRET_KEY }} | |
BROWSERSTACK_USER: ${{ secrets.BROWSER_STACK_USER }} | |
BROWSERSTACK_KEY: ${{ secrets.BROWSER_STACK_KEY }} | |
IS_RN_APP: true | |
jobs: | |
appium-automation-tests: | |
name: appium-automation-tests | |
runs-on: macos-latest | |
steps: | |
- name: Checkout SDK repo with testbed app | |
uses: actions/checkout@v3 | |
with: | |
path: sdk | |
# point to automation master branch by default | |
- name: Checkout qa automation | |
uses: actions/checkout@v3 | |
with: | |
path: qa | |
repository: BranchMetrics/qentelli-saas-sdk-testing-automation | |
token: ${{ secrets.BRANCHLET_ACCESS_TOKEN_PUBLIC }} | |
ref: b4042d0281b94c539afa835c0b590901d16446fb | |
# ref -> Updating APP_URL of BrowserStack for Android and iOS SDK automation | |
# repo's gradle is configured to run on java 11 | |
- name: Setup java 11 for gradle | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'temurin' | |
java-version: '11' | |
# to reduce complexity, testbed app uses sdk as a project reference | |
- name: Build testbed app for Android | |
run: | | |
cd sdk/branch-sdk-automation-testbed/ | |
npm install | |
cd ./android | |
./gradlew assembleDebug | |
cd ../../ | |
- name: Upload APK to BrowserStack | |
run: | | |
response=$(curl -X POST https://api-cloud.browserstack.com/app-automate/upload -u "${{ secrets.BROWSER_STACK_USER }}:${{ secrets.BROWSER_STACK_KEY }}" -F "file=@sdk/branch-sdk-automation-testbed/android/app/build/outputs/apk/debug/app-debug.apk") | |
parsed=$(echo $response | jq ".app_url") | |
echo "::add-mask::$parsed" | |
echo "APP_URL=$parsed" >> "$GITHUB_ENV" | |
- name: Execute automation tests for Android RN app | |
env: | |
IS_RN_APP: true | |
run: | | |
cd qa | |
echo "APP_URL=$parsed" >> "$GITHUB_ENV" | |
mvn clean test -DsuiteXMLFile=testng.xml -e -DInputFormat="json" -DInputFilePath="TestSelection_BrowserStack_Android_RN.json" -DUploadNewBuild="Yes" | |
- name: Install the Apple certificate and provisioning profile | |
env: | |
BUILD_CERTIFICATE_BASE64: ${{ secrets.BUILD_CERTIFICATE_BASE64 }} | |
P12_PASSWORD: ${{ secrets.P12_PASSWORD }} | |
BUILD_PROVISION_PROFILE_BASE64: ${{ secrets.BUILD_PROVISION_PROFILE_BASE64 }} | |
KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }} | |
run: | | |
# create variables | |
CERTIFICATE_PATH=$RUNNER_TEMP/build_certificate.p12 | |
KEYCHAIN_PATH=$RUNNER_TEMP/app-signing.keychain-db | |
PP_PATH=$RUNNER_TEMP/build_pp.mobileprovision | |
# import certificate | |
echo -n "$BUILD_CERTIFICATE_BASE64" | base64 --decode -o $CERTIFICATE_PATH | |
echo -n "$BUILD_PROVISION_PROFILE_BASE64" | base64 --decode -o $PP_PATH | |
# create temporary keychain | |
security create-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH | |
security set-keychain-settings -lut 21600 $KEYCHAIN_PATH | |
security unlock-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH | |
# import certificate to keychain | |
security import $CERTIFICATE_PATH -P "$P12_PASSWORD" -A -t cert -f pkcs12 -k $KEYCHAIN_PATH | |
security list-keychain -d user -s $KEYCHAIN_PATH | |
# apply provisioning profile | |
mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles | |
cp $PP_PATH ~/Library/MobileDevice/Provisioning\ Profiles | |
- name: Build testbed app for iOS | |
run: | | |
cd sdk/branch-sdk-automation-testbed/ | |
npm install | |
cd ./ios | |
pod install | |
xcodebuild -workspace branch_sdk_react_native_app.xcworkspace -scheme branch_sdk_react_native_app -sdk iphoneos archive -archivePath ./IPA/branch_sdk_react_native_app.xcarchive | |
xcodebuild -exportArchive -archivePath ./IPA/branch_sdk_react_native_app.xcarchive -exportOptionsPlist IPA/Info.plist -exportPath IPA/ | |
- name: Upload IPA to BrowserStack | |
run: | | |
response=$(curl -X POST https://api-cloud.browserstack.com/app-automate/upload -u "${{ secrets.BROWSER_STACK_USER }}:${{ secrets.BROWSER_STACK_KEY }}" -F "file=@sdk/branch-sdk-automation-testbed/ios/IPA/branch_sdk_react_native_app.ipa") | |
parsed=$(echo $response | jq ".app_url") | |
echo "::add-mask::$parsed" | |
echo "APP_URL=$parsed" >> "$GITHUB_ENV" | |
- name: Execute automation for iOS RN app | |
run: | | |
cd qa | |
echo "APP_URL=$parsed" >> "$GITHUB_ENV" | |
mvn clean test -DsuiteXMLFile=testng.xml -e -DInputFormat="json" -DInputFilePath="TestSelection_BrowserStack_iOS_RN.json" -DUploadNewBuild="Yes" |