Skip to content

Commit 218d3d5

Browse files
Merge branch 'develop' into feature/axkr1-NRL-1176-fix-feature-test-error
2 parents 3f6f092 + 32d461f commit 218d3d5

File tree

117 files changed

+10054
-1279
lines changed

Some content is hidden

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

117 files changed

+10054
-1279
lines changed

.github/workflows/daily-build.yml

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
name: Build NRL Project on Environment
2+
run-name: Build NRL Project on ${{ inputs.environment || 'dev' }}
3+
permissions:
4+
id-token: write
5+
contents: read
6+
actions: write
7+
8+
on:
9+
schedule:
10+
- cron: "0 1 * * *"
11+
workflow_dispatch:
12+
inputs:
13+
environment:
14+
type: environment
15+
description: "The environment to deploy changes to"
16+
default: "dev"
17+
required: true
18+
19+
jobs:
20+
build:
21+
name: Build - develop
22+
runs-on: [self-hosted, ci]
23+
24+
steps:
25+
- name: Git clone - develop
26+
uses: actions/checkout@v4
27+
with:
28+
ref: develop
29+
30+
- name: Setup asdf cache
31+
uses: actions/cache@v4
32+
with:
33+
path: ~/.asdf
34+
key: ${{ runner.os }}-asdf-${{ hashFiles('**/.tool-versions') }}
35+
restore-keys: |
36+
${{ runner.os }}-asdf-
37+
38+
- name: Install asdf
39+
uses: asdf-vm/actions/[email protected]
40+
with:
41+
asdf_branch: v0.13.1
42+
43+
- name: Install zip
44+
run: sudo apt-get install zip
45+
46+
- name: Setup Python environment
47+
run: |
48+
poetry install --no-root
49+
source $(poetry env info --path)/bin/activate
50+
51+
- name: Run Linting
52+
run: make lint
53+
54+
- name: Run Unit Tests
55+
run: make test
56+
57+
- name: Build Project
58+
run: make build
59+
60+
- name: Configure Management Credentials
61+
uses: aws-actions/configure-aws-credentials@v4
62+
with:
63+
aws-region: eu-west-2
64+
role-to-assume: ${{ secrets.MGMT_ROLE_ARN }}
65+
role-session-name: github-actions-ci-${{ inputs.environment || 'dev' }}-${{ github.run_id }}
66+
67+
- name: Add S3 Permissions to Lambda
68+
run: |
69+
account=$(echo '${{ inputs.environment || 'dev' }}' | cut -d '-' -f1)
70+
inactive_stack=$(poetry run python ./scripts/get_env_config.py inactive-stack ${{ inputs.environment || 'dev' }})
71+
make get-s3-perms ENV=${account} TF_WORKSPACE_NAME=${inactive_stack}
72+
73+
- name: Save Build Artifacts
74+
uses: actions/upload-artifact@v4
75+
with:
76+
name: build-artifacts
77+
path: |
78+
dist/*.zip
79+
!dist/nrlf_permissions.zip
80+
81+
- name: Save NRLF Permissions cache
82+
uses: actions/cache/save@v4
83+
with:
84+
key: ${{ github.run_id }}-nrlf-permissions
85+
path: dist/nrlf_permissions.zip

.github/workflows/pr-env-deploy.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,53 @@ jobs:
264264
- name: Run Integration Tests
265265
run: make test-features-integration TF_WORKSPACE_NAME=${{ needs.set-environment-id.outputs.environment_id }}
266266

267+
smoke-test:
268+
name: Run Smoke Tests
269+
needs: [set-environment-id, integration-test]
270+
environment: pull-request
271+
runs-on: [self-hosted, ci]
272+
steps:
273+
- name: Git Clone - ${{ github.event.pull_request.head.ref }}
274+
uses: actions/checkout@v4
275+
with:
276+
ref: ${{ github.event.pull_request.head.ref }}
277+
278+
- name: Setup asdf cache
279+
uses: actions/cache@v4
280+
with:
281+
path: ~/.asdf
282+
key: ${{ runner.os }}-asdf-${{ hashFiles('**/.tool-versions') }}
283+
restore-keys: |
284+
${{ runner.os }}-asdf-
285+
286+
- name: Install asdf and tools
287+
uses: asdf-vm/actions/[email protected]
288+
with:
289+
asdf_branch: v0.13.1
290+
291+
- name: Setup Python environment
292+
run: |
293+
poetry install --no-root
294+
source $(poetry env info --path)/bin/activate
295+
296+
- name: Configure Management Credentials
297+
uses: aws-actions/configure-aws-credentials@v4
298+
with:
299+
aws-region: eu-west-2
300+
role-to-assume: ${{ secrets.MGMT_ROLE_ARN }}
301+
role-session-name: github-actions-ci-${{ needs.set-environment-id.outputs.environment_id }}
302+
303+
- name: Terraform Init
304+
run: |
305+
terraform -chdir=terraform/infrastructure init
306+
terraform -chdir=terraform/infrastructure workspace new ${{ needs.set-environment-id.outputs.environment_id }} || \
307+
terraform -chdir=terraform/infrastructure workspace select ${{ needs.set-environment-id.outputs.environment_id }}
308+
309+
- name: Smoke Test
310+
run: |
311+
make ENV=dev truststore-pull-client
312+
make ENV=dev TF_WORKSPACE_NAME=${{ needs.set-environment-id.outputs.environment_id }} test-smoke-internal
313+
267314
performance-test:
268315
name: Run Performance Tests
269316
needs: [set-environment-id, integration-test]

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 Crown Copyright
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

