Skip to content

Commit 69df356

Browse files
committed
2 Jun
1 parent 2819041 commit 69df356

4 files changed

Lines changed: 215 additions & 80 deletions

File tree

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/bin/bash
2+
set -e
3+
4+
PYTHON_VERSION="$1"
5+
DESCRIPTION="$2"
6+
COVERAGE_XML="sonarcloud-coverage-$3.xml"
7+
8+
# show cwd
9+
echo "Current working directory: $(pwd)"
10+
# list contents of venv
11+
12+
ls -la .
13+
14+
########### debug
15+
echo "Which Python:"
16+
which python$PYTHON_VERSION || echo "python$PYTHON_VERSION not found in PATH"
17+
18+
echo "Available interpreters:"
19+
pyenv versions || true
20+
21+
echo "Using Python Version $PYTHON_VERSION"
22+
poetry config virtualenvs.in-project true
23+
##############
24+
25+
# Only create/use the env and install if .venv does not exist
26+
echo "Checking for Poetry virtual environment (.venv)"
27+
poetry env list
28+
if [ ! -d ".venv" ]; then
29+
echo "Creating virtual environment (.venv) with Poetry"
30+
poetry env use "$PYTHON_VERSION"
31+
32+
########### debug
33+
echo "Poetry environment info:"
34+
poetry env info || true
35+
###########
36+
37+
poetry install
38+
poetry env list
39+
else
40+
echo "Using cached virtual environment (.venv)"
41+
fi
42+
43+
if poetry run coverage run -m unittest discover; then
44+
echo "$DESCRIPTION tests passed"
45+
else
46+
echo "$DESCRIPTION tests failed" >> ../failed_tests.txt
47+
fi
48+
49+
poetry run coverage xml -o "../$COVERAGE_XML"

.github/scripts/run_test.sh

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,27 @@ echo "Current working directory: $(pwd)"
1111

1212
ls -la .
1313

14+
########### debug
15+
echo "Which Python:"
16+
which python$PYTHON_VERSION || echo "python$PYTHON_VERSION not found in PATH"
17+
1418

1519
echo "Using Python Version $PYTHON_VERSION"
16-
poetry config virtualenvs.in-project true
20+
##############
21+
1722

1823
# Only create/use the env and install if .venv does not exist
1924
echo "Checking for Poetry virtual environment (.venv)"
2025
poetry env list
2126
if [ ! -d ".venv" ]; then
2227
echo "Creating virtual environment (.venv) with Poetry"
2328
poetry env use "$PYTHON_VERSION"
29+
30+
########### debug
31+
echo "Poetry environment info:"
32+
poetry env info || true
33+
###########
34+
2435
poetry install
2536
poetry env list
2637
else

.github/workflows/sonarcloud.yml

Lines changed: 76 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,8 @@ jobs:
1616
runs-on: ubuntu-latest
1717
strategy:
1818
matrix:
19-
python-version: ['3.10', '3.11']
19+
python-version: ['3.11', '3.10']
2020

21-
2221
steps:
2322
- uses: actions/checkout@v4
2423
with:
@@ -29,98 +28,75 @@ jobs:
2928

3029
- uses: actions/setup-python@v5
3130
with:
32-
python-version: ${{ matrix.python-version }}
31+
python-version: |
32+
3.10
33+
3.11
3334
cache: 'poetry'
3435

35-
- name: Set up AWS credentials
36-
env:
37-
AWS_ACCESS_KEY_ID: "FOOBARKEY"
38-
AWS_SECRET_ACCESS_KEY: "FOOBARSECRET"
39-
run: |
40-
aws configure set aws_access_key_id $AWS_ACCESS_KEY_ID
41-
aws configure set aws_secret_access_key $AWS_SECRET_ACCESS_KEY
42-
43-
- name: Chmod .github directory
44-
run: |
45-
chmod +x $SCRIPT_FOLDER/*.sh
36+
- name: Cache global Poetry virtualenvs
4637

47-
- name: Set Poetry to use in-project venvs
48-
run: poetry config virtualenvs.in-project true
38+
# uses: actions/cache@v4
39+
# with:
40+
# path: ~/.cache/pypoetry/virtualenvs
41+
# key: ${{ runner.os }}-poetry-global-venv-py${{ matrix.python-version || 'all' }}-${{ hashFiles('**/poetry.lock') }}
42+
# restore-keys: |
43+
# ${{ runner.os }}-poetry-global-venv-py${{ matrix.python-version || 'all' }}-
4944

