Skip to content

Commit 09d8b75

Browse files
committed
Merge branch 'master' into VED-83-int-ref
2 parents 05f92d1 + 32c40a1 commit 09d8b75

20 files changed

+1211
-86
lines changed

.github/workflows/sonarcloud.yml

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ jobs:
1313
if: ${{ !contains(github.event.pull_request.labels.*.name, 'dependency') }}
1414
runs-on: ubuntu-latest
1515

16-
1716
steps:
1817
- uses: actions/checkout@v4
1918
with:
@@ -26,10 +25,10 @@ jobs:
2625
run: |
2726
aws configure set aws_access_key_id $AWS_ACCESS_KEY_ID
2827
aws configure set aws_secret_access_key $AWS_SECRET_ACCESS_KEY
29-
28+
3029
- name: Initialize Unit Test Failure Tracker
3130
run: echo "false" > test_failed.txt
32-
31+
3332
- name: Run unittest with filenameprocessor-coverage
3433
id: filenameprocessor
3534
continue-on-error: true
@@ -38,23 +37,20 @@ jobs:
3837
poetry run coverage run --source=filenameprocessor -m unittest discover -s filenameprocessor || echo "filenameprocessor tests failed" >> failed_tests.txt
3938
poetry run coverage xml -o sonarcloud-coverage-filenameprocessor-coverage.xml
4039
41-
4240
- name: Run unittest with recordprocessor-coverage
4341
id: recordprocessor
4442
continue-on-error: true
4543
run: |
4644
poetry run coverage run --source=recordprocessor -m unittest discover -s recordprocessor || echo "recordprocessor tests failed" >> failed_tests.txt
4745
poetry run coverage xml -o sonarcloud-coverage-recordprocessor-coverage.xml
4846
49-
5047
- name: Run unittest with recordforwarder-coverage
5148
id: recordforwarder
5249
continue-on-error: true
5350
run: |
5451
PYTHONPATH=$(pwd)/backend:$(pwd)/backend/tests poetry run coverage run --source=backend -m unittest discover -s backend/tests -p "*batch*.py" || echo "recordforwarder tests failed" >> failed_tests.txt
5552
poetry run coverage xml -o sonarcloud-coverage-recordforwarder-coverage.xml
5653
57-
5854
- name: Run unittest with coverage-ack-lambda
5955
id: acklambda
6056
continue-on-error: true
@@ -70,7 +66,7 @@ jobs:
7066
pip install poetry==1.8.4 mypy-boto3-dynamodb==1.35.54 boto3==1.26.165 coverage botocore==1.29.165 jmespath==1.0.1 python-dateutil==2.9.0 urllib3==1.26.20 s3transfer==0.6.2 typing-extensions==4.12.2
7167
poetry run coverage run --source=delta_backend -m unittest discover -s delta_backend || echo "delta tests failed" >> failed_tests.txt
7268
poetry run coverage xml -o sonarcloud-coverage-delta.xml
73-
69+
7470
- name: Run unittest with coverage-fhir-api
7571
id: fhirapi
7672
continue-on-error: true
@@ -79,6 +75,14 @@ jobs:
7975
poetry run coverage run --source=backend -m unittest discover -s backend || echo "fhir-api tests failed" >> failed_tests.txt
8076
poetry run coverage xml -o sonarcloud-coverage.xml
8177
78+
- name: Run unittest with coverage-mesh-processor
79+
id: meshprocessor
80+
continue-on-error: true
81+
run: |
82+
pip install poetry==1.8.4 moto==4.2.11 coverage redis botocore==1.35.49 simplejson responses structlog fhir.resources jsonpath_ng pydantic==1.10.13 requests aws-lambda-typing cffi pyjwt boto3-stubs-lite[dynamodb]~=1.26.90 python-stdnum==1.20
83+
poetry run coverage run --source=mesh_processor -m unittest discover -s mesh_processor || echo "mesh_processor tests failed" >> failed_tests.txt
84+
poetry run coverage xml -o sonarcloud-mesh_processor-coverage.xml
85+
8286
- name: Run Test Failure Summary
8387
id: check_failure
8488
run: |
@@ -98,5 +102,5 @@ jobs:
98102
- name: SonarCloud Scan
99103
uses: SonarSource/sonarqube-scan-action@master
100104
env:
101-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
102-
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
105+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
106+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ build-proxy:
3838
scripts/build_proxy.sh
3939