api/consumer/searchDocumentReference/search_document_reference.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from nrlf.core.logger import LogReference, logger
1010
from nrlf.core.model import ConnectionMetadata, ConsumerRequestParams
1111
from nrlf.core.response import Response, SpineErrorResponse
12-
from nrlf.core.validators import validate_type_system
12+
from nrlf.core.validators import validate_category, validate_type
1313

1414

1515
@request_handler(params=ConsumerRequestParams)
@@ -46,18 +46,28 @@ def handler(
4646
base_url = f"https://{config.ENVIRONMENT}.api.service.nhs.uk/"
4747
self_link = f"{base_url}record-locator/consumer/FHIR/R4/DocumentReference?subject:identifier=https://fhir.nhs.uk/Id/nhs-number|{params.nhs_number}"
4848

49-
# TODO - Add checks for the type code as well as system
50-
if not validate_type_system(params.type, metadata.pointer_types):
49+
if not validate_type(params.type, metadata.pointer_types):
5150
logger.log(
5251
LogReference.CONSEARCH002,
5352
type=params.type,
5453
pointer_types=metadata.pointer_types,
5554
)
5655
return SpineErrorResponse.INVALID_CODE_SYSTEM(
57-
diagnostics="Invalid query parameter (The provided type system does not match the allowed types for this organisation)",
56+
diagnostics="Invalid query parameter (The provided type does not match the allowed types for this organisation)",
5857
expression="type",
5958
)
6059

60+
categories = params.category.root.split(",") if params.category else []
61+
if not validate_category(categories):
62+
logger.log(
63+
LogReference.CONSEARCH002b,
64+
category=params.category,
65+
) # TODO - Should update error message once permissioning by category is implemented
66+
return SpineErrorResponse.INVALID_CODE_SYSTEM(
67+
diagnostics="Invalid query parameter (The provided category is not valid)",
68+
expression="category",
69+
)
70+
6171
custodian_id = (
6272
params.custodian_identifier.root.split("|", maxsplit=1)[1]
6373
if params.custodian_identifier
@@ -70,6 +80,9 @@ def handler(
7080
if params.type:
7181
self_link += f"&type={params.type.root}"
7282

83+
if params.category:
84+
self_link += f"&category={params.category.root}"
85+
7386
bundle = {
7487
"resourceType": "Bundle",
7588
"type": "searchset",
@@ -89,6 +102,7 @@ def handler(
89102
nhs_number=params.nhs_number,
90103
custodian=custodian_id,
91104
pointer_types=pointer_types,
105+
categories=categories,
92106
):
93107
try:
94108
document_reference = DocumentReference.model_validate_json(result.document)

0 commit comments

Comments
 (0)