Skip to content

Commit

Permalink
Merge pull request #331 from NHSDigital/AMB-2327-Fix-Pipeline-Issues
Browse files Browse the repository at this point in the history
AMB-2327-fix-major-pipeline-issue
  • Loading branch information
CLJ2006 authored Jan 30, 2025
2 parents 8f8efd9 + a927d36 commit e570f39
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 45 deletions.
68 changes: 54 additions & 14 deletions .github/workflows/sonarcloud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ jobs:
name: SonarCloud
if: ${{ !contains(github.event.pull_request.labels.*.name, 'dependency') }}
runs-on: ubuntu-latest


steps:
- uses: actions/checkout@v4
with:
Expand All @@ -25,38 +27,76 @@ jobs:
aws configure set aws_access_key_id $AWS_ACCESS_KEY_ID
aws configure set aws_secret_access_key $AWS_SECRET_ACCESS_KEY
- name: Initialize Unit Test Failure Tracker
run: echo "false" > test_failed.txt

- name: Run unittest with filenameprocessor-coverage
id: filenameprocessor
continue-on-error: true
run: |
pip install poetry moto==4.2.11 coverage redis botocore==1.35.49 simplejson pandas freezegun
poetry run coverage run --source=filenameprocessor -m unittest discover -s filenameprocessor
pip install poetry==1.8.4 moto==4.2.11 coverage redis botocore==1.35.49 simplejson pandas freezegun
poetry run coverage run --source=filenameprocessor -m unittest discover -s filenameprocessor || echo "filenameprocessor tests failed" >> failed_tests.txt
poetry run coverage xml -o sonarcloud-coverage-filenameprocessor-coverage.xml
- name: Run unittest with recordprocessor-coverage
id: recordprocessor
continue-on-error: true
run: |
poetry run coverage run --source=recordprocessor -m unittest discover -s recordprocessor || echo "recordprocessor tests failed" >> failed_tests.txt
poetry run coverage xml -o sonarcloud-coverage-recordprocessor-coverage.xml
- name: Run unittest with recordforwarder-coverage
id: recordforwarder
continue-on-error: true
run: |
poetry run coverage run --source=recordforwarder -m unittest discover -s recordforwarder
poetry run coverage xml -o sonarcloud-coverage-recordforwarder-coverage.xml
poetry run coverage run --source=backend -m unittest discover -s backend/tests -p "*batch*.py" || echo "recordforwarder tests failed" >> failed_tests.txt
poetry run coverage xml -o sonarcloud-coverage-recordforwarder-coverage.xml
- name: Run unittest with coverage-ack-lambda
id: acklambda
continue-on-error: true
run: |
pip install poetry coverage moto==4.2.11 freezegun
poetry run coverage run --source=ack_backend -m unittest discover -s ack_backend
poetry run coverage xml -o sonarcloud-coverage-ack-lambda.xml
pip install poetry==1.8.4 coverage moto==4.2.11 freezegun
poetry run coverage run --source=ack_backend -m unittest discover -s ack_backend || echo "ack-lambda tests failed" >> failed_tests.txt
poetry run coverage xml -o sonarcloud-coverage-ack-lambda.xml
- name: Run unittest with coverage-delta
id: delta
continue-on-error: true
run: |
pip install poetry 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
poetry run coverage run --source=delta_backend -m unittest discover -s delta_backend
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
poetry run coverage run --source=delta_backend -m unittest discover -s delta_backend || echo "delta tests failed" >> failed_tests.txt
poetry run coverage xml -o sonarcloud-coverage-delta.xml
- name: Run unittest with coverage-fhir-api
id: fhirapi
continue-on-error: true
run: |
pip install poetry 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
poetry run coverage run --source=backend -m unittest discover -s backend
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
poetry run coverage run --source=backend -m unittest discover -s backend || echo "fhir-api tests failed" >> failed_tests.txt
poetry run coverage xml -o sonarcloud-coverage.xml
- name: Run Test Failure Summary
id: check_failure
run: |
if [ -s failed_tests.txt ]; then
echo "The following tests failed:"
cat failed_tests.txt
while IFS= read -r line; do
echo "##[error]Test Failures: $line"
done < failed_tests.txt
exit 1
else
echo "All tests passed."
fi
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
uses: SonarSource/sonarqube-scan-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
12 changes: 12 additions & 0 deletions backend/tests/test_forwarding_batch_lambda.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
"""Test for recordforwarder lambda"""

import unittest

## Remove this Test- this acting as a placeholder for actual record forwarder tests


