Skip to content

Commit 9443259

Browse files
authored
Merge pull request #791 from NHSDigital/containerized_regression_tests_for_PRs
Containerized regression tests for p rs
2 parents e866b32 + ccb0823 commit 9443259

File tree

5 files changed

+197
-25
lines changed

5 files changed

+197
-25
lines changed

.github/actions/deploy-reports/action.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,16 @@ runs:
2323
id: set-pages-dir
2424
run: |
2525
sanitized_device=$(echo "${{ inputs.device }}" | tr -cd '[:alnum:]_-')
26-
echo "dir=${{ github.ref_name }}/${{ inputs.environment }}/$sanitized_device" >> $GITHUB_OUTPUT
26+
echo "dir=${{ github.head_ref }}/${{ inputs.environment }}/$sanitized_device" >> $GITHUB_OUTPUT
2727
shell: bash
2828

2929
- name: Checkout gh-pages branch
30-
uses: actions/checkout@v4
30+
uses: actions/checkout@v6
3131
with:
32+
repository: NHSDigital/manage-vaccinations-in-schools-testing
3233
ref: gh-pages
3334
path: gh-pages
35+
token: ${{ env.GITHUB_TOKEN }}
3436

3537
- name: Replace existing report
3638
run: |
@@ -53,8 +55,6 @@ runs:
5355
git push origin gh-pages --force
5456
git branch -D temp-pages
5557
shell: bash
56-
env:
57-
GITHUB_TOKEN: ${{ env.GITHUB_TOKEN }}
5858

5959
- name: Set Job Summary
6060
run: |

.github/actions/run-functional-tests/action.yml

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,15 @@ description: 'Execute tests'
33
inputs:
44
tests:
55
default: ''
6+
github_ref:
7+
default: 'main'
8+
required: false
69
accessibility_tests:
710
default: 'false'
11+
reporting_tests:
12+
default: 'false'
13+
imms_api_tests:
14+
default: 'false'
815
device:
916
required: true
1017
base_url:
@@ -43,11 +50,28 @@ runs:
4350
- name: Choose test suite to run
4451
id: marker
4552
run: |
46-
if [ "${{ inputs.accessibility_tests }}" = "true" ]; then
47-
echo "marker=accessibility" >> $GITHUB_OUTPUT
48-
else
49-
echo "marker=not accessibility" >> $GITHUB_OUTPUT
53+
exclude=""
54+
if [ "${{ inputs.accessibility_tests }}" = "false" ]; then
55+
exclude="not accessibility"
56+
fi
57+
if [ "${{ inputs.reporting_tests }}" = "false" ]; then
58+
if [ -n "$exclude" ]; then
59+
exclude="$exclude and not reporting"
60+
else
61+
exclude="not reporting"
62+
fi
63+
fi
64+
if [ "${{ inputs.imms_api_tests }}" = "false" ]; then
65+
if [ -n "$exclude" ]; then
66+
exclude="$exclude and not imms_api"
67+
else
68+
exclude="not imms_api"
69+
fi
70+
fi
71+
if [ -z "$exclude" ]; then
72+
exclude="True"
5073
fi
74+
echo "marker=$exclude" >> $GITHUB_OUTPUT
5175
shell: bash
5276

5377
- name: Determine if reruns are enabled

.github/workflows/functional_selected_device.yaml

Lines changed: 101 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,84 @@
11
name: Functional tests
22

33
on:
4+
workflow_call:
5+
inputs:
6+
tests:
7+
description: 'Tests to run (leave blank to run all tests!)'
8+
required: false
9+
default: ''
10+
type: string
11+
cross_service_tests:
12+
description: 'Include imms api and reporting tests'
13+
required: false
14+
default: false
15+
type: boolean
16+
github_ref:
17+
description: 'Github reference to get tests from'
18+
required: false
19+
default: 'main'
20+
type: string
21+
device:
22+
description: 'Device to test'
23+
required: false
24+
default: 'Desktop Chrome'
25+
type: string
26+
programmes:
27+
description: Programmes to use (FLU, HPV, MENACWY, MMR or TD_IPV)
28+
required: false
29+
default: FLU,HPV,MENACWY,MMR,TD_IPV
30+
type: string
31+
endpoint:
32+
description: 'Environment to run tests against'
33+
required: false
34+
default: 'https://qa.mavistesting.com'
35+
type: string
36+
screenshot_all_steps:
37+
description: 'Take screenshots for all steps (in addition to failures)'
38+
required: false
39+
default: false
40+
type: boolean
41+
enable_reruns:
42+
description: 'Enable test reruns on failure (up to 3 attempts)'
43+
required: false
44+
default: true
45+
type: boolean
46+
test_workers:
47+
description: 'Number of parallel test workers to use'
48+
required: false
49+
default: '4'
50+
type: string
51+
set_feature_flags:
52+
description: 'Set feature flags in the flipper page before running tests (affects all users of the environment being tested!)'
53+
required: false
54+
default: false
55+
type: boolean
56+
additional_feature_flags:
57+
description: '(If enabled above) Additional feature flags to set. api, basic_auth, dev_tools will be set by default'
58+
required: false
59+
default: ''
60+
type: string
61+
secrets:
62+
HTTP_AUTH_TOKEN_FOR_TESTS:
63+
description: 'HTTP Basic Auth token for the environment under test'
64+
required: true
65+
MAVIS_TESTING_REPO_ACCESS_TOKEN:
66+
description: 'Git token with access to the mavis testing repo'
67+
required: false
468
workflow_dispatch:
569
inputs:
670
tests:
771
description: 'Tests to run (leave blank to run all tests!)'
872
required: false
973
default: ''
74+
cross_service_tests:
75+
description: 'Include imms api and reporting tests'
76+
required: false
77+
default: 'true'
78+
type: choice
79+
options:
80+
- true
81+
- false
1082
device:
1183
description: 'Device to test'
1284
required: true
@@ -73,7 +145,6 @@ on:
73145
description: '(If enabled above) Additional feature flags to set. api, basic_auth, dev_tools will be set by default'
74146
required: false
75147
default: ''
76-
pull_request:
77148

