Skip to content

Commit 61a2750

Browse files
authored
VED-305: Run SonarCloud unit tests in isolated environments. (#551)
* VED-305: Testing simple approach to fixing Sonar pipeline. * VED-305: Correct activate path. * VED-305: Use Python 3.10 * VED-305: Install poetry earlier. * VED-305: Attempt to use the correct python versions. * VED-305: Stop trying to be clever. * VED-305: One more try. * VED-305: Remove deactivate call. * VED-305: Save coverage and test failure to correct location. * VED-305: Ensure all subprojects have coverage dependency. * VED-305: Downgrade moto where it's causing issues. Remove custom PYTHONPATH for recordforwarder tests. * VED-305: Only search tests directory for tests.
1 parent ff86ab3 commit 61a2750

File tree

12 files changed

+622
-485
lines changed

12 files changed

+622
-485
lines changed

.github/workflows/sonarcloud.yml

Lines changed: 46 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,16 @@ jobs:
1717
with:
1818
fetch-depth: 0
1919

20+
- name: Install poetry
21+
run: pip install poetry==1.8.4
22+
23+
- uses: actions/setup-python@v5
24+
with:
25+
python-version: |
26+
3.10
27+
3.11
28+
cache: 'poetry'
29+
2030
- name: Set up AWS credentials
2131
env:
2232
AWS_ACCESS_KEY_ID: "FOOBARKEY"
@@ -25,65 +35,78 @@ jobs:
2535
aws configure set aws_access_key_id $AWS_ACCESS_KEY_ID
2636
aws configure set aws_secret_access_key $AWS_SECRET_ACCESS_KEY
2737
28-
- name: Initialize Unit Test Failure Tracker
29-
run: echo "false" > test_failed.txt
30-
3138
- name: Run unittest with filenameprocessor-coverage
39+
working-directory: filenameprocessor
3240
id: filenameprocessor
3341
continue-on-error: true
3442
run: |
35-
pip install poetry==1.8.4 moto==4.2.11 coverage redis botocore==1.35.49 simplejson pandas freezegun 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 fakeredis
36-
poetry run coverage run --source=filenameprocessor -m unittest discover -s filenameprocessor || echo "filenameprocessor tests failed" >> failed_tests.txt
37-
poetry run coverage xml -o sonarcloud-coverage-filenameprocessor-coverage.xml
43+
poetry env use 3.10
44+
poetry install
45+
poetry run coverage run -m unittest discover || echo "filenameprocessor tests failed" >> ../failed_tests.txt
46+
poetry run coverage xml -o ../sonarcloud-coverage-filenameprocessor-coverage.xml
3847
3948
- name: Run unittest with recordprocessor-coverage
49+
working-directory: recordprocessor
4050
id: recordprocessor
4151
continue-on-error: true
4252
run: |
43-
poetry run coverage run --source=recordprocessor -m unittest discover -s recordprocessor || echo "recordprocessor tests failed" >> failed_tests.txt
44-
poetry run coverage xml -o sonarcloud-coverage-recordprocessor-coverage.xml
53+
poetry env use 3.10
54+
poetry install
55+
poetry run coverage run -m unittest discover || echo "recordprocessor tests failed" >> ../failed_tests.txt
56+
poetry run coverage xml -o ../sonarcloud-coverage-recordprocessor-coverage.xml
4557
58+
# This step is redundant - all of these tests will be run in the backend step below
4659
- name: Run unittest with recordforwarder-coverage
60+
working-directory: backend
4761
id: recordforwarder
4862
continue-on-error: true
4963
run: |
50-
pip install poetry==1.8.4 moto==5.1.4
51-
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
52-
poetry run coverage xml -o sonarcloud-coverage-recordforwarder-coverage.xml
64+
poetry env use 3.11
65+
poetry install
66+
poetry run coverage run -m unittest discover -s "./tests" -p "*batch*.py" || echo "recordforwarder tests failed" >> ../failed_tests.txt
67+
poetry run coverage xml -o ../sonarcloud-coverage-recordforwarder-coverage.xml
5368
5469
- name: Run unittest with coverage-ack-lambda
70+
working-directory: ack_backend
5571
id: acklambda
5672
continue-on-error: true
5773
run: |
58-
pip install poetry==1.8.4 coverage moto==4.2.11 freezegun
59-
poetry run coverage run --source=ack_backend -m unittest discover -s ack_backend || echo "ack-lambda tests failed" >> failed_tests.txt
60-
poetry run coverage xml -o sonarcloud-coverage-ack-lambda.xml
74+
poetry env use 3.10
75+
poetry install
76+
poetry run coverage run -m unittest discover || echo "ack-lambda tests failed" >> ../failed_tests.txt
77+
poetry run coverage xml -o ../sonarcloud-coverage-ack-lambda.xml
6178
6279
- name: Run unittest with coverage-delta
80+
working-directory: delta_backend
6381
id: delta
6482
env:
6583
PYTHONPATH: delta_backend/src:delta_backend/tests
6684
continue-on-error: true
6785
run: |
68-
pip install poetry==1.8.4 moto==5.1.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
69-
poetry run coverage run --source=delta_backend -m unittest discover -s delta_backend || echo "delta tests failed" >> failed_tests.txt
70-
poetry run coverage xml -o sonarcloud-coverage-delta.xml
86+
poetry env use 3.11
87+
poetry install
88+
poetry run coverage run -m unittest discover || echo "delta tests failed" >> ../failed_tests.txt
89+
poetry run coverage xml -o ../sonarcloud-coverage-delta.xml
7190
7291
- name: Run unittest with coverage-fhir-api
92+
working-directory: backend
7393
id: fhirapi
7494
continue-on-error: true
7595
run: |
76-
pip install poetry==1.8.4 moto==5.1.4 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
77-
poetry run coverage run --source=backend -m unittest discover -s backend || echo "fhir-api tests failed" >> failed_tests.txt
78-
poetry run coverage xml -o sonarcloud-coverage.xml
96+
poetry env use 3.11
97+
poetry install
98+
poetry run coverage run -m unittest discover || echo "fhir-api tests failed" >> ../failed_tests.txt
99+
poetry run coverage xml -o ../sonarcloud-coverage.xml
79100
80101
- name: Run unittest with coverage-mesh-processor
102+
working-directory: mesh_processor
81103
id: meshprocessor
82104
continue-on-error: true
83105
run: |
84-
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
85-
poetry run coverage run --source=mesh_processor -m unittest discover -s mesh_processor || echo "mesh_processor tests failed" >> failed_tests.txt
86-
poetry run coverage xml -o sonarcloud-mesh_processor-coverage.xml
106+
poetry env use 3.10
107+
poetry install
108+
poetry run coverage run -m unittest discover || echo "mesh_processor tests failed" >> ../failed_tests.txt
109+
poetry run coverage xml -o ../sonarcloud-mesh_processor-coverage.xml
87110
88111
- name: Run Test Failure Summary
89112
id: check_failure

0 commit comments

Comments
 (0)