286 lines (264 loc) · 9.51 KB
/
cron_nightly_tests_reusable.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
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
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
# This workflow aim to run all UI tests on active branches
# and upload the report on Google cloud platform storage
name: Nightly tests (Run & Upload)
on:
workflow_call:
inputs:
BRANCH:
required: true
type: string
PHP_VERSION:
required: true
type: string
NODE_VERSION:
description: 'Node Version'
required: false
type: string
default: '14'
TESTS_DIR:
description: 'Where UI tests are'
required: false
type: string
default: 'tests/UI'
secrets:
## GCP Project ID
GC_PROJECT_ID:
required: true
## GCP Service Key
GC_SERVICE_KEY:
required: true
permissions:
contents: read
jobs:
# First job: Run tests in parallel
test:
name: Nightly tests
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
BRANCH:
- ${{ inputs.BRANCH }}
CAMPAIGN:
- 'cldr'
- 'sanity'
- 'sanity:productV2'
- 'functional:BO:login'
- 'functional:BO:dashboard'
- 'functional:BO:orders:01:0-1'
- 'functional:BO:orders:01-create-orders'
- 'functional:BO:orders:01-view-and-edit-order'
- 'functional:BO:orders:02'
- 'functional:BO:orders:03-05'
- 'functional:BO:catalog:01-02'
- 'functional:BO:catalog:03-04'
- 'functional:BO:catalog:05-06'
- 'functional:BO:catalog:07-08'
- 'functional:BO:customer:01'
- 'functional:BO:customer:02-03'
- 'functional:BO:customer-service'
- 'functional:BO:modules'
- 'functional:BO:design'
- 'functional:BO:shipping'
- 'functional:BO:payment'
- 'functional:BO:international:01'
- 'functional:BO:international:02'
- 'functional:BO:international:03-04'
- 'functional:BO:shop-parameters:01-02'
- 'functional:BO:shop-parameters:03-04'
- 'functional:BO:shop-parameters:05-07'
- 'functional:BO:advanced-parameters:01-06'
- 'functional:BO:advanced-parameters:07-10'
- 'functional:BO:advanced-parameters:11-12'
- 'functional:BO:header'
- 'functional:FO:01-03'
- 'functional:FO:04-07'
- 'functional:FO:08-12'
- 'functional:FO:classic:01-03'
- 'functional:FO:classic:04-07'
- 'functional:FO:classic:08-12'
- 'functional:FO:hummingbird:01-03'
- 'functional:FO:hummingbird:04-07'
- 'functional:FO:hummingbird:08-12'
- 'functional:productV2'
- 'functional:API'
- 'functional:WS'
- 'modules'
- 'regression'
exclude:
## 1.7.8.x
- BRANCH: 1.7.8.x
CAMPAIGN: 'cldr'
- BRANCH: 1.7.8.x
CAMPAIGN: 'functional:BO:advanced-parameters:11-12'
- BRANCH: 1.7.8.x
CAMPAIGN: 'functional:BO:dashboard'
- BRANCH: 1.7.8.x
CAMPAIGN: 'functional:productV2'
- BRANCH: 1.7.8.x
CAMPAIGN: 'functional:API'
- BRANCH: 1.7.8.x
CAMPAIGN: 'functional:FO:classic:01-03'
- BRANCH: 1.7.8.x
CAMPAIGN: 'functional:FO:classic:04-07'
- BRANCH: 1.7.8.x
CAMPAIGN: 'functional:FO:classic:08-12'
- BRANCH: 1.7.8.x
CAMPAIGN: 'functional:FO:hummingbird:01-03'
- BRANCH: 1.7.8.x
CAMPAIGN: 'functional:FO:hummingbird:04-07'
- BRANCH: 1.7.8.x
CAMPAIGN: 'functional:FO:hummingbird:08-12'
- BRANCH: 1.7.8.x
CAMPAIGN: 'functional:WS'
- BRANCH: 1.7.8.x
CAMPAIGN: 'modules'
- BRANCH: 1.7.8.x
CAMPAIGN: 'sanity:productV2'
## 8.0.x
- BRANCH: 8.0.x
CAMPAIGN: 'cldr'
- BRANCH: 8.0.x
CAMPAIGN: 'functional:BO:advanced-parameters:11-12'
- BRANCH: 8.0.x
CAMPAIGN: 'functional:BO:dashboard'
- BRANCH: 8.0.x
CAMPAIGN: 'functional:productV2'
- BRANCH: 8.0.x
CAMPAIGN: 'functional:API'
- BRANCH: 8.0.x
CAMPAIGN: 'functional:FO:classic:01-03'
- BRANCH: 8.0.x
CAMPAIGN: 'functional:FO:classic:04-07'
- BRANCH: 8.0.x
CAMPAIGN: 'functional:FO:classic:08-12'
- BRANCH: 8.0.x
CAMPAIGN: 'functional:FO:hummingbird:01-03'
- BRANCH: 8.0.x
CAMPAIGN: 'functional:FO:hummingbird:04-07'
- BRANCH: 8.0.x
CAMPAIGN: 'functional:FO:hummingbird:08-12'
- BRANCH: 8.0.x
CAMPAIGN: 'functional:WS'
- BRANCH: 8.0.x
CAMPAIGN: 'modules'
## 8.1.x
- BRANCH: 8.1.x
CAMPAIGN: 'functional:BO:advanced-parameters:11-12'
- BRANCH: 8.1.x
CAMPAIGN: 'functional:FO:01-03'
- BRANCH: 8.1.x
CAMPAIGN: 'functional:FO:04-07'
- BRANCH: 8.1.x
CAMPAIGN: 'functional:FO:08-12'
- BRANCH: 8.1.x
CAMPAIGN: 'functional:FO:hummingbird:04-07'
- BRANCH: 8.1.x
CAMPAIGN: 'functional:FO:hummingbird:08-12'
## develop
- BRANCH: develop
CAMPAIGN: 'functional:FO:01-03'
- BRANCH: develop
CAMPAIGN: 'functional:FO:04-07'
- BRANCH: develop
CAMPAIGN: 'functional:FO:08-12'
- BRANCH: develop
CAMPAIGN: 'sanity:productV2'
- BRANCH: develop
CAMPAIGN: 'functional:productV2'
env:
GH_BRANCH: ${{ matrix.BRANCH }} # Branch to test
REPORTS_DIR: 'reports_${{ matrix.BRANCH }}' # Where to move test's reports
TEST_CAMPAIGN: ${{ matrix.CAMPAIGN }} # Command to execute from the matrix
INSTALL_AUTO: ${{ (matrix.CAMPAIGN == 'sanity') && 'false' || 'true' }}
ENABLE_SSL: ${{ ((matrix.BRANCH == '8.0.x') || (matrix.BRANCH == '1.7.8.x')) && 'false' || 'true' }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ env.GH_BRANCH }}
- name: Setup Environment
timeout-minutes: 15
uses: ./.github/actions/setup-env
with:
PHP_VERSION: ${{ inputs.PHP_VERSION }}
ENABLE_SSL: ${{ env.ENABLE_SSL }}
INSTALL_AUTO: ${{ env.INSTALL_AUTO }}
CP_API_CONFIG: ${{ (env.GH_BRANCH == '8.1.x') && 'true' || 'false' }}
# Keycloak is only needed for API campaign
- name: Setup Keycloak
uses: ./.github/actions/setup-keycloak
if: ${{ env.GH_BRANCH == 'develop' && env.TEST_CAMPAIGN == 'functional:API' }}
- name: Run Tests
continue-on-error: true
uses: ./.github/actions/ui-test
with:
NODE_VERSION: ${{ inputs.NODE_VERSION }}
TEST_CAMPAIGN: ${{ env.TEST_CAMPAIGN }}
TESTS_DIR: ${{ inputs.TESTS_DIR }}
# Rename and upload report as artifact
- name: Rename file reports
working-directory: ${{ inputs.TESTS_DIR }}
env:
REPORTS_DIR_PATH: ${{ github.workspace }}/${{ env.REPORTS_DIR }}
run: |
mkdir -p ${{ env.REPORTS_DIR_PATH }}
FILENAME="$( echo -e '${{ env.TEST_CAMPAIGN }}' | tr ':' '-' )"
mv ./mochawesome-report/mochawesome.json ${{ env.REPORTS_DIR_PATH }}/${FILENAME}.json
- uses: actions/upload-artifact@v3
name: Upload report
with:
name: reports_${{ env.GH_BRANCH }}
path: ${{ env.REPORTS_DIR }}
# Second job: Merge Mochawesome reports and upload them on GCP
## Always executed even if tests are in error
merge-upload-reports:
name: Combine all reports and upload them
if: ${{ always() }}
needs:
- test
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
BRANCH:
- ${{ inputs.BRANCH }}
env:
GH_BRANCH: ${{ matrix.branch }} # Branch to test
REPORTS_DIR: 'reports_${{ matrix.BRANCH }}' # Where to move test's reports
COMBINED_REPORT_DIR: 'combined_reports' # Where to store the combined report
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ env.GH_BRANCH }}
- uses: actions/download-artifact@v3
name: Download reports
with:
name: reports_${{ env.GH_BRANCH }}
path: ${{ env.REPORTS_DIR }}
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: ${{ inputs.NODE_VERSION }}
- name: Install dependencies
working-directory: ${{ inputs.TESTS_DIR }}
run: npm ci
- name: Combine reports
working-directory: ${{ inputs.TESTS_DIR }}
env:
REPORTS_DIR_PATH: ${{ github.workspace }}/${{ env.REPORTS_DIR }}
COMBINED_REPORT_DIR_PATH: ${{ github.workspace }}/${{ env.COMBINED_REPORT_DIR }}
run: |
mkdir -p ${{ env.COMBINED_REPORT_DIR_PATH }}
REPORT_NAME="$(date +%Y-%m-%d)-${{ env.GH_BRANCH }}"
npx mochawesome-merge "${{ env.REPORTS_DIR_PATH }}/*.json" -o "${{ env.COMBINED_REPORT_DIR_PATH }}/${REPORT_NAME}.json"
- name: Auth Cloud Sdk
uses: google-github-actions/auth@v1
with:
credentials_json: ${{ secrets.GC_SERVICE_KEY }}
project_id: ${{ secrets.GC_PROJECT_ID }}
- name: Setup Cloud Sdk
uses: google-github-actions/setup-gcloud@v1
- name: Upload to Google Cloud Storage (GCS)
run: gsutil cp -r "${{ env.COMBINED_REPORT_DIR }}/**" gs://prestashop-core-nightly/reports