78149
jobs:
79150
test:
@@ -96,8 +167,9 @@ jobs:
96167
[sandbox-alpha]="https://sandbox-alpha.mavistesting.com"
97168
[sandbox-beta]="https://sandbox-beta.mavistesting.com"
98169
)
99-
if [ "${{ github.event_name }}" = "pull_request" ]; then
170+
if [ "${{ github.event_name }}" = "push" ]; then
100171
echo "tests=" >> $GITHUB_OUTPUT
172+
echo "cross_service_tests=true" >> $GITHUB_OUTPUT
101173
echo "device=Desktop Chrome" >> $GITHUB_OUTPUT
102174
echo "environment=${env_map[qa]}" >> $GITHUB_OUTPUT
103175
echo "programmes=FLU,HPV,MENACWY,MMR,TD_IPV" >> $GITHUB_OUTPUT
@@ -108,23 +180,32 @@ jobs:
108180
echo "enable_reruns=true" >> $GITHUB_OUTPUT
109181
echo "test_workers=4" >> $GITHUB_OUTPUT
110182
else
111-
echo "tests=${{ github.event.inputs.tests }}" >> $GITHUB_OUTPUT
112-
echo "device=${{ github.event.inputs.device }}" >> $GITHUB_OUTPUT
113-
114-
input_env="${{ github.event.inputs.environment }}"
115-
url="${env_map[$input_env]:-${env_map[qa]}}"
116-
echo "environment=$url" >> $GITHUB_OUTPUT
183+
echo "tests=${{ inputs.tests }}" >> $GITHUB_OUTPUT
184+
echo "cross_service_tests=${{ inputs.cross_service_tests }}" >> $GITHUB_OUTPUT
185+
echo "device=${{ inputs.device }}" >> $GITHUB_OUTPUT
186+
187+
input_env="${{ inputs.environment }}"
188+
if [ -n "$input_env" ]; then
189+
url="${env_map[$input_env]:-${env_map[qa]}}"
190+
echo "environment=$url" >> $GITHUB_OUTPUT
191+
else
192+
echo "environment=${{ inputs.endpoint }}" >> $GITHUB_OUTPUT
193+
fi
117194
118-
echo "programmes=${{ github.event.inputs.programmes }}" >> $GITHUB_OUTPUT
119-
echo "set_feature_flags=${{ github.event.inputs.set_feature_flags }}" >> $GITHUB_OUTPUT
120-
echo "additional_feature_flags=${{ github.event.inputs.additional_feature_flags }}" >> $GITHUB_OUTPUT
195+
echo "programmes=${{ inputs.programmes }}" >> $GITHUB_OUTPUT
196+
echo "set_feature_flags=${{ inputs.set_feature_flags }}" >> $GITHUB_OUTPUT
197+
echo "additional_feature_flags=${{ inputs.additional_feature_flags }}" >> $GITHUB_OUTPUT
121198
echo "deploy_report=true" >> $GITHUB_OUTPUT
122-
echo "screenshot_all_steps=${{ github.event.inputs.screenshot_all_steps }}" >> $GITHUB_OUTPUT
123-
echo "enable_reruns=${{ github.event.inputs.enable_reruns }}" >> $GITHUB_OUTPUT
124-
echo "test_workers=${{ github.event.inputs.test_workers }}" >> $GITHUB_OUTPUT
199+
echo "screenshot_all_steps=${{ inputs.screenshot_all_steps }}" >> $GITHUB_OUTPUT
200+
echo "enable_reruns=${{ inputs.enable_reruns }}" >> $GITHUB_OUTPUT
201+
echo "test_workers=${{ inputs.test_workers }}" >> $GITHUB_OUTPUT
125202
fi
126203
127-
- uses: actions/checkout@v6
204+
- name: Checkout repository
205+
uses: actions/checkout@v6
206+
with:
207+
repository: NHSDigital/manage-vaccinations-in-schools-testing
208+
ref: ${{ inputs.github_ref || github.head_ref }}
128209

