-
Notifications
You must be signed in to change notification settings - Fork 3
189 lines (167 loc) · 6.24 KB
/
test-with-allure-report.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
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
name: Run tests with allure report
on:
pull_request:
branches:
- master
paths:
- 'aquality-appium-mobile-template/**'
- 'aquality-appium-mobile-template-cucumber/**'
- 'aquality-appium-mobile-template-testng/**'
- 'scripts/**'
push:
branches: [ master ]
workflow_dispatch:
inputs:
environment:
type: choice
description: 'App environment'
required: true
default: 'stage'
options:
- prod
- stage
jobs:
build-and-test-android:
env:
CUCUMBER_ALLURE_RESULTS: aquality-appium-mobile-template-cucumber/target/allure-results
TESTNG_ALLURE_RESULTS: aquality-appium-mobile-template-testng/target/allure-results
SUBPROJECT_NAME: aquality-appium-mobile-template-cucumber
ENVIRONMENT: ${{ github.event.inputs.environment == '' && 'stage' || github.event.inputs.environment }}
ANDROID_PROFILE: Nexus 6
ANDROID_TARGET: google_apis
ANDROID_API_LEVEL: 28
ANDROID_ARCH: x86_64
concurrency: test-android-${{ github.event.inputs.environment == '' && 'stage' || github.event.inputs.environment }}
name: Run tests against Android
runs-on: macos-12
outputs:
maven_tests: ${{ steps.maven_tests.outcome }}
steps:
- uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'adopt'
cache: maven
- name: Install and Run Appium Server
run: |
chmod +x ./scripts/PrepareAppiumServerForAndroid.sh
./scripts/PrepareAppiumServerForAndroid.sh
- name: Test against Android
id: maven_tests
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ env.ANDROID_API_LEVEL }}
target: ${{ env.ANDROID_TARGET }}
arch: ${{ env.ANDROID_ARCH }}
profile: ${{ env.ANDROID_PROFILE }}
script: mvn test -DisRemote=true -DplatformName=android
- name: Copy TestNG allure result to the Cucumber allure result
if: always()
run: cp -r ${{ env.TESTNG_ALLURE_RESULTS }}/. ${{ env.CUCUMBER_ALLURE_RESULTS }}
- name: Upload results as artifacts
if: always()
uses: actions/upload-artifact@master
with:
name: allure-results-android
path: ${{ env.SUBPROJECT_NAME }}/target/allure-results
build-and-test-ios:
env:
CUCUMBER_ALLURE_RESULTS: aquality-appium-mobile-template-cucumber/target/allure-results
TESTNG_ALLURE_RESULTS: aquality-appium-mobile-template-testng/target/allure-results
SUBPROJECT_NAME: aquality-appium-mobile-template-cucumber
ENVIRONMENT: ${{ github.event.inputs.environment == '' && 'stage' || github.event.inputs.environment }}
IOS_SIM_MODEL: iPhone 8
concurrency: test-ios-${{ github.event.inputs.environment == '' && 'stage' || github.event.inputs.environment }}
name: Run tests against iOS
runs-on: macos-12
outputs:
maven_tests: ${{ steps.maven_tests.outcome }}
steps:
- uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'adopt'
cache: maven
- name: Install and Run Appium Server
run: |
chmod +x ./scripts/PrepareAppiumServerForIos.sh
./scripts/PrepareAppiumServerForIos.sh
- name: Setup iOS simulator
if: always()
uses: futureware-tech/simulator-action@v2
with:
model: ${{ env.IOS_SIM_MODEL }}
- name: Wait for simulator to be ready
run: |
SIM_UID="$(xcrun simctl list devices | grep -m 1 "$IOS_SIM_MODEL" | grep -E -o -i "([0-9A-F]{8}-([0-9A-F]{4}-){3}[0-9A-F]{12})")"
xcrun simctl bootstatus $SIM_UID
- name: Test against iOS
if: always()
id: maven_tests
run: mvn test -DisRemote=true -DplatformName=ios
- name: Copy TestNG allure result to the Cucumber allure result
if: always()
run: cp -r ${{ env.TESTNG_ALLURE_RESULTS }}/. ${{ env.CUCUMBER_ALLURE_RESULTS }}
- name: Upload results as artifacts
if: always()
uses: actions/upload-artifact@master
with:
name: allure-results-ios
path: ${{ env.SUBPROJECT_NAME }}/target/allure-results
deploy-report:
if: always()
name: Generate and deploy Allure Report
needs: [build-and-test-android, build-and-test-ios]
runs-on: ubuntu-latest
env:
GH_PAGES_URL: https://aquality-automation.github.io/aquality-appium-mobile-java-template
steps:
- name: Get Allure history
uses: actions/checkout@v3
if: always()
continue-on-error: true
with:
ref: gh-pages
path: gh-pages
- name: Download Android results artifacts
if: always()
uses: actions/download-artifact@master
with:
name: allure-results-android
path: target/allure-results
- name: Download iOS results artifacts
if: always()
uses: actions/download-artifact@master
with:
name: allure-results-ios
path: target/allure-results
- name: Generate Allure Report
uses: simple-elf/allure-report-action@master
if: always()
id: allure-report
with:
allure_results: target/allure-results
gh_pages: gh-pages
allure_report: allure-report
allure_history: allure-history
keep_reports: 20
- name: Deploy report to Github Pages
if: always()
uses: peaceiris/actions-gh-pages@v2
env:
PERSONAL_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PUBLISH_BRANCH: gh-pages
PUBLISH_DIR: allure-history
- name: Post the link to the report
if: always()
uses: Sibz/github-status-action@v1
with:
authToken: ${{secrets.GITHUB_TOKEN}}
context: 'Test report'
state: ${{ needs.build-and-test-android.outputs.maven_tests == 'success' && needs.build-and-test-ios.outputs.maven_tests == 'success' && 'success' || 'failure' }}
sha: ${{github.event.pull_request.head.sha || github.sha}}
target_url: ${{ env.GH_PAGES_URL }}/${{github.run_number}}/