forked from PrestaShop/PrestaShop
-
Notifications
You must be signed in to change notification settings - Fork 0
197 lines (170 loc) · 6.02 KB
/
cron_nightly_tests.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
# This workflow aim to run all UI tests on active branches
# and upload the report on Google cloud platform storage
name: Nightly tests and report
on:
workflow_run:
workflows: [ 'Nightly Build' ]
types:
- requested
env:
GC_PROJECT_ID: ${{ secrets.GC_PROJECT_ID }} # GCP project id
GC_SERVICE_KEY: ${{ secrets.GC_SERVICE_KEY }} # GCP service key
NODE_VERSION: '14' # Node version on this workflow (For all jobs)
API_NIGHTLY_IMPORT_HOOK: 'https://api-nightly.prestashop.com/hook/reports/import' # Nightly hook to import report
NIGHTLY_TOKEN: ${{ secrets.NIGHTLY_TOKEN }} # Nightly token to validate the import
TESTS_DIR: 'tests/UI' # Where UI tests are
permissions:
contents: read
jobs:
# First job: Run tests in parallel
test:
name: Nightly tests
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
BRANCH:
- develop
- 8.0.x
CAMPAIGN:
- 'sanity'
- 'regression'
- 'functional:BO:login'
- 'functional:BO:orders'
- 'functional:BO:catalog'
- 'functional:BO:customer'
- 'functional:BO:customer-service'
- 'functional:BO:modules'
- 'functional:BO:design'
- 'functional:BO:shipping'
- 'functional:BO:payment'
- 'functional:BO:international'
- 'functional:BO:shop-parameters'
- 'functional:BO:advanced-parameters'
- 'functional:BO:header'
- 'functional:FO'
env:
GH_BRANCH: ${{ matrix.BRANCH }} # Branch to test
REPORTS_DIR: 'reports_${{ matrix.BRANCH }}' # Where to move test's reports
TEST_CAMPAIGN: 'test:${{ matrix.CAMPAIGN }}' # Command to execute from the matrix
PS_LANGUAGE: 'en'
PS_INSTALL_AUTO: 1
PS_DEV_MODE: 0
DB_SERVER: 'mysql'
DB_NAME: 'prestashop'
DB_PREFIX: 'tst_'
DB_USER: 'root'
DB_PASSWD: 'prestashop'
ADMIN_PASSWD: 'Correct Horse Battery Staple'
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
ref: ${{ env.GH_BRANCH }}
# Use docker to create shop
- name: Build and run shop with docker
timeout-minutes: 15
run: |
USER_ID=$(id -u) GROUP_ID=$(id -g) \
docker-compose -f docker-compose.yml up -d --build
bash -c 'while [[ "$(curl -L -s -o /dev/null -w %{http_code} http://localhost:8001/en/)" != "200" ]]; do sleep 5; done'
- name: Setup Node
uses: actions/setup-node@v2
with:
node-version: ${{ env.NODE_VERSION }}
- name: Install dependencies
working-directory: ${{ env.TESTS_DIR }}
run: npm install
- name: Run tests
continue-on-error: true
working-directory: ${{ env.TESTS_DIR }}
env:
URL_FO: 'http://localhost:8001/'
SMTP_SERVER: '172.17.0.1'
run: npm run ${{ env.TEST_CAMPAIGN }}
# Rename and upload report as artifact
- name: Rename file reports
working-directory: ${{ env.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@v2
name: Upload report
with:
name: reports_${{ env.GH_BRANCH }}
path: ${{ env.REPORTS_DIR }}
# Second job: Merge Mochawesome reports and upload them on GCP
merge-upload-reports:
name: Combine all reports and upload them
if: ${{ always() }}
needs:
- test
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
BRANCH:
- develop
- 8.0.x
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@v2
with:
fetch-depth: 0
ref: ${{ env.GH_BRANCH }}
- uses: actions/download-artifact@v2
name: Download reports
with:
name: reports_${{ env.GH_BRANCH }}
path: ${{ env.REPORTS_DIR }}
- name: Setup Node
uses: actions/setup-node@v2
with:
node-version: ${{ env.NODE_VERSION }}
- name: Install dependencies
working-directory: ${{ env.TESTS_DIR }}
run: npm install
- name: Combine reports
working-directory: ${{ env.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"
- uses: google-github-actions/setup-gcloud@v0
name: Setup Cloud Sdk
with:
service_account_key: ${{ env.GC_SERVICE_KEY }}
project_id: ${{ env.GC_PROJECT_ID }}
- name: Upload to Google Cloud Storage (GCS)
run: gsutil cp -r "${{ env.COMBINED_REPORT_DIR }}/**" gs://prestashop-core-nightly/reports
# Add pushed reports to GCp on nightly
push-nightly-reports:
permissions:
contents: none
name: Push reports to nightly.prestashop.com
if: ${{ always() }}
needs:
- merge-upload-reports
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
BRANCH:
- develop
- 8.0.x
env:
GH_BRANCH: ${{ matrix.branch }}
steps:
- name: Push reports
run: |
REPORT_NAME="$(date +%Y-%m-%d)-${{ env.GH_BRANCH }}"
curl -v "${{ env.API_NIGHTLY_IMPORT_HOOK }}?token=${{ env.NIGHTLY_TOKEN }}&filename=${REPORT_NAME}.json"