Skip to content

Commit 1762b8b

Browse files
VIA-598 AJ/DB WIP add snapshot tests to scheduled assurances
1 parent 1cf87d2 commit 1762b8b

File tree

3 files changed

+103
-51
lines changed

3 files changed

+103
-51
lines changed

.github/actions/run-e2e-tests/action.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
name: "Run E2E tests"
22
description: "Run E2E tests"
3+
34
inputs:
45
checkout_ref:
56
description: "Ref to checkout"
Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,66 @@
11
name: "Run Snapshot Tests"
2-
description: "Run snapshot tests against Preprod environment"
2+
description: "Run snapshot tests"
33

44
inputs:
55
checkout_ref:
66
description: "Ref to checkout"
77
required: true
88
release_name:
9-
description: "S3 folder to use for references and storing results (e.g. 'release1', 'latest-main')"
9+
description: "S3 folder to use for references and storing results ('release1' / 'latest-main-tag')"
1010
required: true
1111

1212
runs:
1313
using: "composite"
14+
1415
steps:
15-
- name: "Checkout code"
16+
- name: "Checkout target code"
1617
uses: actions/checkout@v5
1718
with:
1819
ref: ${{ inputs.checkout_ref }}
1920
path: "code-for-snapshot-tests"
2021

21-
- name: "Configure AWS credentials for environment"
22+
- name: "Configure AWS credentials"
2223
uses: aws-actions/configure-aws-credentials@v5
2324
with:
2425
role-session-name: GitHubActionsSession
25-
role-to-assume: ${{ secrets.IAM_ROLE }}
26-
aws-region: ${{ env.AWS_REGION }}
26+
role-to-assume: ${{ env.SECRET_IAM_ROLE }}
27+
aws-region: eu-west-2
2728

28-
- name: Cache node modules
29+
- name: "Cache node modules"
2930
id: cache-npm
3031
uses: actions/cache@v4
3132
env:
3233
cache-name: cache-node-modules
3334
with:
3435
path: ~/.npm
35-
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('./code-for-snapshot-tests**/package-lock.json') }}
36+
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('./code-for-snapshot-tests/**/package-lock.json') }}
3637

3738
- name: "Install dependencies"
3839
shell: bash
3940
working-directory: "./code-for-snapshot-tests"
4041
run: |
42+
echo "::group::Install dependencies"
4143
npm ci --ignore-scripts
44+
echo "::endgroup::"
4245
4346
- name: "Get current week number and playwright version"
44-
id: cache_key_values
4547
shell: bash
4648
working-directory: "./code-for-snapshot-tests"
49+
id: cache_key_values
4750
run: |
51+
echo "::group::Get current week number and playwright version"
4852
echo "week_num=$(date -u +'%Y-%V')" | tee -a $GITHUB_OUTPUT
4953
echo "playwright_version=$(npm view @playwright/test version)" | tee -a $GITHUB_OUTPUT
54+
echo "::endgroup::"
5055
5156
- name: "Get current date"
52-
id: folder_name_value
5357
shell: bash
5458
working-directory: "./code-for-snapshot-tests"
59+
id: folder_name_value
5560
run: |
61+
echo "::group::Get current date"
5662
echo "current_datetime=$(date -u +'%Y-%m-%dT%H%M%SZ')" | tee -a $GITHUB_OUTPUT
63+
echo "::endgroup::"
5764
5865
- name: "Cache Playwright browsers"
5966
uses: actions/cache@v4
@@ -67,15 +74,23 @@ runs:
6774
shell: bash
6875
working-directory: "./code-for-snapshot-tests"
6976
run: |
77+
echo "::group::Install Playwright browsers (Chromium, Firefox)"
7078
npx playwright install chromium firefox --with-deps
79+
EXIT_STATUS=$?
80+
echo "::endgroup::"
81+
exit $EXIT_STATUS
7182
7283
- name: "Install Playwright browsers (Webkit)"
7384
shell: bash
7485
working-directory: "./code-for-snapshot-tests"
7586
run: |
87+
echo "::group::Install Playwright browsers (Webkit)"
7688
npx playwright install webkit --with-deps
89+
EXIT_STATUS=$?
90+
echo "::endgroup::"
91+
exit $EXIT_STATUS
7792
78-
- name: "Download snapshots from ${{ inputs.release_name }} S3 bucket"
93+
- name: "Download reference snapshots from S3"
7994
shell: bash
8095
working-directory: "./code-for-snapshot-tests"
8196
run: |
@@ -90,17 +105,17 @@ runs:
90105
CURRENT_DATETIME: ${{ steps.folder_name_value.outputs.current_datetime }}
91106
CHECKOUT_REF: ${{ inputs.checkout_ref }}
92107

