-
Notifications
You must be signed in to change notification settings - Fork 53
226 lines (203 loc) · 8.14 KB
/
Copy pathuitests.yaml
File metadata and controls
226 lines (203 loc) · 8.14 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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
name: UITest
on:
workflow_dispatch:
inputs:
device:
required: true
default: 'Pixel8_API33'
type: choice
options:
- 'Pixel8_API33'
- 'Pixel8_API35'
runner:
required: true
default: 'autotestdebug'
type: choice
options:
- 'autotestdebug'
- 'ubuntu-latest'
jobs:
build:
name: build android application for ui tests
runs-on: ${{ github.event.inputs.runner || 'autotestdebug' }}
timeout-minutes: 30
steps:
- name: Print Env Variables
run: env
working-directory: ${{ github.workspace }}
- name: checkout source code of application
uses: actions/checkout@v4
with:
clean: true
path: 'appodeal-android-sdk'
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
- name: Build with Gradle
working-directory: ${{ github.workspace }}/appodeal-android-sdk
run: ./gradlew :banner:assembleDebug
- name: save debug build for aws
uses: actions/upload-artifact@v4
with:
name: banner-debug.apk
path: appodeal-android-sdk/banner/build/outputs/apk/debug/banner-debug.apk
retention-days: 14
tests:
name: run ui tests on aws with appium
needs: build
runs-on: ${{ github.event.inputs.runner || 'autotestdebug' }}
timeout-minutes: 30
steps:
- name: Print Env Variables
run: env
working-directory: ${{ github.workspace }}
- name: checkout source code of application
uses: actions/checkout@v4
with:
path: 'SDK-Auto-Test'
clean: true
repository: 'appodeal/SDK-Auto-Test'
ref: 'aws'
token: ${{ secrets.UITESTREPOACCESS }}
- name: Set up JDK 11
uses: actions/setup-java@v4
with:
java-version: '11'
distribution: 'temurin'
- name: download debug build
uses: actions/download-artifact@v4
with:
name: banner-debug.apk
path: ./SDK-Auto-Test/apk
- name: prepare build
working-directory: ${{ github.workspace }}/SDK-Auto-Test
run: |
mvn clean
sleep 10
mvn jar:jar
sleep 10
mvn jar:test-jar
sleep 10
mvn assembly:assembly -DskipTests -Ddescriptor=src/main/assembly/zip.xml
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-west-2
- name: Upload APK to AWS Device Farm
id: upload-apk
run: |
APP_UPLOAD_RESPONSE=$(aws devicefarm create-upload --project-arn arn:aws:devicefarm:us-west-2:381491970378:project:4c28c1e5-8344-4d34-919c-a1e9377d3b2f --name banner-debug.apk --type ANDROID_APP)
APP_ARN=$(echo $APP_UPLOAD_RESPONSE | jq -r .upload.arn)
echo "APP_ARN=$APP_ARN" >> $GITHUB_ENV
APP_URL=$(echo $APP_UPLOAD_RESPONSE | jq -r .upload.url)
curl -T ./SDK-Auto-Test/apk/banner-debug.apk "$APP_URL"
# Wait until the upload is processed
while [[ "$(aws devicefarm get-upload --arn $APP_ARN | jq -r '.upload.status')" != "SUCCEEDED" ]]; do
echo "Waiting for APK upload to complete..."
sleep 10
done
- name: Upload Test Package to AWS Device Farm
id: upload-tests
run: |
TEST_PACKAGE_UPLOAD_RESPONSE=$(aws devicefarm create-upload --project-arn arn:aws:devicefarm:us-west-2:381491970378:project:4c28c1e5-8344-4d34-919c-a1e9377d3b2f --name zip-with-dependencies.zip --type APPIUM_JAVA_TESTNG_TEST_PACKAGE)
TEST_PACKAGE_ARN=$(echo $TEST_PACKAGE_UPLOAD_RESPONSE | jq -r .upload.arn)
echo "TEST_PACKAGE_ARN=$TEST_PACKAGE_ARN" >> $GITHUB_ENV
TEST_PACKAGE_URL=$(echo $TEST_PACKAGE_UPLOAD_RESPONSE | jq -r .upload.url)
curl -T ./SDK-Auto-Test/target/zip-with-dependencies.zip $TEST_PACKAGE_URL
# Wait until the upload is processed
while [[ "$(aws devicefarm get-upload --arn $TEST_PACKAGE_ARN | jq -r '.upload.status')" != "SUCCEEDED" ]]; do
echo "Waiting for Test Package upload to complete..."
sleep 10
done
- name: Schedule Device Farm Automated Test
id: run-test
uses: aws-actions/aws-devicefarm-mobile-device-testing@v2.3
with:
run-settings-json: |
{
"name": "GitHubAction-${{ github.workflow }}_${{ github.run_id }}_${{ github.run_attempt }}",
"projectArn": "arn:aws:devicefarm:us-west-2:381491970378:project:4c28c1e5-8344-4d34-919c-a1e9377d3b2f",
"appArn": "${{ env.APP_ARN }}",
"devicePoolArn": "arn:aws:devicefarm:us-west-2:381491970378:devicepool:4c28c1e5-8344-4d34-919c-a1e9377d3b2f/86ebd86a-2150-4997-b71f-2e3d72510e0d",
"test": {
"type": "APPIUM_JAVA_TESTNG",
"testPackageArn": "${{ env.TEST_PACKAGE_ARN }}",
"testSpecArn": "default.yml"
}
}
artifact-types: ALL
- uses: actions/upload-artifact@v4
if: always()
with:
name: AutomatedTestOutputFiles
path: ${{ steps.run-test.outputs.artifact-folder }}
- name: Adding summary
if: ${{ always() }}
run: |
echo "### Results of test execution :fire:" >> $GITHUB_STEP_SUMMARY
echo "Launch: ${{ github.run_number }}" >> $GITHUB_STEP_SUMMARY
echo "Device: ${{ github.event.inputs.device }}" >> $GITHUB_STEP_SUMMARY
echo "Build agent: ${{ github.event.inputs.runner }}" >> $GITHUB_STEP_SUMMARY
report:
name: send test report to slack
needs: tests
runs-on: ${{ github.event.inputs.runner || 'autotestdebug' }}
timeout-minutes: 10
steps:
- name: Print Env Variables
run: env
working-directory: ${{ github.workspace }}
- name: checkout source code of application
uses: actions/checkout@v4
with:
path: 'SDK-Auto-Test'
clean: true
repository: 'appodeal/SDK-Auto-Test'
ref: 'aws'
token: ${{ secrets.UITESTREPOACCESS }}
- name: Set up JDK 11
uses: actions/setup-java@v4
with:
java-version: '11'
distribution: 'temurin'
- name: download debug build
uses: actions/download-artifact@v4
with:
name: AutomatedTestOutputFiles
path: ./SDK-Auto-Test/
- name: Copy Junit Reports
if: always()
working-directory: ${{ github.workspace }}/SDK-Auto-Test
env:
DEVICEFARM_LOG_DIR: \$DEVICEFARM_LOG_DIR
run: |
rm -rf saved_reports && mkdir saved_reports
find . -type f -name "00003-Customer Artifacts.zip" | while read -r file; do
unzip "$file" -d "$(dirname "$file")"
test_file_path=$(find "$(dirname "$file")" -type f -name "TEST-tests.example_APD.ApdBannerTest.xml")
if [ -n "$test_file_path" ]; then
echo "Файл найден: $test_file_path"
removed_spaces=$(echo "$test_file_path" | tr -d ' ')
first_directory=$(echo "$removed_spaces" | cut -d'/' -f2)
cp "$test_file_path" ./saved_reports/$first_directory.xml
fi
done
- name: Run JUnitReportParser for all XML files
if: always()
working-directory: ${{ github.workspace }}/SDK-Auto-Test
run: |
chmod +x slack.sh
if [ -d "./saved_reports" ]; then
find ./saved_reports -type f -name "*.xml" | while read -r test_file_path; do
if [ -n "$test_file_path" ]; then
echo "Файл найден: $test_file_path"
./slack.sh "$test_file_path" ${{ secrets.SLACK_WEBHOOK_URL }}
fi
done
else
echo "Directory ./saved_reports does not exist."
fi