129210
- name: Cache Playwright browsers
130211
uses: actions/cache@v4
@@ -137,6 +218,9 @@ jobs:
137218
uses: ./.github/actions/run-functional-tests
138219
with:
139220
tests: ${{ steps.set-variables.outputs.tests }}
221+
imms_api_tests: ${{ steps.set-variables.outputs.cross_service_tests }}
222+
reporting_tests: ${{ steps.set-variables.outputs.cross_service_tests }}
223+
github_ref: ${{ inputs.github_ref || github.head_ref }}
140224
device: ${{ steps.set-variables.outputs.device }}
141225
base_url: ${{ steps.set-variables.outputs.environment }}
142226
programmes_enabled: ${{ steps.set-variables.outputs.programmes }}
@@ -160,4 +244,5 @@ jobs:
160244
device: ${{ steps.set-variables.outputs.device }}
161245
environment: ${{ github.event.inputs.environment }}
162246
env:
163-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
247+
GITHUB_TOKEN: ${{ secrets.MAVIS_TESTING_REPO_ACCESS_TOKEN || secrets.GITHUB_TOKEN }}
248+
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Pull Request Validation
2+
3+
on: pull_request
4+
5+
permissions: { }
6+
7+
jobs:
8+
identify-target-environment:
9+
runs-on: ubuntu-latest
10+
permissions:
11+
contents: read
12+
outputs:
13+
environment: ${{ steps.identify-target-environment.outputs.environment }}
14+
mavis_branch: ${{ steps.check-branch.outputs.mavis_branch }}
15+
steps:
16+
- name: Check if branch exists
17+
id: check-branch
18+
run: |
19+
if git ls-remote --exit-code --heads https://github.com/nhsuk/manage-vaccinations-in-schools.git ${{ github.head_ref }} > /dev/null 2>&1; then
20+
echo "mavis_branch=${{ github.head_ref }}" >> $GITHUB_OUTPUT
21+
else
22+
echo "mavis_branch=main" >> $GITHUB_OUTPUT
23+
fi
24+
- name: Identify target environment
25+
id: identify-target-environment
26+
run: |
27+
environment='qa'
28+
if [[ -n "${{ steps.check-branch.outputs.mavis_branch }}" ]]; then
29+
environment='container'
30+
fi
31+
echo "environment=$environment" >> $GITHUB_OUTPUT
32+
run-tests-against-staging:
33+
needs: identify-target-environment
34+
if: needs.identify-target-environment.outputs.environment != 'container'
35+
uses: ./.github/workflows/functional_selected_device.yaml
36+
permissions:
37+
contents: write
38+
with:
39+
tests: ''
40+
cross_service_tests: false
41+
github_ref: ${{ github.ref }}
42+
endpoint: 'https://qa.mavistesting.com'
43+
device: 'Desktop Chrome'
44+
programmes: 'FLU,HPV,MENACWY,MMR,TD_IPV'
45+
screenshot_all_steps: false
46+
enable_reruns: false
47+
test_workers: '4'
48+
set_feature_flags: false
49+
additional_feature_flags: ''
50+
secrets:
51+
HTTP_AUTH_TOKEN_FOR_TESTS: ${{ secrets.HTTP_AUTH_TOKEN_FOR_TESTS }}
52+
run-tests-against-container:
53+
needs: identify-target-environment
54+
if: needs.identify-target-environment.outputs.environment == 'container'
55+
uses: nhsuk/manage-vaccinations-in-schools/.github/workflows/end-to-end-tests.yml@containerized_regression_tests_for_PRs #TODO: Change once this is in main
56+
permissions:
57+
id-token: write
58+
contents: write
59+
with:
60+
github_ref: ${{ needs.identify-target-environment.outputs.mavis_branch }}
61+
secrets:
62+
HTTP_AUTH_TOKEN_FOR_TESTS: ${{ secrets.HTTP_AUTH_TOKEN_FOR_TESTS }}
63+
MAVIS_TESTING_REPO_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ cython_debug/
165165
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
166166
# and can be added to the global gitignore or merged into this file. For a more nuclear
167167
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
168-
#.idea/
168+
.idea/
169169

170170
# Visual Studio Code
171171
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore

0 commit comments

Comments
 (0)