-
Notifications
You must be signed in to change notification settings - Fork 0
202 lines (180 loc) Β· 6.77 KB
/
regression_tests.yaml
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
name: Regression Tests
on:
workflow_dispatch:
inputs:
marker:
description: 'Test scenario tags'
required: false
type: string
default: ''
environment:
description: 'Environment to run tests against'
type: environment
required: true
default: "dev"
product:
description: 'The product we are testing'
type: choice
options:
- RAVS
required: false
default: RAVS
browser:
description: 'Browser to run tests on'
type: choice
options:
- chrome
- firefox
- safari
- edge
- mobile
required: false
default: "edge"
device:
description: 'Device to run tests on'
type: choice
options:
- iphone_12
- iphone_11
- pixel_5
required: false
default: "iphone_12"
id:
description: 'Unique run identifier (Do not change this)'
required: false
default: "Manually Triggered Run"
pull_request_id:
description: 'The ID of the pull request. This should be in the format pr-xxxx where xxxx is the pull request id'
required: false
default: ""
github_tag:
description: 'The GitHub tag to run the test pack from'
required: false
default: "main"
push:
branches:
- '**'
schedule:
- cron: '0 6 * * *'
- cron: '30 6 * * *'
jobs:
regression_tests:
runs-on: ubuntu-latest
environment: ${{ github.event_name == 'push' && 'dev' || (github.event_name == 'schedule' && github.event.schedule == '0 6 * * *' && 'qa' || (github.event_name == 'workflow_dispatch' && inputs.environment || 'dev')) }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Cache Python dependencies
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Set Environment Variables
run: |
if [[ "${{ github.event_name }}" == "schedule" ]]; then
case "${{ github.event.schedule }}" in
"0 6 * * *")
echo "ENV=qa" >> $GITHUB_ENV
;;
"30 6 * * *")
echo "ENV=dev" >> $GITHUB_ENV
;;
*)
echo "Unrecognized schedule. Defaulting to dev."
echo "ENV=dev" >> $GITHUB_ENV
;;
esac
elif [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
echo "ENV=${{ github.event.inputs.environment }}" >> $GITHUB_ENV
elif [[ "${{ github.event_name }}" == "push" ]]; then
echo "ENV=dev" >> $GITHUB_ENV
else
echo "Unknown event. Defaulting to dev."
echo "ENV=dev" >> $GITHUB_ENV
fi
echo "BROWSER=${{ github.event.inputs.browser || 'edge' }}" >> $GITHUB_ENV
echo "DEVICE=${{ github.event.inputs.device || 'iphone_12' }}" >> $GITHUB_ENV
echo "PRODUCT=${{ github.event.inputs.product || 'RAVS' }}" >> $GITHUB_ENV
- name: Notify Slack - Tests Started
run: |
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
TRIGGER_SOURCE="π *Tests have been kicked off manually by* ${{ github.actor }}."
elif [[ "${{ github.event_name }}" == "schedule" ]]; then
TRIGGER_SOURCE="π *Tests have been triggered by a scheduled run.*"
elif [[ "${{ github.event_name }}" == "push" ]]; then
TRIGGER_SOURCE="π *Tests have been triggered by a code push.*"
else
TRIGGER_SOURCE="π *Tests have started.*"
fi
BROWSER_MESSAGE="${{ env.BROWSER }}"
if [[ "${{ env.BROWSER }}" == "mobile" ]]; then
BROWSER_MESSAGE="Mobile (${{ env.DEVICE }})"
fi
SLACK_MESSAGE="${TRIGGER_SOURCE}\n
*Environment:* ${{ env.ENV }}
*Product:* ${{ env.PRODUCT }}
*Run ID:* ${{ github.run_id }}
*Browser:* ${BROWSER_MESSAGE}
*Branch:* ${{ github.ref_name }}"
curl -X POST -H 'Content-type: application/json' --data "{\"text\":\"${SLACK_MESSAGE}\"}" ${{ secrets.SLACK_WEBHOOK_URL }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Install xvfb
run: sudo apt-get install xvfb
- name: Install Playwright
run: |
python -m pip install playwright
playwright install
playwright install --with-deps webkit
playwright install-deps
- name: Install Allure Commandline
run: |
curl -o allure-commandline-2.17.3.tgz -Ls https://repo.maven.apache.org/maven2/io/qameta/allure/allure-commandline/2.17.3/allure-commandline-2.17.3.tgz && \
tar -zxvf allure-commandline-2.17.3.tgz -C /opt/ && \
sudo ln -s /opt/allure-2.17.3/bin/allure /usr/bin/allure && \
rm -rf allure-commandline-2.17.3.tgz
- name: Run Tests
env:
TZ: "Europe/London"
LANG: "en_GB.UTF-8"
LC_ALL: "en_GB.UTF-8"
TEST_ENVIRONMENT: ${{ env.ENV }}
RAVS_PASSWORD: ${{ secrets.RAVS_PASSWORD }}
HEADLESS_MODE: "true"
BROWSER: ${{ env.BROWSER }}
DEVICE: ${{ env.DEVICE }}
MARKER: ${{ inputs.marker || '' }}
AGENTS: 3
run: |
tox -v
continue-on-error: true
- name: Upload Allure Results
uses: actions/upload-artifact@v4
with:
name: allure-results
path: allure-results
if-no-files-found: error
- name: Generate a token
id: generate-token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ secrets.EPS_REGRESSION_TESTING_APP_ID }}
private-key: ${{ secrets.EPS_REGRESSION_TESTING_PEM }}
owner: "NHSDigital"
repositories: "ravs-tests,ravs-test-reports"
- name: Trigger test report generation
run: |
curl -X POST \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
-H "Authorization: Bearer ${{ steps.generate-token.outputs.token }}" \
-d '{"ref": "main", "inputs": {"run_id": "${{ github.run_id }}", "browser": "${{ env.BROWSER }}", "device": "${{ env.DEVICE }}"}}' \
"https://api.github.com/repos/NHSDigital/ravs-test-reports/actions/workflows/publish_report.yml/dispatches"