93-
- name: "Upload snapshots to ${{ inputs.release_name }} S3 bucket with tag ${{ steps.folder_name_value.outputs.current_datetime }}-${{ inputs.checkout_ref }}"
94-
if: failure()
108+
- name: "Upload snapshots to S3 bucket with tag ${{ steps.folder_name_value.outputs.current_datetime }}-${{ inputs.checkout_ref }}"
109+
if: ${{ failure() }}
95110
shell: bash
96111
working-directory: "./code-for-snapshot-tests"
97112
run: |
98113
aws s3 sync --delete ./e2e/snapshot/snapshot_review/ s3://${{ env.AWS_S3_ARTEFACTS_BUCKET }}/playwright/snapshots-for-review/${{ inputs.release_name }}/${{ steps.folder_name_value.outputs.current_datetime }}-${{ inputs.checkout_ref }}/
99114
100115
- name: "Upload report"
101116
uses: actions/upload-artifact@v5
102-
if: always()
117+
if: ${{ failure() }}
103118
with:
104119
name: playwright-report-snapshot-${{ inputs.release_name }}-${{ steps.folder_name_value.outputs.current_datetime }}-${{ inputs.checkout_ref }}
105-
path: playwright-report/
120+
path: ./code-for-snapshot-tests/playwright-report/
106121
retention-days: 30

.github/workflows/cicd-9-scheduled-wip.yaml

Lines changed: 72 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ on:
1414
- All
1515

1616
jobs:
17+
##########################################################
18+
# R1.0 deployment and assurance (e2e+snapshots+contract)
19+
##########################################################
20+
1721
deploy-and-test-r1:
1822
name: "R1.0 Assurance"
1923
runs-on: "ubuntu-latest"
@@ -43,7 +47,7 @@ jobs:
4347
- name: "Checkout code"
4448
uses: actions/checkout@v5
4549

46-
- name: "Deploy to AWS (preprod)"
50+
- name: "Deploy ${{ steps.get-latest-tag-name.outputs.value }} to AWS (preprod)"
4751
timeout-minutes: 10
4852
uses: ./.github/actions/deploy
4953
with:
@@ -53,23 +57,6 @@ jobs:
5357
secret_aws_iam_role: ${{ secrets.IAM_ROLE }}
5458
secret_aws_slack_channel_id: ${{ secrets.ALARMS_SLACK_CHANNEL_ID }}
5559

56-
- name: "Run E2E tests on ${{ steps.get-latest-tag-name.outputs.value }} (preprod)"
57-
timeout-minutes: 10
58-
uses: ./.github/actions/run-e2e-tests
59-
with:
60-
checkout_ref: ${{ steps.get-latest-tag-name.outputs.value }}
61-
cross_browser: true
62-
env:
63-
TEST_NHS_APP_URL: ${{ secrets.TEST_NHS_APP_URL }}
64-
TEST_NHS_LOGIN_PASSWORD: ${{ secrets.TEST_NHS_LOGIN_PASSWORD }}
65-
TEST_NHS_LOGIN_OTP: ${{ secrets.TEST_NHS_LOGIN_OTP }}
66-
TEST_NBS_APP_USERNAME: ${{ secrets.TEST_NBS_APP_USERNAME }}
67-
TEST_NBS_APP_PASSWORD: ${{ secrets.TEST_NBS_APP_PASSWORD }}
68-
TEST_APP_URL: ${{ secrets.TEST_APP_URL }}
69-
NHS_APP_REDIRECT_LOGIN_URL: ${{ secrets.NHS_APP_REDIRECT_LOGIN_URL }}
70-
VITA_TEST_USER_PATTERN: ${{ secrets.VITA_TEST_USER_PATTERN }}
71-
DEPLOY_ENVIRONMENT: "preprod"
72-
7360
- name: "Run contract tests (sandpit+mocked)"
7461
timeout-minutes: 3
7562
uses: ./.github/actions/run-contract-tests
@@ -94,6 +81,41 @@ jobs:
9481
MAX_SESSION_AGE_MINUTES: 0
9582
AUTH_SECRET: "dummy"
9683

