-
Notifications
You must be signed in to change notification settings - Fork 206
99 lines (95 loc) · 4.61 KB
/
automation-trigger-test.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
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 }}
# 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
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"