Skip to content

Commit 115865c

Browse files
authored
Merge pull request #3930 from nhsuk/next
Version 2.8.0
2 parents 528af92 + b4cfe97 commit 115865c

76 files changed

Lines changed: 1687 additions & 568 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/data-replication-pipeline.yml

Lines changed: 51 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: Data replication pipeline
2-
run-name: ${{ inputs.action }} data replication resources for ${{ inputs.environment }}
2+
run-name: ${{ inputs.deployment_type }} for data replication resources for ${{ inputs.environment }}
33

44
on:
55
workflow_dispatch:
@@ -15,18 +15,17 @@ on:
1515
- qa
1616
- sandbox-alpha
1717
- sandbox-beta
18+
deployment_type:
19+
description: Deployment type
20+
required: true
21+
type: choice
22+
options:
23+
- Deployment with DB recreation
24+
- Application only deployment
1825
image_tag:
1926
description: Docker image tag to deploy
2027
required: false
2128
type: string
22-
action:
23-
description: Action to perform on data replication env
24-
required: true
25-
type: choice
26-
options:
27-
- Destroy
28-
- Recreate
29-
default: Recreate
3029
db_snapshot_arn:
3130
description: ARN of the DB snapshot to use (optional)
3231
required: false
@@ -50,8 +49,8 @@ concurrency:
5049
group: deploy-data-replica-${{ inputs.environment }}
5150

5251
jobs:
53-
prepare:
54-
if: ${{ inputs.action == 'Recreate' }}
52+
prepare-db-replica:
53+
if: ${{ inputs.deployment_type == 'Deployment with DB recreation' }}
5554
name: Prepare data replica
5655
runs-on: ubuntu-latest
5756
permissions:
@@ -95,58 +94,13 @@ jobs:
9594
terraform init -backend-config="env/${{ inputs.environment }}-backend.hcl" -upgrade
9695
DB_SECRET_ARN=$(terraform output --raw db_secret_arn)
9796
echo "DB_SECRET_ARN=$DB_SECRET_ARN" >> $GITHUB_OUTPUT
98-
- name: ECR login
99-
id: login-ecr
100-
uses: aws-actions/amazon-ecr-login@v2
101-
- name: Get docker image digest
102-
id: get-docker-image-digest
103-
run: |
104-
set -e
105-
DOCKER_IMAGE="${{ steps.login-ecr.outputs.registry }}/mavis/webapp:${{ inputs.image_tag || github.sha }}"
106-
docker pull "$DOCKER_IMAGE"
107-
DOCKER_DIGEST=$(docker inspect --format='{{index .RepoDigests 0}}' "$DOCKER_IMAGE")
108-
DIGEST="${DOCKER_DIGEST#*@}"
109-
echo "DIGEST=$DIGEST" >> $GITHUB_OUTPUT
11097
outputs:
11198
SNAPSHOT_ARN: ${{ steps.get-latest-snapshot.outputs.SNAPSHOT_ARN }}
11299
DB_SECRET_ARN: ${{ steps.get-db-secret-arn.outputs.DB_SECRET_ARN }}
113-
DOCKER_DIGEST: ${{ steps.get-docker-image-digest.outputs.DIGEST }}
114-
115-
plan-destroy:
116-
name: Plan destruction job
117-
runs-on: ubuntu-latest
118-
permissions:
119-
id-token: write
120-
steps:
121-
- name: Checkout code
122-
uses: actions/checkout@v4
123-
- name: Configure AWS Credentials
124-
uses: aws-actions/configure-aws-credentials@v4
125-
with:
126-
role-to-assume: ${{ env.aws_role }}
127-
aws-region: eu-west-2
128-
- name: Install terraform
129-
uses: hashicorp/setup-terraform@v3
130-
with:
131-
terraform_version: 1.11.4
132-
- name: Terraform Plan
133-
run: |
134-
set -e
135-
terraform init -backend-config="env/${{ inputs.environment }}-backend.hcl" -upgrade
136-
terraform plan -destroy -var-file="env/${{ inputs.environment }}.tfvars" -var="image_digest=filler_value" \
137-
-var="db_secret_arn=filler_value" -var="imported_snapshot=filler_value" \
138-
-out ${{ runner.temp }}/tfplan_destroy | tee ${{ runner.temp }}/tf_stdout
139-
- name: Upload artifact
140-
uses: actions/upload-artifact@v4
141-
with:
142-
name: tfplan_destroy_infrastructure-${{ inputs.environment }}
143-
path: ${{ runner.temp }}/tfplan_destroy
144100

