generated from NHSDigital/nhs-notify-repository-template
-
Notifications
You must be signed in to change notification settings - Fork 1
181 lines (177 loc) · 5.84 KB
/
stage-4-acceptance.yaml
File metadata and controls
181 lines (177 loc) · 5.84 KB
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
name: "Acceptance stage"
on:
workflow_call:
inputs:
build_datetime:
description: "Build datetime, set by the CI/CD pipeline workflow"
required: true
type: string
build_timestamp:
description: "Build timestamp, set by the CI/CD pipeline workflow"
required: true
type: string
build_epoch:
description: "Build epoch, set by the CI/CD pipeline workflow"
required: true
type: string
nodejs_version:
description: "Node.js version, set by the CI/CD pipeline workflow"
required: true
type: string
python_version:
description: "Python version, set by the CI/CD pipeline workflow"
required: true
type: string
terraform_version:
description: "Terraform version, set by the CI/CD pipeline workflow"
required: true
type: string
version:
description: "Version of the software, set by the CI/CD pipeline workflow"
required: true
type: string
env:
AWS_REGION: eu-west-2
permissions:
id-token: write # This is required for requesting the JWT
contents: read # This is required for actions/checkout
jobs:
sandbox-set-up:
name: "Sandbox set up"
runs-on: ubuntu-latest
environment: dev
timeout-minutes: 15
steps:
- uses: hashicorp/setup-terraform@v3
- uses: asdf-vm/actions/setup@v3
- name: "Checkout code"
uses: actions/checkout@v4
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/${{ secrets.AWS_ASSUME_ROLE_NAME }}
role-session-name: deployInfra
aws-region: ${{ env.AWS_REGION }}
- name: "Get normalized branch name"
id: normalize_branch_name
uses: ./.github/actions/normalize-branch-name
- name: "Create Backend sandbox"
run: |
npm run create-backend-sandbox ${{ steps.normalize_branch_name.outputs.normalized_branch_name }}
- uses: actions/upload-artifact@v4
with:
name: sandbox_tf_outputs.json
path: sandbox_tf_outputs.json
test-security:
name: "Security test"
runs-on: ubuntu-latest
needs: [sandbox-set-up]
timeout-minutes: 10
steps:
- name: "Checkout code"
uses: actions/checkout@v4
- name: "Run security test"
run: |
make test-security
- name: "Save result"
run: |
echo "Nothing to save"
test-accessibility:
name: "Accessibility test"
runs-on: ubuntu-latest
needs: [sandbox-set-up]
environment: dev
env:
INCLUDE_AUTH_PAGES: 'true'
timeout-minutes: 10
steps:
- name: "Checkout code"
uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: sandbox_tf_outputs.json
path: ./
- name: "Repo setup"
run: |
npm ci
- name: "Generate dependencies"
run: |
npm run generate-dependencies --workspaces --if-present
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/${{ secrets.AWS_ASSUME_ROLE_NAME }}
role-session-name: deployInfra
aws-region: eu-west-2
- name: "Run accessibility test"
run: |
npm run create-amplify-outputs file
make test-accessibility
- name: Archive accessibility results
uses: actions/upload-artifact@v4
with:
name: accessibility
path: ".reports/accessibility"
test-ui-component:
name: "UI Component test"
runs-on: ubuntu-latest
needs: [sandbox-set-up]
environment: dev
env:
INCLUDE_AUTH_PAGES: 'true'
timeout-minutes: 10
steps:
- name: "Checkout code"
uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: sandbox_tf_outputs.json
path: ./
- name: "Repo setup"
run: |
npm ci
- name: "Generate dependencies"
run: |
npm run generate-dependencies --workspaces --if-present
- name: Install Playwright Browsers
run: npx playwright install --with-deps
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/${{ secrets.AWS_ASSUME_ROLE_NAME }}
role-session-name: deployInfra
aws-region: eu-west-2
- name: "Run ui component test"
run: |
npm run create-amplify-outputs file
cd tests/test-team
npm run test:local-ui
- name: Archive component test results
if: success() || failure()
uses: actions/upload-artifact@v4
with:
name: component test report
path: "tests/test-team/playwright-report"
sandbox-tear-down:
name: "Sandbox tear down"
if: success() || failure()
runs-on: ubuntu-latest
needs: [test-accessibility, test-ui-component]
environment: dev
steps:
- uses: hashicorp/setup-terraform@v3
- uses: asdf-vm/actions/setup@v3
- name: "Checkout code"
uses: actions/checkout@v4
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/${{ secrets.AWS_ASSUME_ROLE_NAME }}
role-session-name: deployInfra
aws-region: eu-west-2
- name: "Get normalized branch name"
id: normalize_branch_name
uses: ./.github/actions/normalize-branch-name
- name: "Destroy Backend sandbox"
run: |
npm run destroy-backend-sandbox ${{ steps.normalize_branch_name.outputs.normalized_branch_name }}