84+
- name: "Run E2E tests on ${{ steps.get-latest-tag-name.outputs.value }} (preprod)"
85+
timeout-minutes: 10
86+
uses: ./.github/actions/run-e2e-tests
87+
with:
88+
checkout_ref: ${{ steps.get-latest-tag-name.outputs.value }}
89+
cross_browser: true
90+
env:
91+
TEST_NHS_APP_URL: ${{ secrets.TEST_NHS_APP_URL }}
92+
TEST_NHS_LOGIN_PASSWORD: ${{ secrets.TEST_NHS_LOGIN_PASSWORD }}
93+
TEST_NHS_LOGIN_OTP: ${{ secrets.TEST_NHS_LOGIN_OTP }}
94+
TEST_NBS_APP_USERNAME: ${{ secrets.TEST_NBS_APP_USERNAME }}
95+
TEST_NBS_APP_PASSWORD: ${{ secrets.TEST_NBS_APP_PASSWORD }}
96+
TEST_APP_URL: ${{ secrets.TEST_APP_URL }}
97+
NHS_APP_REDIRECT_LOGIN_URL: ${{ secrets.NHS_APP_REDIRECT_LOGIN_URL }}
98+
VITA_TEST_USER_PATTERN: ${{ secrets.VITA_TEST_USER_PATTERN }}
99+
DEPLOY_ENVIRONMENT: "preprod"
100+
101+
- name: "Run snapshot tests on ${{ steps.get-latest-tag-name.outputs.value }} (preprod)"
102+
uses: ./.github/actions/run-snapshot-tests
103+
with:
104+
checkout_ref: ${{ inputs.checkout_ref }}
105+
release_name: "release1"
106+
env:
107+
SECRET_IAM_ROLE: ${{ secrets.IAM_ROLE }}
108+
TEST_NHS_APP_URL: ${{ secrets.TEST_NHS_APP_URL }}
109+
TEST_NHS_LOGIN_PASSWORD: ${{ secrets.TEST_NHS_LOGIN_PASSWORD }}
110+
TEST_NHS_LOGIN_OTP: ${{ secrets.TEST_NHS_LOGIN_OTP }}
111+
TEST_APP_URL: ${{ secrets.TEST_APP_URL }}
112+
VITA_TEST_USER_PATTERN: ${{ secrets.VITA_TEST_USER_PATTERN }}
113+
AWS_S3_ARTEFACTS_BUCKET: vita-${{ secrets.AWS_ACCOUNT_ID }}-artefacts-preprod
114+
115+
#################################################################
116+
# Main branch deployment and assurance (e2e+snapshots+contract)
117+
#################################################################
118+
97119
deploy-and-test-main:
98120
name: "Main Branch Assurance"
99121
runs-on: "ubuntu-latest"
@@ -125,7 +147,7 @@ jobs:
125147
- name: "Checkout code"
126148
uses: actions/checkout@v5
127149

128-
- name: "Deploy to AWS (preprod)"
150+
- name: "Deploy ${{ steps.get-latest-tag-name.outputs.value }} to AWS (preprod)"
129151
timeout-minutes: 10
130152
uses: ./.github/actions/deploy
131153
with:
@@ -135,23 +157,6 @@ jobs:
135157
secret_aws_iam_role: ${{ secrets.IAM_ROLE }}
136158
secret_aws_slack_channel_id: ${{ secrets.ALARMS_SLACK_CHANNEL_ID }}
137159

