Skip to content

Commit 2393799

Browse files
Merge branch 'develop' into feature/hakh11-NRL-1002-consumerIntegrationTests
2 parents b6b69b7 + 072f141 commit 2393799

File tree

8 files changed

+510
-2
lines changed

8 files changed

+510
-2
lines changed

.github/workflows/persistent-environment.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,8 +234,7 @@ jobs:
234234

235235
- name: Update environment config version
236236
run: |
237-
short_commit_ref="$(echo ${{ github.sha }} | cut -c1-8)"
238-
deployed_version="${{ inputs.branch_name }}@${short_commit_ref}"
237+
deployed_version=$(terraform -chdir=terraform/infrastructure output --raw version)
239238
poetry run python ./scripts/set_env_config.py inactive-version ${deployed_version} ${{ inputs.environment }}
240239
241240
- name: Smoke Test
Lines changed: 296 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,296 @@
1+
name: Update Lambda Permissions
2+
run-name: Updating permissions on ${{ inputs.stack_name }} using ${{ github.ref }} by ${{ github.actor }}
3+
4+
on:
5+
workflow_dispatch:
6+
inputs:
7+
environment:
8+
description: Environment to deploy to
9+
required: true
10+
default: "dev"
11+
type: environment
12+
13+
stack_name:
14+
description: Stack to update
15+
required: true
16+
type: string
17+
18+
strict_versioning:
19+
description: Use strict versioning (recommended)
20+
required: true
21+
type: boolean
22+
default: true
23+
24+
permissions:
25+
id-token: write
26+
contents: read
27+
actions: write
28+
29+
jobs:
30+
check-versions:
31+
name: Check versions
32+
runs-on: [self-hosted, ci]
33+
34+
steps:
35+
- name: Git clone - ${{ github.ref }}
36+
uses: actions/checkout@v4
37+
with:
38+
ref: ${{ github.ref }}
39+
40+
- name: Setup asdf cache
41+
uses: actions/cache@v4
42+
with:
43+
path: ~/.asdf
44+
key: ${{ runner.os }}-asdf-${{ hashFiles('**/.tool-versions') }}
45+
restore-keys: |
46+
${{ runner.os }}-asdf-
47+
48+
- name: Install asdf
49+
uses: asdf-vm/actions/[email protected]
50+
51+
- name: Install zip
52+
run: sudo apt-get install zip
53+
54+
- name: Setup Python environment
55+
run: |
56+
poetry install --no-root
57+
source $(poetry env info --path)/bin/activate
58+
59+
- name: Configure Management Credentials
60+
uses: aws-actions/configure-aws-credentials@v4
61+
with:
62+
aws-region: eu-west-2
63+
role-to-assume: ${{ secrets.MGMT_ROLE_ARN }}
64+
role-session-name: github-actions-ci-${{ inputs.environment }}-${{ github.run_id }}
65+
66+
- name: Terraform Init
67+
run: |
68+
terraform -chdir=terraform/infrastructure init
69+
terraform -chdir=terraform/infrastructure workspace new ${{ inputs.stack_name }} || \
70+
terraform -chdir=terraform/infrastructure workspace select ${{ inputs.stack_name }}
71+
72+
- name: Check deployed version matches build version
73+
run: |
74+
this_version="$(./scripts/get-current-info.sh | jq -r .version)"
75+
deployed_version="$(terraform -chdir=terraform/infrastructure output --raw version)"
76+
77+
echo "code-version=${this_version} deployed-version=${deployed_version}"
78+
79+
if [ "${deployed_version}" != "${this_version}" ]
80+
then
81+
echo "${this_version} does not match deployed version: ${deployed_version}" 1>&2
82+
83+
if [ "${{ inputs.strict_versioning }}" == "true" ]; then
84+
echo "Strict version checking failed, cancelling workflow" 1>&2
85+
exit 1
86+
fi
87+
fi
88+
89+
build-permissions:
90+
name: Build permissions
91+
runs-on: [self-hosted, ci]
92+
environment: ${{ inputs.environment }}
93+
94+
needs: [check-versions]
95+
96+
steps:
97+
- name: Git clone - ${{ github.ref }}
98+
uses: actions/checkout@v4
99+
with:
100+
ref: ${{ github.ref }}
101+
102+
- name: Setup asdf cache
103+
uses: actions/cache@v4
104+
with:
105+
path: ~/.asdf
106+
key: ${{ runner.os }}-asdf-${{ hashFiles('**/.tool-versions') }}
107+
restore-keys: |
108+
${{ runner.os }}-asdf-
109+
110+
- name: Install asdf
111+
uses: asdf-vm/actions/[email protected]
112+
113+
- name: Install zip
114+
run: sudo apt-get install zip
115+
116+
- name: Setup Python environment
117+
run: |
118+
poetry install --no-root
119+
source $(poetry env info --path)/bin/activate
120+
121+
- name: Configure Management Credentials
122+
uses: aws-actions/configure-aws-credentials@v4
123+
with:
124+
aws-region: eu-west-2
125+
role-to-assume: ${{ secrets.MGMT_ROLE_ARN }}
126+
role-session-name: github-actions-ci-${{ inputs.environment }}-${{ github.run_id }}
127+
128+
- name: Create lambda permissions layer
129+
run: |
130+
account=$(echo '${{ inputs.environment }}' | cut -d '-' -f1)
131+
make get-s3-perms ENV=${account} TF_WORKSPACE_NAME=${{ inputs.stack_name }}
132+
133+
- name: Save NRLF permissions in cache
134+
uses: actions/cache/save@v4
135+
with:
136+
key: ${{ github.run_id }}-nrlf-permissions
137+
path: dist/nrlf_permissions.zip
138+
139+
pull-deployed-lambdas:
140+
name: Pull deployed lambdas
141+
runs-on: [self-hosted, ci]
142+
environment: ${{ inputs.environment }}
143+
144+
needs: [check-versions]
145+
146+
steps:
147+
- name: Git clone - ${{ github.ref }}
148+
uses: actions/checkout@v4
149+
with:
150+
ref: ${{ github.ref }}
151+
152+
- name: Configure Management Credentials
153+
uses: aws-actions/configure-aws-credentials@v4
154+
with:
155+
aws-region: eu-west-2
156+
role-to-assume: ${{ secrets.MGMT_ROLE_ARN }}
157+
role-session-name: github-actions-ci-${{ inputs.environment }}-${{ github.run_id }}
158+
159+
- name: Configure Account Role
160+
uses: aws-actions/configure-aws-credentials@v4
161+
with:
162+
aws-region: eu-west-2
163+
role-chaining: true
164+
role-to-assume: ${{ secrets.DEPLOY_ROLE_ARN }}
165+
role-session-name: github-actions-ci-acc-${{ inputs.environment }}-${{ github.run_id }}
166+
167+
- name: Pull deployed lambda artifacts
168+
run: |
169+
account=$(echo '${{ inputs.environment }}' | cut -d '-' -f1)
170+
./scripts/pull-lambda-code-for-stack.sh ${{ inputs.stack_name }}
171+
172+
- name: Save lambda artifacts in cache
173+
uses: actions/cache/save@v4
174+
with:
175+
key: ${{ github.run_id }}-pulled-lambda-artifacts
176+
path: dist/*.zip
177+
178+
terraform-plan:
179+
name: Plan changes
180+
runs-on: [self-hosted, ci]
181+
environment: ${{ inputs.environment }}
182+
183+
needs: [build-permissions, pull-deployed-lambdas]
184+
185+
steps:
186+
- name: Git clone - ${{ github.ref }}
187+
uses: actions/checkout@v4
188+
with:
189+
ref: ${{ github.ref }}
190+
191+
- name: Setup asdf cache
192+
uses: actions/cache@v4
193+
with:
194+
path: ~/.asdf
195+
key: ${{ runner.os }}-asdf-${{ hashFiles('**/.tool-versions') }}
196+
restore-keys: |
197+
${{ runner.os }}-asdf-
198+
199+
- name: Install asdf
200+
uses: asdf-vm/actions/[email protected]
201+
202+
- name: Install zip
203+
run: sudo apt-get install zip
204+
205+
- name: Setup Python environment
206+
run: |
207+
poetry install --no-root
208+
source $(poetry env info --path)/bin/activate
209+
210+
- name: Restore pulled lambda artifacts
211+
uses: actions/cache/restore@v4
212+
with:
213+
key: ${{ github.run_id }}-pulled-lambda-artifacts
214+
path: dist/*.zip
215+
fail-on-cache-miss: true
216+
217+
- name: Restore NRLF permissions cache
218+
uses: actions/cache/restore@v4
219+
with:
220+
key: ${{ github.run_id }}-nrlf-permissions
221+
path: dist/nrlf_permissions.zip
222+
fail-on-cache-miss: true
223+
224+
- name: Configure Management Credentials
225+
uses: aws-actions/configure-aws-credentials@v4
226+
with:
227+
aws-region: eu-west-2
228+
role-to-assume: ${{ secrets.MGMT_ROLE_ARN }}
229+
role-session-name: github-actions-ci-${{ inputs.environment }}-${{ github.run_id }}
230+
231+
- name: Terraform Init
232+
run: |
233+
terraform -chdir=terraform/infrastructure init
234+
terraform -chdir=terraform/infrastructure workspace new ${{ inputs.stack_name }} || \
235+
terraform -chdir=terraform/infrastructure workspace select ${{ inputs.stack_name }}
236+
237+
- name: Terraform Plan
238+
run: |
239+
terraform -chdir=terraform/infrastructure plan \
240+
--var-file=etc/${{ vars.ACCOUNT_NAME }}.tfvars \
241+
--var assume_role_arn=${{ secrets.DEPLOY_ROLE_ARN }} \
242+
--var use_shared_resources=$(poetry run python scripts/are_resources_shared_for_stack.py ${{ inputs.stack_name }}) \
243+
--out tfplan
244+
245+
- name: Save Terraform Plan
246+
run: |
247+
terraform -chdir=terraform/infrastructure show -no-color tfplan > terraform/infrastructure/tfplan.txt
248+
aws s3 cp terraform/infrastructure/tfplan s3://nhsd-nrlf--mgmt--github-ci-logging/${{ inputs.environment }}/${{ github.run_id }}/tfplan
249+
aws s3 cp terraform/infrastructure/tfplan.txt s3://nhsd-nrlf--mgmt--github-ci-logging/${{ inputs.environment }}/${{ github.run_id }}/tfplan.txt
250+
251+
terraform-apply:
252+
name: Apply permissions
253+
runs-on: [self-hosted, ci]
254+
environment: ${{ inputs.environment }}
255+
256+
needs: terraform-plan
257+
258+
steps:
259+
- name: Git clone - ${{ github.ref }}
260+
uses: actions/checkout@v4
261+
with:
262+
ref: ${{ github.ref }}
263+
264+
- name: Restore pulled lambda artifacts
265+
uses: actions/cache/restore@v4
266+
with:
267+
key: ${{ github.run_id }}-pulled-lambda-artifacts
268+
path: dist/*.zip
269+
fail-on-cache-miss: true
270+
271+
- name: Restore NRLF permissions cache
272+
uses: actions/cache/restore@v4
273+
with:
274+
key: ${{ github.run_id }}-nrlf-permissions
275+
path: dist/nrlf_permissions.zip
276+
fail-on-cache-miss: true
277+
278+
- name: Configure Management Credentials
279+
uses: aws-actions/configure-aws-credentials@v4
280+
with:
281+
aws-region: eu-west-2
282+
role-to-assume: ${{ secrets.MGMT_ROLE_ARN }}
283+
role-session-name: github-actions-ci-${{ inputs.environment }}-${{ github.run_id }}
284+
285+
- name: Download Terraform Plan artifact
286+
run: aws s3 cp s3://nhsd-nrlf--mgmt--github-ci-logging/${{ inputs.environment }}/${{ github.run_id }}/tfplan terraform/infrastructure/tfplan
287+
288+
- name: Terraform Init
289+
run: |
290+
terraform -chdir=terraform/infrastructure init
291+
terraform -chdir=terraform/infrastructure workspace new ${{ inputs.stack_name }} || \
292+
terraform -chdir=terraform/infrastructure workspace select ${{ inputs.stack_name }}
293+
294+
- name: Terraform Apply
295+
run: |
296+
terraform -chdir=terraform/infrastructure apply tfplan
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"resourceType": "ValueSet",
3+
"id": "NRLF-RecordCategory",
4+
"url": "https://fhir.nhs.uk/England/CodeSystem/England-NRLRecordCategory",
5+
"version": "1.1.1",
6+
"name": "NRLF Record Category",
7+
"status": "draft",
8+
"date": "2024-03-20T00:00:00+00:00",
9+
"publisher": "NHS Digital",
10+
"contact": {
11+
"name": "NRL Team at NHS Digital",
12+
"telecom": {
13+
"system": "email",
14+
"value": "[email protected]",
15+
"use": "work"
16+
}
17+
},
18+
"description": "A code from the SNOMED Clinical Terminology UK coding system to represent the NRL clinical record class.",
19+
"copyright": "Copyright 2024 NHS Digital. This value set includes content from SNOMED CT, which is copyright 2002+ International Health Terminology Standards Development Organisation (IHTSDO), and distributed by agreement between IHTSDO and HL7. Implementer use of SNOMED CT is not covered by this agreement.",
20+
"compose": {
21+
"include": [
22+
{
23+
"system": "http://snomed.info/sct",
24+
"concept": [
25+
{
26+
"code": "734163000",
27+
"display": "Care plan"
28+
},
29+
{
30+
"code": "1102421000000108",
31+
"display": "Observations"
32+
},
33+
{
34+
"code": "823651000000106",
35+
"display": "Clinical note"
36+
}
37+
]
38+
}
39+
]
40+
}
41+
}

0 commit comments

Comments
 (0)