4040
#Files to loop over in release
41-
_dist_include="pytest.ini poetry.lock poetry.toml pyproject.toml Makefile build/. e2e e2e_batch specification sandbox terraform scripts backend delta_backend ack_backend filenameprocessor recordprocessor"
41+
_dist_include="pytest.ini poetry.lock poetry.toml pyproject.toml Makefile build/. e2e e2e_batch specification sandbox terraform scripts backend delta_backend ack_backend filenameprocessor recordprocessor mesh_processor"
4242

4343

4444
#Create /dist/ sub-directory and copy files into directory

filenameprocessor/src/file_key_validation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def validate_file_key(file_key: str) -> tuple[str, str]:
5454
and version in Constants.VALID_VERSIONS
5555
and supplier # Note that if supplier could be identified, this also implies that ODS code is valid
5656
and is_valid_datetime(timestamp)
57-
and extension == "CSV"
57+
and ((extension == "CSV") or (extension == "DAT")) # The DAT extension has been added for MESH file processing
5858
):
5959
raise InvalidFileKeyError("Initial file validation failed: invalid file key")
6060

filenameprocessor/tests/test_file_key_validation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def test_validate_file_key(self):
9393
# File key with missing timestamp
9494
(VALID_FLU_EMIS_FILE_KEY.replace("20000101T00000001", ""), invalid_file_key_error_message),
9595
# File key with incorrect extension
96-
(VALID_FLU_EMIS_FILE_KEY.replace(".csv", ".dat"), invalid_file_key_error_message),
96+
(VALID_FLU_EMIS_FILE_KEY.replace(".csv", ".xlsx"), invalid_file_key_error_message),
9797
]
9898

9999
for file_key, expected_result in test_cases_for_failure_scenarios:

immunisation-fhir-api.code-workspace

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@
1717
},
1818
{
1919
"path": "delta_backend"
20+
},
21+
{
22+
"path": "mesh_processor"
2023
}
2124
],
2225
"settings": {},
23-
24-
}
26+
}

mesh-infra/main.tf

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
terraform {
2+
required_providers {
3+
aws = {
4+
source = "hashicorp/aws"
5+
version = "~> 5"
6+
}
7+
}
8+
backend "s3" {
9+
region = "eu-west-2"
10+
key = "state"
11+
}
12+
required_version = ">= 1.5.0"
13+
}
14+
15+
16+
17+
data "aws_vpc" "default" {
18+
default = true
19+
}
20+
data "aws_subnets" "default" {
21+
filter {
22+
name = "vpc-id"
23+
values = [data.aws_vpc.default.id]
24+
}
25+
}
26+
27+
module "mesh" {
28+
source = "git::https://github.com/nhsdigital/terraform-aws-mesh-client.git//module?ref=v2.1.5"
29+
30+
name_prefix = "local-immunisation"
31+
mesh_env = "integration"
32+
subnet_ids = data.aws_subnets.default.ids
33+
34+
mailbox_ids = ["X26OT303"]
35+
verify_ssl = "true"
36+
get_message_max_concurrency = 10
37+
compress_threshold = 1 * 1024 * 1024
38+
handshake_schedule = "rate(24 hours)"
39+
40+
account_id = 345594581768
41+
}

mesh_processor/Dockerfile

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
FROM public.ecr.aws/lambda/python:3.10 AS base
2+
3+
# Create a non-root user with a specific UID and GID
4+
RUN mkdir -p /home/appuser && \
5+
echo 'appuser:x:1001:1001::/home/appuser:/sbin/nologin' >> /etc/passwd && \
6+
echo 'appuser:x:1001:' >> /etc/group && \
7+
chown -R 1001:1001 /home/appuser && pip install "poetry~=1.5.0"
8+
9+
10+
11+
COPY poetry.lock pyproject.toml README.md ./
12+
RUN poetry config virtualenvs.create false && poetry install --no-interaction --no-ansi --no-root --only main
13+
14+
15+
# -----------------------------
16+
FROM base AS build
17+
18+
COPY src .
19+
RUN chmod 644 $(find . -type f) && chmod 755 $(find . -type d)
20+
# Switch to the non-root user for running the container
21+
USER 1001:1001
22+
CMD ["converter.lambda_handler"]

mesh_processor/Makefile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
build:
2+
docker build -t mesh-lambda-build .
3+
4+
package: build
5+
mkdir -p build
6+
docker run --rm -v $(shell pwd)/build:/build mesh-lambda-build
7+
8+
test:
9+
python -m unittest
10+
11+
.PHONY: build package test

mesh_processor/README.md

Whitespace-only changes.

0 commit comments

Comments
 (0)