forked from forcedotcom/SalesforceMobileSDK-Android
-
Notifications
You must be signed in to change notification settings - Fork 1
143 lines (136 loc) · 5.67 KB
/
Copy pathreusable-ui-workflow.yaml
File metadata and controls
143 lines (136 loc) · 5.67 KB
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
on:
workflow_call:
inputs:
is_pr:
type: boolean
default: false
jobs:
test-android:
runs-on: ubuntu-latest
env:
BUNDLE_GEMFILE: ${{ github.workspace }}/.github/DangerFiles/Gemfile
steps:
- uses: actions/checkout@v4
if: ${{ inputs.is_pr }}
with:
# We need a sufficient depth or Danger will occasionally run into issues checking which files were modified.
fetch-depth: 100
ref: ${{ github.event.pull_request.head.sha }}
- uses: actions/checkout@v4
if: ${{ ! inputs.is_pr }}
with:
ref: ${{ github.head_ref }}
- name: Install Dependencies
env:
TEST_CREDENTIALS: ${{ secrets.TEST_CREDENTIALS }}
UI_TEST_CONFIG: ${{ secrets.UI_TEST_CONFIG }}
run: |
./install.sh
echo $TEST_CREDENTIALS > ./shared/test/test_credentials.json
echo $UI_TEST_CONFIG > ./shared/test/ui_test_config.json
- uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '21'
- name: Setup Android SDK
uses: android-actions/setup-android@v3
- uses: gradle/actions/setup-gradle@v4
with:
# This is the actual Gradle version (not AGP), which can be found in the gradle-wrapper.properties file.
gradle-version: "8.14.3"
add-job-summary: on-failure
add-job-summary-as-pr-comment: on-failure
- name: Build for Testing
if: success() || failure()
run: |
./gradlew native:NativeSampleApps:AuthFlowTester:assembleDebug
- name: Build Tests
run: |
./gradlew native:NativeSampleApps:AuthFlowTester:assembleAndroidTest
- uses: 'google-github-actions/auth@v2'
if: success() || failure()
with:
credentials_json: '${{ secrets.GCLOUD_SERVICE_KEY }}'
- uses: 'google-github-actions/setup-gcloud@v2'
if: success() || failure()
- name: Run Tests
continue-on-error: true
if: success() || failure()
env:
# Most used according to https://gs.statcounter.com/android-version-market-share/mobile-tablet/worldwide
PR_API_VERSION: "35"
FULL_API_RANGE: "28 29 30 31 32 33 34 35 36"
IS_PR: ${{ inputs.is_pr }}
CI_USER_USERNAME: ${{ secrets.CI_USER_USERNAME }}
CI_USER_PASSWORD: ${{ secrets.CI_USER_PASSWORD }}
run: |
LEVELS_TO_TEST=$FULL_API_RANGE
RETRIES=0
TEST_TARGETS=""
if $IS_PR ; then
LEVELS_TO_TEST=$PR_API_VERSION
RETRIES=1
# Run only a single test named "testLogin"
TEST_TARGETS="--test-targets \"class com.salesforce.samples.authflowtester.LoginTest#testLogin\""
fi
mkdir firebase_results
for LEVEL in $LEVELS_TO_TEST
do
GCLOUD_RESULTS_DIR=authflowtester-api-${LEVEL}-build-${{github.run_number}}
eval gcloud firebase test android run \
--project mobile-apps-firebase-test \
--type instrumentation \
--app "native/NativeSampleApps/AuthFlowTester/build/outputs/apk/debug/AuthFlowTester-debug.apk" \
--test "native/NativeSampleApps/AuthFlowTester/build/outputs/apk/androidTest/debug/AuthFlowTester-debug-androidTest.apk" \
--device model=MediumPhone.arm,version=${LEVEL},locale=en,orientation=portrait \
--environment-variables username=${CI_USER_USERNAME},password=${CI_USER_PASSWORD} \
--directories-to-pull=/sdcard \
--results-dir=${GCLOUD_RESULTS_DIR} \
--results-history-name=AuthFlowTester \
--timeout=5m --no-performance-metrics \
$TEST_TARGETS \
--num-flaky-test-attempts=${RETRIES} || true
done
- name: Copy Test Results
continue-on-error: true
if: success() || failure()
env:
# Most used according to https://gs.statcounter.com/android-version-market-share/mobile-tablet/worldwide
PR_API_VERSION: "35"
FULL_API_RANGE: "28 29 30 31 32 33 34 35 36"
IS_PR: ${{ inputs.is_pr }}
run: |
LEVELS_TO_TEST=$FULL_API_RANGE
if $IS_PR ; then
LEVELS_TO_TEST=$PR_API_VERSION
fi
for LEVEL in $LEVELS_TO_TEST
do
GCLOUD_RESULTS_DIR=authflowtester-api-${LEVEL}-build-${{github.run_number}}
BUCKET_PATH="gs://test-lab-w87i9sz6q175u-kwp8ium6js0zw/${GCLOUD_RESULTS_DIR}"
gsutil ls ${BUCKET_PATH} > /dev/null 2>&1
if [ $? == 0 ] ; then
# Copy XML file for test reporting
if gsutil ls "${BUCKET_PATH}/*test_results_merged.xml" > /dev/null 2>&1; then
# Sharded runs produce test_results_merged.xml at top level
gsutil cp "${BUCKET_PATH}/*test_results_merged.xml" firebase_results/api_${LEVEL}_test_result.xml
else
gsutil cp "${BUCKET_PATH}/*/test_result_1.xml" firebase_results/api_${LEVEL}_test_result.xml
fi
fi
done
- name: Test Report
uses: mikepenz/action-junit-report
if: success() || failure()
with:
check_name: ${{ inputs.lib }} Test Results
job_name: ${{ inputs.lib }} Test Results
require_tests: true
check_retries: true
flaky_summary: true
fail_on_failure: true
group_reports: false
include_passed: true
include_empty_in_summary: false
simplified_summary: true
report_paths: 'firebase_results/**.xml'