145-
destroy:
146-
name: Destroy data replication infrastructure
101+
prepare-webapp:
102+
name: Prepare webapp
147103
runs-on: ubuntu-latest
148-
needs: plan-destroy
149-
environment: ${{ inputs.environment }}
150104
permissions:
151105
id-token: write
152106
steps:
@@ -157,32 +111,35 @@ jobs:
157111
with:
158112
role-to-assume: ${{ env.aws_role }}
159113
aws-region: eu-west-2
160-
- name: Install terraform
161-
uses: hashicorp/setup-terraform@v3
162-
with:
163-
terraform_version: 1.11.4
164-
- name: Download artifact
165-
uses: actions/download-artifact@v4
166-
with:
167-
name: tfplan_destroy_infrastructure-${{ inputs.environment }}
168-
path: ${{ runner.temp }}
169-
- name: Terraform Destroy
170-
id: destroy
114+
- name: ECR login
115+
id: login-ecr
116+
uses: aws-actions/amazon-ecr-login@v2
117+
- name: Get docker image digest
118+
id: get-docker-image-digest
171119
run: |
172120
set -e
173-
terraform init -backend-config="env/${{ inputs.environment }}-backend.hcl" -upgrade
174-
terraform apply ${{ runner.temp }}/tfplan_destroy
121+
DOCKER_IMAGE="${{ steps.login-ecr.outputs.registry }}/mavis/webapp:${{ inputs.image_tag || github.sha }}"
122+
docker pull "$DOCKER_IMAGE"
123+
DOCKER_DIGEST=$(docker inspect --format='{{index .RepoDigests 0}}' "$DOCKER_IMAGE")
124+
DIGEST="${DOCKER_DIGEST#*@}"
125+
echo "DIGEST=$DIGEST" >> $GITHUB_OUTPUT
126+
outputs:
127+
DOCKER_DIGEST: ${{ steps.get-docker-image-digest.outputs.DIGEST }}
175128

176129
plan:
177130
name: Terraform plan
178131
runs-on: ubuntu-latest
179132
needs:
180-
- prepare
181-
- destroy
133+
- prepare-db-replica
134+
- prepare-webapp
135+
if: ${{ !cancelled() &&
136+
(needs.prepare-db-replica.result == 'success' || needs.prepare-db-replica.result == 'skipped') &&
137+
needs.prepare-webapp.result == 'success' }}
182138
env:
183-
SNAPSHOT_ARN: ${{ needs.prepare.outputs.SNAPSHOT_ARN }}
184-
DB_SECRET_ARN: ${{ needs.prepare.outputs.DB_SECRET_ARN }}
185-
DOCKER_DIGEST: ${{ needs.prepare.outputs.DOCKER_DIGEST }}
139+
SNAPSHOT_ARN: ${{ needs.prepare-db-replica.outputs.SNAPSHOT_ARN }}
140+
DB_SECRET_ARN: ${{ needs.prepare-db-replica.outputs.DB_SECRET_ARN || 'arn:aws:secretsmanager:eu-west-2:000000000000:secret:placeholder' }}
141+
DOCKER_DIGEST: ${{ needs.prepare-webapp.outputs.DOCKER_DIGEST }}
142+
REPLACE_DB_CLUSTER: ${{ inputs.deployment_type == 'Deployment with DB recreation' }}
186143
permissions:
187144
id-token: write
188145
steps:
@@ -200,12 +157,24 @@ jobs:
200157
- name: Terraform Plan
201158
id: plan
202159
run: |
203-
set -e
160+
set -eo pipefail
204161
terraform init -backend-config="env/${{ inputs.environment }}-backend.hcl" -upgrade
205-
terraform plan -var="image_digest=${{ env.DOCKER_DIGEST }}" -var="db_secret_arn=${{ env.DB_SECRET_ARN }}" \
206-
-var="imported_snapshot=${{ env.SNAPSHOT_ARN }}" -var-file="env/${{ inputs.environment }}.tfvars" \
207-
-var='allowed_egress_cidr_blocks=${{ inputs.egress_cidr }}' \
208-
-out ${{ runner.temp }}/tfplan | tee ${{ runner.temp }}/tf_stdout
162+
163+
CIDR_BLOCKS='${{ inputs.egress_cidr }}'
164+
PLAN_ARGS=(
165+
"plan"
166+
"-var=image_digest=${{ env.DOCKER_DIGEST }}"
167+
"-var=db_secret_arn=${{ env.DB_SECRET_ARN }}"
168+
"-var=imported_snapshot=${{ env.SNAPSHOT_ARN }}"
169+
"-var-file=env/${{ inputs.environment }}.tfvars"
170+
"-var=allowed_egress_cidr_blocks=$CIDR_BLOCKS"
171+
"-out=${{ runner.temp }}/tfplan"
172+
)
173+
174+
if [ "${{ env.REPLACE_DB_CLUSTER }}" = "true" ]; then
175+
PLAN_ARGS+=("-replace" "aws_rds_cluster.cluster")
176+
fi
177+
terraform "${PLAN_ARGS[@]}" | tee ${{ runner.temp }}/tf_stdout
209178
- name: Upload artifact
210179
uses: actions/upload-artifact@v4
211180
with:
@@ -216,6 +185,7 @@ jobs:
216185
name: Terraform apply
217186
runs-on: ubuntu-latest
218187
needs: plan
188+
if: ${{ !cancelled() && needs.plan.result == 'success' }}
219189
environment: ${{ inputs.environment }}
220190
permissions:
221191
id-token: write