138-
- name: "Run E2E tests on ${{ steps.get-latest-tag-name.outputs.value }} (preprod)"
139-
timeout-minutes: 10
140-
uses: ./.github/actions/run-e2e-tests
141-
with:
142-
checkout_ref: ${{ steps.get-latest-tag-name.outputs.value }}
143-
cross_browser: true
144-
env:
145-
TEST_NHS_APP_URL: ${{ secrets.TEST_NHS_APP_URL }}
146-
TEST_NHS_LOGIN_PASSWORD: ${{ secrets.TEST_NHS_LOGIN_PASSWORD }}
147-
TEST_NHS_LOGIN_OTP: ${{ secrets.TEST_NHS_LOGIN_OTP }}
148-
TEST_NBS_APP_USERNAME: ${{ secrets.TEST_NBS_APP_USERNAME }}
149-
TEST_NBS_APP_PASSWORD: ${{ secrets.TEST_NBS_APP_PASSWORD }}
150-
TEST_APP_URL: ${{ secrets.TEST_APP_URL }}
151-
NHS_APP_REDIRECT_LOGIN_URL: ${{ secrets.NHS_APP_REDIRECT_LOGIN_URL }}
152-
VITA_TEST_USER_PATTERN: ${{ secrets.VITA_TEST_USER_PATTERN }}
153-
DEPLOY_ENVIRONMENT: "preprod"
154-
155160
- name: "Run contract tests (sandpit+mocked)"
156161
timeout-minutes: 3
157162
uses: ./.github/actions/run-contract-tests
@@ -175,3 +180,34 @@ jobs:
175180
NBS_BOOKING_PATH: "dummy"
176181
MAX_SESSION_AGE_MINUTES: 0
177182
AUTH_SECRET: "dummy"
183+
184+
- name: "Run E2E tests on ${{ steps.get-latest-tag-name.outputs.value }} (preprod)"
185+
timeout-minutes: 10
186+
uses: ./.github/actions/run-e2e-tests
187+
with:
188+
checkout_ref: ${{ steps.get-latest-tag-name.outputs.value }}
189+
cross_browser: true
190+
env:
191+
TEST_NHS_APP_URL: ${{ secrets.TEST_NHS_APP_URL }}
192+
TEST_NHS_LOGIN_PASSWORD: ${{ secrets.TEST_NHS_LOGIN_PASSWORD }}
193+
TEST_NHS_LOGIN_OTP: ${{ secrets.TEST_NHS_LOGIN_OTP }}
194+
TEST_NBS_APP_USERNAME: ${{ secrets.TEST_NBS_APP_USERNAME }}
195+
TEST_NBS_APP_PASSWORD: ${{ secrets.TEST_NBS_APP_PASSWORD }}
196+
TEST_APP_URL: ${{ secrets.TEST_APP_URL }}
197+
NHS_APP_REDIRECT_LOGIN_URL: ${{ secrets.NHS_APP_REDIRECT_LOGIN_URL }}
198+
VITA_TEST_USER_PATTERN: ${{ secrets.VITA_TEST_USER_PATTERN }}
199+
DEPLOY_ENVIRONMENT: "preprod"
200+
201+
- name: "Run snapshot tests on ${{ steps.get-latest-tag-name.outputs.value }} (preprod)"
202+
uses: ./.github/actions/run-snapshot-tests
203+
with:
204+
checkout_ref: ${{ inputs.checkout_ref }}
205+
release_name: "latest-main-tag"
206+
env:
207+
SECRET_IAM_ROLE: ${{ secrets.IAM_ROLE }}
208+
TEST_NHS_APP_URL: ${{ secrets.TEST_NHS_APP_URL }}
209+
TEST_NHS_LOGIN_PASSWORD: ${{ secrets.TEST_NHS_LOGIN_PASSWORD }}
210+
TEST_NHS_LOGIN_OTP: ${{ secrets.TEST_NHS_LOGIN_OTP }}
211+
TEST_APP_URL: ${{ secrets.TEST_APP_URL }}
212+
VITA_TEST_USER_PATTERN: ${{ secrets.VITA_TEST_USER_PATTERN }}
213+
AWS_S3_ARTEFACTS_BUCKET: vita-${{ secrets.AWS_ACCOUNT_ID }}-artefacts-preprod

0 commit comments

Comments
 (0)