50-
- name: Cache Poetry virtualenv (filenameprocessor)
51-
if: matrix.python-version == '3.10'
5245
uses: actions/cache@v4
5346
with:
54-
path: ./filenameprocessor/.venv
55-
key: ${{ runner.os }}-venv-fp-py3.10-${{ hashFiles('filenameprocessor/poetry.lock') }}
47+
path: ~/.cache/pypoetry/virtualenvs
48+
key: ${{ runner.os }}-poetry-venv-${{ matrix.python-version }}-${{ hashFiles('<project>/poetry.lock') }}
5649
restore-keys: |
57-
${{ runner.os }}-venv-fp-py3.10-
50+
${{ runner.os }}-poetry-venv-${{ matrix.python-version }}-
5851
59-
- name: Cache Poetry virtualenv (recordprocessor)
60-
if: matrix.python-version == '3.10'
61-
uses: actions/cache@v4
62-
with:
63-
path: ./recordprocessor/.venv
64-
key: ${{ runner.os }}-venv-rp-py3.10-${{ hashFiles('recordprocessor/poetry.lock') }}
65-
restore-keys: |
66-
${{ runner.os }}-venv-rp-py3.10-
6752
68-
- name: Cache Poetry virtualenv (recordforwarder)
69-
if: matrix.python-version == '3.11'
70-
uses: actions/cache@v4
71-
with:
72-
path: ./backend/.venv
73-
key: ${{ runner.os }}-venv-be-py3.11-${{ hashFiles('backend/poetry.lock') }}
74-
restore-keys: |
75-
${{ runner.os }}-venv-be-py3.11-
76-
77-
- name: Cache Poetry virtualenv (ack_backend)
78-
if: matrix.python-version == '3.10'
79-
uses: actions/cache@v4
80-
with:
81-
path: ./ack_backend/.venv
82-
key: ${{ runner.os }}-venv-ack-py3.10-${{ hashFiles('ack_backend/poetry.lock') }}
83-
restore-keys: |
84-
${{ runner.os }}-venv-ack-py3.10-
8553
86-
- name: Cache Poetry virtualenv (delta_backend)
87-
if: matrix.python-version == '3.11'
88-
uses: actions/cache@v4
89-
with:
90-
path: ./delta_backend/.venv
91-
key: ${{ runner.os }}-venv-delta-py3.11-${{ hashFiles('delta_backend/poetry.lock') }}
92-
restore-keys: |
93-
${{ runner.os }}-venv-delta-py3.11-
94-
95-
- name: Run unittest with filenameprocessor-coverage (S)
96-
if: matrix.python-version == '3.10'
97-
working-directory: filenameprocessor
98-
id: filenameprocessor
99-
continue-on-error: true
100-
run: $RUN_TEST 3.10 filenameprocessor filenameprocessor-coverage.xml
101-
102-
- name: Run unittest with recordprocessor-coverage (s)
103-
if: matrix.python-version == '3.10'
104-
working-directory: recordprocessor
105-
id: recordprocessor
106-
continue-on-error: true
107-
run: $RUN_TEST 3.10 recordprocessor recordprocessor-coverage.xml
108-
109-
- name: Run unittest with recordforwarder-coverage
110-
if: matrix.python-version == '3.11'
111-
working-directory: backend
112-
id: recordforwarder
113-
continue-on-error: true
54+
- name: Set up AWS credentials
55+
env:
56+
AWS_ACCESS_KEY_ID: "FOOBARKEY"
57+
AWS_SECRET_ACCESS_KEY: "FOOBARSECRET"
11458
run: |
115-
poetry config virtualenvs.in-project true
116-
$RUN_TEST 3.11 recordforwarder recordforwarder-coverage.xml
59+
aws configure set aws_access_key_id $AWS_ACCESS_KEY_ID
60+
aws configure set aws_secret_access_key $AWS_SECRET_ACCESS_KEY
61+
62+
# - name: Run unittest with filenameprocessor-coverage
63+
# working-directory: filenameprocessor
64+
# id: filenameprocessor
65+
# continue-on-error: true
66+
# run: |
67+
# poetry env use 3.10
68+
# poetry install
69+
# poetry run coverage run -m unittest discover || echo "filenameprocessor tests failed" >> ../failed_tests.txt
70+
# poetry run coverage xml -o ../sonarcloud-coverage-filenameprocessor-coverage.xml
71+
72+
# - name: Run unittest with recordprocessor-coverage
73+
# working-directory: recordprocessor
74+
# id: recordprocessor
75+
# continue-on-error: true
76+
# run: |
77+
# poetry env use 3.10
78+
# poetry install
79+
# poetry run coverage run -m unittest discover || echo "recordprocessor tests failed" >> ../failed_tests.txt
80+
# poetry run coverage xml -o ../sonarcloud-coverage-recordprocessor-coverage.xml
81+
82+
# # This step is redundant - all of these tests will be run in the backend step below
83+
# - name: Run unittest with recordforwarder-coverage
84+
# working-directory: backend
85+
# id: recordforwarder
86+
# continue-on-error: true
87+
# run: |
88+
# poetry env use 3.11
89+
# poetry install
90+
# poetry run coverage run -m unittest discover -s "./tests" -p "*batch*.py" || echo "recordforwarder tests failed" >> ../failed_tests.txt
91+
# poetry run coverage xml -o ../sonarcloud-coverage-recordforwarder-coverage.xml
11792