.github/workflows/destroy-infrastructure.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,9 @@ jobs:
4747
run: |
4848
set -e
4949
terraform init -backend-config="env/${{ inputs.environment }}-backend.hcl" -upgrade
50-
if terraform state list | grep -q 'aws_rds_cluster.aurora_cluster'; then
51-
echo "DB cluster exsits: removing delete protection"
52-
CLUSTER_IDENTIFIER=$(grep -oP 'db_cluster\s*=\s*"\K[^"]+' env/${{ inputs.environment }}.tfvars)
53-
aws rds modify-db-cluster --db-cluster-identifier "$CLUSTER_IDENTIFIER" --no-deletion-protection
50+
if terraform state list | grep -q 'aws_rds_cluster.core'; then
51+
echo "DB cluster exists: removing delete protection"
52+
aws rds modify-db-cluster --db-cluster-identifier mavis-${{ inputs.environment }} --no-deletion-protection
5453
echo "DB cluster delete protection removed: proceeding to delete stage"
5554
else
5655
echo "DB cluster not in state: proceeding to delete stage"

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ WORKDIR /rails
1010

1111
# Install base packages
1212
RUN apt-get update -qq && \
13-
apt-get install --no-install-recommends -y curl libjemalloc2 libvips libicu-dev postgresql-client && \
13+
apt-get install --no-install-recommends -y curl libjemalloc2 libvips libicu-dev postgresql-client jq && \
1414
rm -rf /var/lib/apt/lists /var/cache/apt/archives
1515

1616
# Set production environment

