-
Notifications
You must be signed in to change notification settings - Fork 0
235 lines (209 loc) Β· 8.78 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
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
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
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:
- '**' # Triggers on push to any branch
schedule:
# QA environment at 6:00 AM UTC
- cron: '0 6 * * *' # This will run the tests for the QA environment
# DEV environment at 6:30 AM UTC
- cron: '30 6 * * *' # This will run the tests for the DEV environment
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')) }} # Dynamically set environment based on event type
steps:
# Step 1: Checkout the repository
- name: Checkout code
uses: actions/checkout@v4
# Step 2: Cache Python dependencies
- 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=${{ 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
# - name: Notify Slack - Test Run Started
# if: ${{ github.event_name == 'workflow_dispatch' }}
# run: |
# BRANCH_NAME=${{ github.ref_name || 'manual trigger (branch not specified)' }}
# curl -X POST -H 'Content-type: application/json' \
# --data '{
# "text": "π Tests have been kicked off manually by *${{ github.actor }}*.\n*Environment:* ${{ inputs.environment }}\n*Product:* RAVS\n*Run ID:* ${{ github.run_id }}\n*Branch:* '$BRANCH_NAME'"
# }' \
# ${{ secrets.SLACK_WEBHOOK_URL }}
- name: Notify Slack - Test Run Started
if: ${{ github.event_name == 'workflow_dispatch' }}
run: |
# Detect Azure DevOps trigger
if [[ "${{ github.actor }}" == "azure-pipelines[bot]" ]] || [[ "${{ github.event.inputs.trigger_source }}" == "Azure devops" ]]; then
TRIGGER_SOURCE="Azure DevOps Pipeline"
else
TRIGGER_SOURCE="manually by *${{ github.actor }}*"
fi
# Branch name
BRANCH_NAME=${{ github.ref_name || 'manual trigger (branch not specified)' }}
# Notify Slack
curl -X POST -H 'Content-type: application/json' \
--data "{
\"text\": \"π Tests have been kicked off $TRIGGER_SOURCE.\n*Environment:* ${{ inputs.environment }}\n*Product:* RAVS\n*Run ID:* ${{ github.run_id }}\n*Branch:* ${BRANCH_NAME}\"
}" \
${{ secrets.SLACK_WEBHOOK_URL }}
- name: Notify Slack - Test Run Started
if: ${{ github.event_name == 'push' }}
run: |
curl -X POST -H 'Content-type: application/json' \
--data '{"text": "π Tests have been triggered by a push to branch *${{ github.ref_name }}*.\n*Environment:* ${{ env.ENV }}\n*Product:* RAVS\n*Run ID:* ${{ github.run_id }}"}' \
${{ secrets.SLACK_WEBHOOK_URL }}
- name: Notify Slack - Test Run Started
if: ${{ github.event_name == 'schedule' }}
run: |
curl -X POST -H 'Content-type: application/json' \
--data '{"text": "π Tests have been triggered by a scheduled run.\n*Environment:* ${{ env.ENV }}\n*Product:* RAVS\n*Run ID:* ${{ github.run_id }}"}' \
${{ secrets.SLACK_WEBHOOK_URL }}
- name: Set up en_GB.UTF-8 locale
run: |
sudo apt-get update
sudo apt-get install -y locales
sudo locale-gen "en_GB.UTF-8"
sudo update-locale LANG=en_GB.UTF-8 LANGUAGE=en_GB:en LC_ALL=en_GB.UTF-8
env:
DEBIAN_FRONTEND: noninteractive
# Step 3: Set up Python 3.11
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
# Step 4: Install Python dependencies from requirements.txt
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
# Step 5: Cache Playwright binaries
- name: Cache Playwright binaries
uses: actions/cache@v4
with:
path: ~/.cache/ms-playwright
key: ${{ runner.os }}-playwright-${{ inputs.environment }}
restore-keys: |
${{ runner.os }}-playwright-
# Step 6: Install Playwright dependencies
- name: Install Playwright dependencies
run: |
python -m pip install playwright
playwright install
playwright install-deps
# Step 7: Install Allure Commandline
- 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
# Step 8: Verify Allure Installation
- name: Verify Allure Installation
run: allure --version
# Step 9: Debug tox.ini content for visibility
- name: Debug tox.ini
run: cat tox.ini
- name: Debug regression_tests.yaml
run: cat .github/workflows/regression_tests.yaml
- name: Debug locale settings
run: |
echo "Current Locale:"
locale
# Step 10: Run Tests using tox
- name: Run Tests
env:
TZ: "Europe/London"
LANG: "en_GB.UTF-8"
LANGUAGE: "en_GB:en"
LC_ALL: "en_GB.UTF-8"
TEST_ENVIRONMENT: ${{ github.event_name == 'push' && 'dev' || (github.event_name == 'schedule' && github.event.schedule == '0 6 * * *' && 'qa' || (github.event_name == 'workflow_dispatch' && inputs.environment || 'dev')) }}
RAVS_PASSWORD: ${{ secrets.RAVS_PASSWORD }}
HEADLESS_MODE: "true"
BROWSER: "edge"
MARKER: ${{ inputs.marker || '' }}
AGENTS: 3
run: |
tox -v
continue-on-error: true
# Step 11: Upload Allure Results as an artifact
- name: Upload Allure Results
uses: actions/upload-artifact@v4
with:
name: allure-results
path: allure-results
if-no-files-found: error
# Step 12: Generate a token and trigger report generation
- 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 }}"}}' \
"https://api.github.com/repos/NHSDigital/ravs-test-reports/actions/workflows/publish_report.yml/dispatches"