|
1 | | -name: "Acceptance stage" |
| 1 | +name: Acceptance stage |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | workflow_call: |
5 | | - inputs: |
6 | | - build_datetime: |
7 | | - description: "Build datetime, set by the CI/CD pipeline workflow" |
8 | | - required: true |
9 | | - type: string |
10 | | - build_timestamp: |
11 | | - description: "Build timestamp, set by the CI/CD pipeline workflow" |
12 | | - required: true |
13 | | - type: string |
14 | | - build_epoch: |
15 | | - description: "Build epoch, set by the CI/CD pipeline workflow" |
16 | | - required: true |
17 | | - type: string |
18 | | - nodejs_version: |
19 | | - description: "Node.js version, set by the CI/CD pipeline workflow" |
20 | | - required: true |
21 | | - type: string |
22 | | - python_version: |
23 | | - description: "Python version, set by the CI/CD pipeline workflow" |
24 | | - required: true |
25 | | - type: string |
26 | | - terraform_version: |
27 | | - description: "Terraform version, set by the CI/CD pipeline workflow" |
28 | | - required: true |
29 | | - type: string |
30 | | - version: |
31 | | - description: "Version of the software, set by the CI/CD pipeline workflow" |
32 | | - required: true |
33 | | - type: string |
34 | | - |
35 | | -env: |
36 | | - AWS_REGION: eu-west-2 |
37 | 5 |
|
38 | 6 | permissions: |
39 | | - id-token: write # This is required for requesting the JWT |
40 | | - contents: read # This is required for actions/checkout |
| 7 | + id-token: write |
| 8 | + contents: read |
41 | 9 |
|
42 | 10 | jobs: |
43 | 11 | sandbox-set-up: |
44 | | - name: "Sandbox set up" |
45 | | - runs-on: ubuntu-latest |
46 | | - environment: dev |
47 | | - timeout-minutes: 15 |
48 | | - steps: |
49 | | - - uses: hashicorp/setup-terraform@v3 |
50 | | - - uses: asdf-vm/actions/setup@v3 |
51 | | - - name: "Checkout code" |
52 | | - uses: actions/checkout@v4 |
53 | | - - name: Configure AWS credentials |
54 | | - uses: aws-actions/configure-aws-credentials@v4 |
55 | | - with: |
56 | | - role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/${{ secrets.AWS_ASSUME_ROLE_NAME }} |
57 | | - role-session-name: templates-ci-sandbox-setup |
58 | | - aws-region: ${{ env.AWS_REGION }} |
59 | | - - name: "Get normalized branch name" |
60 | | - id: normalize_branch_name |
61 | | - uses: ./.github/actions/normalize-branch-name |
62 | | - - name: "Create Backend sandbox" |
63 | | - run: | |
64 | | - npm run create-backend-sandbox ${{ steps.normalize_branch_name.outputs.normalized_branch_name }} |
65 | | - - uses: actions/upload-artifact@v4 |
66 | | - with: |
67 | | - name: sandbox_tf_outputs.json |
68 | | - path: sandbox_tf_outputs.json |
69 | | - - uses: actions/upload-artifact@v4 |
70 | | - with: |
71 | | - name: amplify_outputs.json |
72 | | - path: ./frontend/amplify_outputs.json |
73 | | - test-security: |
74 | | - name: "Security test" |
75 | | - runs-on: ubuntu-latest |
76 | | - needs: [sandbox-set-up] |
77 | | - timeout-minutes: 10 |
78 | | - steps: |
79 | | - - name: "Checkout code" |
80 | | - uses: actions/checkout@v4 |
81 | | - - name: "Run security test" |
82 | | - run: | |
83 | | - make test-security |
84 | | - - name: "Save result" |
85 | | - run: | |
86 | | - echo "Nothing to save" |
87 | | - test-accessibility: |
88 | | - name: "Accessibility test" |
89 | | - runs-on: ubuntu-latest |
90 | | - needs: [sandbox-set-up] |
91 | | - environment: dev |
92 | | - timeout-minutes: 10 |
93 | | - steps: |
94 | | - - name: "Checkout code" |
95 | | - uses: actions/checkout@v4 |
96 | | - - uses: actions/download-artifact@v4 |
97 | | - with: |
98 | | - name: sandbox_tf_outputs.json |
99 | | - path: ./ |
100 | | - - uses: actions/download-artifact@v4 |
101 | | - with: |
102 | | - name: amplify_outputs.json |
103 | | - path: ./frontend |
104 | | - - name: "Repo setup" |
105 | | - run: | |
106 | | - npm ci |
107 | | - - name: Configure AWS credentials |
108 | | - uses: aws-actions/configure-aws-credentials@v4 |
109 | | - with: |
110 | | - role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/${{ secrets.AWS_ASSUME_ROLE_NAME }} |
111 | | - role-session-name: templates-ci-accessibility-tests |
112 | | - aws-region: eu-west-2 |
113 | | - - name: "Run accessibility test" |
114 | | - run: make test-accessibility |
115 | | - - name: Archive accessibility results |
116 | | - uses: actions/upload-artifact@v4 |
117 | | - with: |
118 | | - name: accessibility |
119 | | - path: ".reports/accessibility" |
120 | | - test-ui-component: |
121 | | - name: "UI Component test" |
122 | | - runs-on: ubuntu-latest |
123 | | - needs: [sandbox-set-up] |
124 | | - environment: dev |
125 | | - timeout-minutes: 10 |
126 | | - steps: |
127 | | - - name: "Checkout code" |
128 | | - uses: actions/checkout@v4 |
129 | | - - uses: actions/download-artifact@v4 |
130 | | - with: |
131 | | - name: sandbox_tf_outputs.json |
132 | | - path: ./ |
133 | | - - uses: actions/download-artifact@v4 |
134 | | - with: |
135 | | - name: amplify_outputs.json |
136 | | - path: ./frontend |
137 | | - - name: "Repo setup" |
138 | | - run: | |
139 | | - npm ci |
140 | | - - name: Install Playwright Browsers |
141 | | - run: npx playwright install --with-deps |
142 | | - - name: Configure AWS credentials |
143 | | - uses: aws-actions/configure-aws-credentials@v4 |
144 | | - with: |
145 | | - role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/${{ secrets.AWS_ASSUME_ROLE_NAME }} |
146 | | - role-session-name: templates-ci-component-tests |
147 | | - aws-region: eu-west-2 |
148 | | - - name: "Run ui component test" |
149 | | - run: | |
150 | | - cd tests/test-team |
151 | | - npm run test:local-ui |
152 | | - - name: Archive component test results |
153 | | - if: success() || failure() |
154 | | - uses: actions/upload-artifact@v4 |
155 | | - with: |
156 | | - name: component test report |
157 | | - path: "tests/test-team/playwright-report" |
158 | | - test-api: |
159 | | - name: "API test" |
160 | | - runs-on: ubuntu-latest |
161 | | - needs: [sandbox-set-up] |
162 | | - environment: dev |
163 | | - timeout-minutes: 10 |
164 | | - steps: |
165 | | - - name: "Checkout code" |
166 | | - uses: actions/checkout@v4 |
167 | | - - uses: actions/download-artifact@v4 |
168 | | - with: |
169 | | - name: sandbox_tf_outputs.json |
170 | | - path: './' |
171 | | - - uses: actions/download-artifact@v4 |
172 | | - with: |
173 | | - name: amplify_outputs.json |
174 | | - path: ./frontend |
175 | | - - name: "Repo setup" |
176 | | - run: | |
177 | | - npm ci |
178 | | - - name: Configure AWS credentials |
179 | | - uses: aws-actions/configure-aws-credentials@v4 |
180 | | - with: |
181 | | - role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/${{ secrets.AWS_ASSUME_ROLE_NAME }} |
182 | | - role-session-name: templates-ci-api-tests |
183 | | - aws-region: eu-west-2 |
184 | | - - name: "Run API test" |
185 | | - run: | |
186 | | - cd tests/test-team |
187 | | - npm run test:api |
188 | | - - name: Archive API test results |
189 | | - uses: actions/upload-artifact@v4 |
190 | | - with: |
191 | | - name: API test report |
192 | | - path: "tests/test-team/playwright-report" |
193 | | - test-e2e: |
194 | | - name: "E2E test" |
195 | | - runs-on: ubuntu-latest |
196 | | - needs: [sandbox-set-up] |
197 | | - environment: dev |
198 | | - timeout-minutes: 10 |
199 | | - steps: |
200 | | - - name: "Checkout code" |
201 | | - uses: actions/checkout@v4 |
202 | | - - uses: actions/download-artifact@v4 |
203 | | - with: |
204 | | - name: sandbox_tf_outputs.json |
205 | | - path: ./ |
206 | | - - uses: actions/download-artifact@v4 |
207 | | - with: |
208 | | - name: amplify_outputs.json |
209 | | - path: ./frontend |
210 | | - - name: "Repo setup" |
211 | | - run: | |
212 | | - npm ci |
213 | | - - name: Install Playwright Browsers |
214 | | - run: npx playwright install --with-deps |
215 | | - - name: Configure AWS credentials |
216 | | - uses: aws-actions/configure-aws-credentials@v4 |
217 | | - with: |
218 | | - role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/${{ secrets.AWS_ASSUME_ROLE_NAME }} |
219 | | - role-session-name: templates-ci-e2e-tests |
220 | | - aws-region: eu-west-2 |
221 | | - - name: "Run E2E test" |
222 | | - run: |
223 | | - npm -w tests/test-team run test:e2e |
224 | | - - name: Archive e2e test results |
225 | | - if: success() || failure() |
226 | | - uses: actions/upload-artifact@v4 |
227 | | - with: |
228 | | - name: e2e test report |
229 | | - path: "tests/test-team/playwright-report" |
| 12 | + name: Step 1 |
| 13 | + uses: ./.github/workflows/dispatch_internal_repo_workflow.yaml |
| 14 | + secrets: inherit |
| 15 | + with: |
| 16 | + jobName: Sandbox set up |
| 17 | + infraRepoName: nhs-notify-template-management |
| 18 | + releaseVersion: ${{ github.head_ref || github.ref_name }} |
| 19 | + targetWorkflow: dispatch-deploy-dynamic-env.yaml |
| 20 | + targetEnvironment: pr${{ github.event.number }} |
| 21 | + targetAccountGroup: nhs-notify-template-management-dev |
| 22 | + targetComponent: sandbox |
| 23 | + terraformAction: apply |
| 24 | + |
| 25 | + acceptance-tests: |
| 26 | + name: Step 2 |
| 27 | + needs: sandbox-set-up |
| 28 | + |
| 29 | + # Calls out to the nhs-notify-internal repo. |
| 30 | + # The nhs-notify-internal repo will run the tests |
| 31 | + # setup in ./.github/actions/acceptance-tests/action.yaml |
| 32 | + uses: ./.github/workflows/dispatch_internal_repo_workflow.yaml |
| 33 | + secrets: inherit |
| 34 | + with: |
| 35 | + jobName: Acceptance tests |
| 36 | + infraRepoName: nhs-notify-template-management |
| 37 | + releaseVersion: ${{ github.head_ref || github.ref_name }} |
| 38 | + targetWorkflow: dispatch-acceptance-tests-dynamic-env.yaml |
| 39 | + targetEnvironment: pr${{ github.event.number }} |
| 40 | + targetAccountGroup: nhs-notify-template-management-dev |
| 41 | + targetComponent: sandbox |
| 42 | + |
230 | 43 | sandbox-tear-down: |
231 | | - name: "Sandbox tear down" |
232 | | - if: success() || failure() |
233 | | - runs-on: ubuntu-latest |
234 | | - needs: |
235 | | - - test-accessibility |
236 | | - - test-ui-component |
237 | | - - test-api |
238 | | - - test-e2e |
239 | | - environment: dev |
240 | | - steps: |
241 | | - - uses: hashicorp/setup-terraform@v3 |
242 | | - - uses: asdf-vm/actions/setup@v3 |
243 | | - - name: "Checkout code" |
244 | | - uses: actions/checkout@v4 |
245 | | - - name: Configure AWS credentials |
246 | | - uses: aws-actions/configure-aws-credentials@v4 |
247 | | - with: |
248 | | - role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/${{ secrets.AWS_ASSUME_ROLE_NAME }} |
249 | | - role-session-name: templates-ci-sandbox-teardown |
250 | | - aws-region: eu-west-2 |
251 | | - - name: "Get normalized branch name" |
252 | | - id: normalize_branch_name |
253 | | - uses: ./.github/actions/normalize-branch-name |
254 | | - - name: "Destroy Backend sandbox" |
255 | | - run: | |
256 | | - npm run destroy-backend-sandbox ${{ steps.normalize_branch_name.outputs.normalized_branch_name }} |
| 44 | + name: Step 3 |
| 45 | + needs: acceptance-tests |
| 46 | + if: always() |
| 47 | + |
| 48 | + uses: ./.github/workflows/dispatch_internal_repo_workflow.yaml |
| 49 | + secrets: inherit |
| 50 | + with: |
| 51 | + jobName: Sandbox tear down |
| 52 | + infraRepoName: nhs-notify-template-management |
| 53 | + releaseVersion: ${{ github.head_ref || github.ref_name }} |
| 54 | + targetWorkflow: dispatch-deploy-dynamic-env.yaml |
| 55 | + targetEnvironment: pr${{ github.event.number }} |
| 56 | + targetAccountGroup: nhs-notify-template-management-dev |
| 57 | + targetComponent: sandbox |
| 58 | + terraformAction: destroy |
0 commit comments