Gemfile.lock

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ GEM
113113
ast (2.4.3)
114114
attr_required (1.0.2)
115115
aws-eventstream (1.4.0)
116-
aws-partitions (1.1125.0)
116+
aws-partitions (1.1126.0)
117117
aws-sdk-accessanalyzer (1.73.0)
118118
aws-sdk-core (~> 3, >= 3.225.0)
119119
aws-sigv4 (~> 1.5)
@@ -124,7 +124,7 @@ GEM
124124
base64
125125
jmespath (~> 1, >= 1.6.1)
126126
logger
127-
aws-sdk-ec2 (1.533.0)
127+
aws-sdk-ec2 (1.537.0)
128128
aws-sdk-core (~> 3, >= 3.225.0)
129129
aws-sigv4 (~> 1.5)
130130
aws-sdk-ecr (1.104.0)
@@ -139,7 +139,7 @@ GEM
139139
aws-sdk-rds (1.283.0)
140140
aws-sdk-core (~> 3, >= 3.225.0)
141141
aws-sigv4 (~> 1.5)
142-
aws-sdk-s3 (1.191.0)
142+
aws-sdk-s3 (1.192.0)
143143
aws-sdk-core (~> 3, >= 3.225.0)
144144
aws-sdk-kms (~> 1)
145145
aws-sigv4 (~> 1.5)
@@ -229,15 +229,15 @@ GEM
229229
factory_bot_rails (6.5.0)
230230
factory_bot (~> 6.5)
231231
railties (>= 6.1.0)
232-
faker (3.5.1)
232+
faker (3.5.2)
233233
i18n (>= 1.8.11, < 2)
234-
faraday (2.13.1)
234+
faraday (2.13.2)
235235
faraday-net_http (>= 2.0, < 3.5)
236236
json
237237
logger
238238
faraday-follow_redirects (0.3.0)
239239
faraday (>= 1, < 3)
240-
faraday-net_http (3.4.0)
240+
faraday-net_http (3.4.1)
241241
net-http (>= 0.5.0)
242242
ferrum (0.17.1)
243243
addressable (~> 2.5)
@@ -252,14 +252,14 @@ GEM
252252
date_time_precision (>= 0.8)
253253
mime-types (>= 3.0)
254254
nokogiri (>= 1.11.4)
255-
flipper (1.3.4)
255+
flipper (1.3.5)
256256
concurrent-ruby (< 2)
257-
flipper-active_record (1.3.4)
257+
flipper-active_record (1.3.5)
258258
activerecord (>= 4.2, < 9)
259-
flipper (~> 1.3.4)
260-
flipper-ui (1.3.4)
259+
flipper (~> 1.3.5)
260+
flipper-ui (1.3.5)
261261
erubi (>= 1.0.0, < 2.0.0)
262-
flipper (~> 1.3.4)
262+
flipper (~> 1.3.5)
263263
rack (>= 1.4, < 4)
264264
rack-protection (>= 1.5.3, < 5.0.0)
265265
rack-session (>= 1.0.2, < 3.0.0)
@@ -423,13 +423,13 @@ GEM
423423
webfinger (~> 2.0)
424424
orm_adapter (0.5.0)
425425
ostruct (0.6.2)
426-
pagy (9.3.4)
426+
pagy (9.3.5)
427427
parallel (1.27.0)
428428
parser (3.3.8.0)
429429
ast (~> 2.4.1)
430430
racc
431431
pg (1.5.9)
432-
phonelib (0.10.9)
432+
phonelib (0.10.10)
433433
pp (0.6.2)
434434
prettyprint
435435
prettier_print (1.2.1)
@@ -552,7 +552,7 @@ GEM
552552
rspec-mocks (~> 3.13)
553553
rspec-support (~> 3.13)
554554
rspec-support (3.13.4)
555-
rubocop (1.76.2)
555+
rubocop (1.77.0)
556556
json (~> 2.3)
557557
language_server-protocol (~> 3.17.0.2)
558558
lint_roller (~> 1.1.0)
@@ -569,8 +569,8 @@ GEM
569569
rubocop-capybara (2.22.1)
570570
lint_roller (~> 1.1)
571571
rubocop (~> 1.72, >= 1.72.1)
572-
rubocop-govuk (5.1.15)
573-
rubocop (= 1.76.2)
572+
rubocop-govuk (5.1.16)
573+
rubocop (= 1.77.0)
574574
rubocop-ast (= 1.45.1)
575575
rubocop-capybara (= 2.22.1)
576576
rubocop-rails (= 2.32.0)
@@ -618,7 +618,7 @@ GEM
618618
simplecov_json_formatter (~> 0.1)
619619
simplecov-html (0.12.3)
620620
simplecov_json_formatter (0.1.4)
621-
solargraph (0.55.4)
621+
solargraph (0.56.0)
622622
backport (~> 1.2)
623623
benchmark (~> 0.4)
624624
bundler (~> 2.0)
@@ -630,16 +630,17 @@ GEM
630630
observer (~> 0.1)
631631
ostruct (~> 0.6)
632632
parser (~> 3.0)
633+
prism (~> 1.4)
633634
rbs (~> 3.3)
634635
reverse_markdown (~> 3.0)
635636
rubocop (~> 1.38)
636637
thor (~> 1.0)
637638
tilt (~> 2.0)
638639
yard (~> 0.9, >= 0.9.24)
639640
yard-solargraph (~> 0.1)
640-
solargraph-rails (1.1.0)
641+
solargraph-rails (1.2.0)
641642
activesupport
642-
solargraph
643+
solargraph (= 0.56.0)
643644
splunk-sdk-ruby (1.0.5)
644645
stackprof (0.2.27)
645646
stimulus-rails (1.3.4)

app/components/app_vaccinate_form_component.rb

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,11 @@ def url
1919
end
2020

2121
def delivery_method
22-
triage_status = patient.triage_status(programme:)
23-
24-
status =
25-
if triage_status.not_required?
26-
patient.consent_status(programme:)
27-
else
28-
triage_status
29-
end
30-
31-
status.vaccine_method_nasal? ? :nasal_spray : :intramuscular
22+
if patient.approved_vaccine_methods(programme:).include?("nasal")
23+
:nasal_spray
24+
else
25+
:intramuscular
26+
end
3227
end
3328

3429
def dose_sequence

app/components/app_vaccination_record_summary_component.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,8 +329,6 @@ def dose_number_value
329329
end
330330

331331
def dose_number
332-
return nil if @programme.seasonal?
333-
334332
dose_sequence = @vaccination_record.dose_sequence
335333

336334
if dose_sequence.nil?

app/controllers/draft_vaccination_records_controller.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ def handle_confirm
120120

121121
send_vaccination_confirmation(@vaccination_record) if should_notify_parents
122122

123+
EnqueueSyncVaccinationRecordToNHS.call(@vaccination_record)
124+
123125
# In case the user navigates back to try and edit the newly created
124126
# vaccination record.
125127
@draft_vaccination_record.update!(editing_id: @vaccination_record.id)

0 commit comments

Comments
 (0)