class Test_forward_lambda_handler(unittest.TestCase):
def test_name_length(self):
"""Test that the length of 'recordforwarder' is 15."""
name = "recordforwarder"
self.assertEqual(len(name), 15) # This test will pass
4 changes: 2 additions & 2 deletions e2e/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ To run all the tests you need to provide a `.env` file. The below table describe
| APIGEE_USERNAME | [email protected] | this value is needed inorder to authenticate with apigee |
| APIGEE_ENVIRONMENT | internal-dev | apigee environment |
| PROXY_NAME | immunisation-fhir-api-pr-100 | this the proxy name that you want to target. You can find it in the apigee ui |
| SERVICE_BASE_PATH | immunisation-fhir-api-pr-100 | the base path for the proxy. This value can be found in overview section in the apigee ui |
| SERVICE_BASE_PATH | immunisation-fhir-api/FHIR/R4-pr-100 | the base path for the proxy. This value can be found in overview section in the apigee ui |
| STATUS_API_KEY | secret | if you don't have this value then _status endpoint test will fail. You can ignore it |
| AWS_PROFILE | apim-dev | some operation may need to run aws cli. This value is used for aws authentication |
| AWS_DOMAIN_NAME | https://pr-100.imms.dev.vds.platform.nhs.uk | this value points to our backend deployment. We use it to test mTLS. Ignore it in local tests |
Expand All @@ -40,7 +40,7 @@ Given your `.env` file:
export APIGEE_USERNAME=<your-apigee-email>
export APIGEE_ENVIRONMENT=internal-dev
export PROXY_NAME=immunisation-fhir-api-pr-100
export SERVICE_BASE_PATH=immunisation-fhir-api-pr-100
export SERVICE_BASE_PATH=immunisation-fhir-api/FHIR/R4-pr-100
```

You can run all tests using:
Expand Down
51 changes: 25 additions & 26 deletions filenameprocessor/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,32 +1,31 @@
[tool.poetry]
name = "filenameprocessor"
version = "0.1.0"
name = "filenameprocessor"
version = "0.1.0"
description = ""
authors = ["Your Name <[email protected]>"]
readme = "README.md"
packages = [{include = "src"}]
readme = "README.md"
authors = ["Your Name <[email protected]>"]
packages = [{ include = "src" }]

[tool.poetry.dependencies]
python = "~3.10"
"fhir.resources" = "~7.0.2"
boto3 = "~1.26.90"
boto3-stubs-lite = {extras = ["dynamodb"], version = "~1.26.90"}
aws-lambda-typing = "~2.18.0"
moto = "~4.2.11"
requests = "~2.31.0"
responses = "~0.24.1"
pydantic = "~1.10.13"
pyjwt = "~2.8.0"
cryptography = "~42.0.4"
cffi = "~1.16.0"
jsonpath-ng = "^1.6.0"
simplejson = "^3.19.2"
structlog = "^24.1.0"
redis = "^5.1.1"
coverage = "7.6.1"
freezegun = "^1.5.1"
python = "~3.10"
"fhir.resources" = "~7.0.2"
boto3 = "~1.26.90"
boto3-stubs-lite = { extras = ["dynamodb"], version = "~1.26.90" }
aws-lambda-typing = "~2.18.0"
moto = "~4.2.11"
requests = "~2.31.0"
responses = "~0.24.1"
pydantic = "~1.10.13"
pyjwt = "~2.8.0"
cryptography = "~42.0.4"
cffi = "~1.16.0"
jsonpath-ng = "^1.6.0"
simplejson = "^3.19.2"
structlog = "^24.1.0"
redis = "^5.1.1"
coverage = "7.6.1"
freezegun = "^1.5.1"

[build-system]
requires = ["poetry-core ~= 1.5.0"]

build-backend = "poetry.core.masonry.api"
requires = ["poetry-core >= 1.5.0"]
build-backend = "poetry.core.masonry.api"
2 changes: 1 addition & 1 deletion filenameprocessor/tests/test_audit_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def test_add_to_audit_table(self):
expected_table_item_3 = {
"message_id": message_id_3,
"filename": file_key_1,
"status": "Processed",
"status": "Not processed - duplicate",
"timestamp": created_at_formatted_string_3,
}

Expand Down
4 changes: 2 additions & 2 deletions sonar-project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ sonar.organization=nhsdigital
sonar.host.url=https://sonarcloud.io
sonar.python.version=3.11
sonar.exclusions=**/e2e/**,**/temporary_sandbox/**,**/devtools/**,**/proxies/**,**/scripts/**,**/terraform/**,**/tests/**
sonar.python.coverage.reportPaths=sonarcloud-coverage.xml,sonarcloud-coverage-delta.xml,sonarcloud-coverage-ack-lambda.xml,sonarcloud-coverage-filenameprocessor-coverage.xml,sonarcloud-coverage-recordforwarder-coverage.xml
sonar.python.coverage.reportPaths=sonarcloud-coverage.xml,sonarcloud-coverage-delta.xml,sonarcloud-coverage-ack-lambda.xml,sonarcloud-coverage-filenameprocessor-coverage.xml,sonarcloud-coverage-recordforwarder-coverage.xml,sonarcloud-coverage-recordprocessor-coverage.xml
sonar.issue.ignore.multicriteria=exclude_snomed_urls
sonar.issue.ignore.multicriteria.exclude_snomed_urls.ruleKey=python:S5332
sonar.issue.ignore.multicriteria.exclude_snomed_urls.pattern=**http://snomed\.info/sct**
sonar.issue.ignore.multicriteria.exclude_snomed_urls.resourceKey=**http://snomed\.info/sct**

0 comments on commit e570f39

Please sign in to comment.