11893
- name: Run unittest with coverage-ack-lambda
11994
if: matrix.python-version == '3.10'
12095
working-directory: ack_backend
12196
id: acklambda
12297
continue-on-error: true
123-
run: $RUN_TEST 3.10 ack-lambda ack-lambda.xml
98+
run: |
99+
$RUN_TEST 3.10 "ack-lambda" "ack-lambda.xml"
124100
125101
- name: Run unittest with coverage-delta
126102
if: matrix.python-version == '3.11'
@@ -129,7 +105,28 @@ jobs:
129105
env:
130106
PYTHONPATH: delta_backend/src:delta_backend/tests
131107
continue-on-error: true
132-
run: $RUN_TEST 3.11 delta_backend delta.xml
108+
run: |
109+
$RUN_TEST 3.11 delta_backend delta.xml
110+
111+
# - name: Run unittest with coverage-fhir-api
112+
# working-directory: backend
113+
# id: fhirapi
114+
# continue-on-error: true
115+
# run: |
116+
# poetry env use 3.11
117+
# poetry install
118+
# poetry run coverage run -m unittest discover || echo "fhir-api tests failed" >> ../failed_tests.txt
119+
# poetry run coverage xml -o ../sonarcloud-coverage.xml
120+
121+
# - name: Run unittest with coverage-mesh-processor
122+
# working-directory: mesh_processor
123+
# id: meshprocessor
124+
# continue-on-error: true
125+
# run: |
126+
# poetry env use 3.10
127+
# poetry install
128+
# poetry run coverage run -m unittest discover || echo "mesh_processor tests failed" >> ../failed_tests.txt
129+
# poetry run coverage xml -o ../sonarcloud-mesh_processor-coverage.xml
133130

134131
- name: Run Test Failure Summary
135132
id: check_failure
@@ -151,4 +148,4 @@ jobs:
151148
uses: SonarSource/sonarqube-scan-action@master
152149
env:
153150
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
154-
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
151+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: SonarCloud
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
types: [labeled, opened, synchronize, reopened, unlabeled]
9+
env:
10+
SCRIPT_FOLDER: ./.github/scripts
11+
RUN_TEST: source ../.github/scripts/run_test.sh
12+
13+
jobs:
14+
sonarcloud:
15+
name: SonarCloud
16+
runs-on: ubuntu-latest
17+
strategy:
18+
matrix:
19+
python-version: ['3.11']
20+
21+
steps:
22+
- uses: actions/checkout@v4
23+
with:
24+
fetch-depth: 0
25+
26+
- name: Install poetry
27+
run: pip install poetry==1.8.4
28+
29+
- uses: actions/setup-python@v5
30+
with:
31+
python-version: ${{ matrix.python-version }}
32+
cache: 'poetry'
33+
34+
- name: Set up AWS credentials
35+
env:
36+
AWS_ACCESS_KEY_ID: "FOOBARKEY"
37+
AWS_SECRET_ACCESS_KEY: "FOOBARSECRET"
38+
run: |
39+
aws configure set aws_access_key_id $AWS_ACCESS_KEY_ID
40+
aws configure set aws_secret_access_key $AWS_SECRET_ACCESS_KEY
41+
42+
- name: Chmod .github directory
43+
run: |
44+
chmod +x $SCRIPT_FOLDER/*.sh
45+
46+
- name: Cache global Poetry virtualenvs
47+
uses: actions/cache@v4
48+
with:
49+
path: ~/.cache/pypoetry/virtualenvs
50+
key: ${{ runner.os }}-poetry-global-venv-py${{ matrix.python-version }}-${{ hashFiles('**/poetry.lock') }}
51+
restore-keys: |
52+
${{ runner.os }}-poetry-global-venv-py${{ matrix.python-version }}-
53+
54+
- name: Run unittest with coverage-delta
55+
if: matrix.python-version == '3.11'
56+
working-directory: delta_backend
57+
id: delta
58+
env:
59+
PYTHONPATH: delta_backend/src:delta_backend/tests
60+
continue-on-error: true
61+
run: |
62+
$RUN_TEST 3.11 delta_backend delta.xml
63+
64+
- name: Run Test Failure Summary
65+
id: check_failure
66+
run: |
67+
if [ -s failed_tests.txt ]; then
68+
echo "The following tests failed:"
69+
cat failed_tests.txt
70+
71+
while IFS= read -r line; do
72+
echo "##[error]Test Failures: $line"
73+
done < failed_tests.txt
74+
75+
exit 1
76+
else
77+
echo "All tests passed."
78+
fi

0 commit comments

Comments
 (0)