Skip to content

Commit ceebd4c

Browse files
VIA-245 AS Run snapshot tests after acceptance stage for preprod deployments only
1 parent 45e945b commit ceebd4c

File tree

4 files changed

+85
-8
lines changed

4 files changed

+85
-8
lines changed

.github/workflows/cicd-3-deploy.yaml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ jobs:
6060
needs: [metadata]
6161
uses: ./.github/workflows/stage-4-deploy.yaml
6262
with:
63-
environment: ${{ github.event.inputs.environment}}
63+
environment: ${{ github.event.inputs.environment }}
6464
terraform_version: "${{ needs.metadata.outputs.terraform_version }}"
6565
tag: "${{ needs.metadata.outputs.tag }}"
6666
secrets: inherit
@@ -71,3 +71,10 @@ jobs:
7171
with:
7272
environment: ${{ github.event.inputs.environment}}
7373
secrets: inherit
74+
snapshot-test-stage:
75+
name: "Snapshot Test stage"
76+
if: ${{ github.event.inputs.environment == 'preprod' }}
77+
needs: [metadata, acceptance-stage]
78+
uses: ./.github/workflows/stage-7-snapshot-test.yaml
79+
with:
80+
tag: "${{ needs.metadata.outputs.tag }}"

.github/workflows/cicd-5-snapshot-test.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@ on:
44
workflow_dispatch:
55
inputs:
66
tag:
7-
description: "Tag"
7+
description: "Tag of deployment"
88
type: string
99
required: true
1010

1111
env:
1212
AWS_REGION: eu-west-2
13-
AWS_S3_ARTEFACTS_BUCKET: vita-${{ secrets.AWS_ACCOUNT_ID }}-artefacts-dev
13+
AWS_S3_ARTEFACTS_BUCKET: vita-${{ secrets.AWS_ACCOUNT_ID }}-artefacts-preprod
1414

1515
jobs:
1616
snapshot-test:
1717
name: "Snapshot Test"
1818
runs-on: ubuntu-latest
19-
environment: dev
19+
environment: preprod
2020
timeout-minutes: 30
2121
permissions:
2222
id-token: write

.github/workflows/cicd-6-snapshot-update.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
name: "CI/CD snapshot update"
1+
name: "CI/CD snapshot update (PreProd)"
22

33
on:
44
workflow_dispatch:
55
inputs:
66
tag:
7-
description: "Tag"
7+
description: "Tag of snapshots to set as reference"
88
required: true
99
type: string
1010

1111
env:
1212
AWS_REGION: eu-west-2
13-
AWS_S3_ARTEFACTS_BUCKET: vita-${{ secrets.AWS_ACCOUNT_ID }}-artefacts-dev
13+
AWS_S3_ARTEFACTS_BUCKET: vita-${{ secrets.AWS_ACCOUNT_ID }}-artefacts-preprod
1414

1515
jobs:
1616
upload-snapshots:
1717
name: "Update Snapshots in S3"
1818
runs-on: ubuntu-latest
19-
environment: dev
19+
environment: preprod
2020
timeout-minutes: 10
2121
permissions:
2222
id-token: write
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: "Snapshot Test stage"
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
tag:
7+
description: "Tag of deployment"
8+
required: true
9+
type: string
10+
11+
env:
12+
AWS_REGION: eu-west-2
13+
AWS_S3_ARTEFACTS_BUCKET: vita-${{ secrets.AWS_ACCOUNT_ID }}-artefacts-preprod
14+
15+
jobs:
16+
snapshot-test:
17+
name: "Snapshot Test"
18+
runs-on: ubuntu-latest
19+
environment: preprod
20+
timeout-minutes: 30
21+
permissions:
22+
id-token: write
23+
contents: read
24+
env:
25+
TEST_NHS_APP_USERNAME: ${{ secrets.TEST_NHS_APP_USERNAME }}
26+
TEST_NHS_APP_PASSWORD: ${{ secrets.TEST_NHS_APP_PASSWORD }}
27+
TEST_NHS_APP_URL: ${{ secrets.TEST_NHS_APP_URL }}
28+
TEST_NHS_LOGIN_PASSWORD: ${{ secrets.TEST_NHS_LOGIN_PASSWORD }}
29+
TEST_NHS_LOGIN_OTP: ${{ secrets.TEST_NHS_LOGIN_OTP }}
30+
TEST_APP_URL: ${{ secrets.TEST_APP_URL }}
31+
32+
steps:
33+
- name: "Checkout code"
34+
uses: actions/checkout@v4
35+
36+
- name: "Install dependencies"
37+
run: |
38+
npm ci --ignore-scripts
39+
40+
- name: "Install Playwright browsers"
41+
run: |
42+
npx playwright install --with-deps
43+
44+
- name: "Configure AWS credentials for environment"
45+
uses: aws-actions/configure-aws-credentials@v4
46+
with:
47+
role-session-name: GitHubActionsSession
48+
role-to-assume: ${{ secrets.IAM_ROLE }}
49+
aws-region: ${{ env.AWS_REGION }}
50+
51+
- name: "Download snapshots from S3 bucket"
52+
run: |
53+
aws s3 sync s3://${{ env.AWS_S3_ARTEFACTS_BUCKET }}/playwright/reference/ ./e2e/snapshot/
54+
55+
- name: "Run Playwright snapshot tests (no update)"
56+
run: |
57+
npm run e2e:snapshot
58+
59+
- name: "Upload snapshots to S3 bucket with tag ${{ inputs.tag }}"
60+
if: failure()
61+
run: |
62+
aws s3 sync ./e2e/snapshot/snapshot_review/ s3://${{ env.AWS_S3_ARTEFACTS_BUCKET }}/playwright/${{ inputs.tag }}/
63+
64+
- name: "Upload report"
65+
uses: actions/upload-artifact@v4
66+
if: always()
67+
with:
68+
name: playwright-report
69+
path: playwright-report/
70+
retention-days: 30

0 commit comments

Comments
 (0)