Skip to content

Commit 2819041

Browse files
committed
1 Jun
1 parent dba9351 commit 2819041

3 files changed

Lines changed: 200 additions & 52 deletions

File tree

.github/scripts/run_test.sh

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,14 @@ PYTHON_VERSION="$1"
55
DESCRIPTION="$2"
66
COVERAGE_XML="sonarcloud-coverage-$3.xml"
77

8-
echo "Using Python $PYTHON_VERSION again"
8+
# show cwd
9+
echo "Current working directory: $(pwd)"
10+
# list contents of venv
11+
12+
ls -la .
13+
14+
15+
echo "Using Python Version $PYTHON_VERSION"
916
poetry config virtualenvs.in-project true
1017

1118
# Only create/use the env and install if .venv does not exist

.github/workflows/sonarcloud.yml

Lines changed: 32 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,17 @@ on:
88
types: [labeled, opened, synchronize, reopened, unlabeled]
99
env:
1010
SCRIPT_FOLDER: ./.github/scripts
11-
TEST_SCRIPT: source ../.github/scripts/run_test.sh
11+
RUN_TEST: source ../.github/scripts/run_test.sh
1212

1313
jobs:
1414
sonarcloud:
1515
name: SonarCloud
1616
runs-on: ubuntu-latest
17+
strategy:
18+
matrix:
19+
python-version: ['3.10', '3.11']
1720

21+
1822
steps:
1923
- uses: actions/checkout@v4
2024
with:
@@ -25,9 +29,7 @@ jobs:
2529

2630
- uses: actions/setup-python@v5
2731
with:
28-
python-version: |
29-
3.10
30-
3.11
32+
python-version: ${{ matrix.python-version }}
3133
cache: 'poetry'
3234

3335
- name: Set up AWS credentials
@@ -46,109 +48,88 @@ jobs:
4648
run: poetry config virtualenvs.in-project true
4749

4850
- name: Cache Poetry virtualenv (filenameprocessor)
51+
if: matrix.python-version == '3.10'
4952
uses: actions/cache@v4
5053
with:
5154
path: ./filenameprocessor/.venv
52-
key: ${{ runner.os }}-venv-filenameprocessor-${{ hashFiles('filenameprocessor/poetry.lock') }}
55+
key: ${{ runner.os }}-venv-fp-py3.10-${{ hashFiles('filenameprocessor/poetry.lock') }}
5356
restore-keys: |
54-
${{ runner.os }}-venv-filenameprocessor-
57+
${{ runner.os }}-venv-fp-py3.10-
5558
5659
- name: Cache Poetry virtualenv (recordprocessor)
60+
if: matrix.python-version == '3.10'
5761
uses: actions/cache@v4
5862
with:
5963
path: ./recordprocessor/.venv
60-
key: ${{ runner.os }}-venv-recordprocessor-${{ hashFiles('recordprocessor/poetry.lock') }}
64+
key: ${{ runner.os }}-venv-rp-py3.10-${{ hashFiles('recordprocessor/poetry.lock') }}
6165
restore-keys: |
62-
${{ runner.os }}-venv-recordprocessor-
66+
${{ runner.os }}-venv-rp-py3.10-
6367
6468
- name: Cache Poetry virtualenv (recordforwarder)
69+
if: matrix.python-version == '3.11'
6570
uses: actions/cache@v4
6671
with:
6772
path: ./backend/.venv
68-
key: ${{ runner.os }}-venv-backend-${{ hashFiles('backend/poetry.lock') }}
73+
key: ${{ runner.os }}-venv-be-py3.11-${{ hashFiles('backend/poetry.lock') }}
6974
restore-keys: |
70-
${{ runner.os }}-venv-backend-
75+
${{ runner.os }}-venv-be-py3.11-
7176
7277
- name: Cache Poetry virtualenv (ack_backend)
78+
if: matrix.python-version == '3.10'
7379
uses: actions/cache@v4
7480
with:
7581
path: ./ack_backend/.venv
76-
key: ${{ runner.os }}-venv-ack_backend-${{ hashFiles('ack_backend/poetry.lock') }}
82+
key: ${{ runner.os }}-venv-ack-py3.10-${{ hashFiles('ack_backend/poetry.lock') }}
7783
restore-keys: |
78-
${{ runner.os }}-venv-ack_backend-
84+
${{ runner.os }}-venv-ack-py3.10-
7985
8086
- name: Cache Poetry virtualenv (delta_backend)
87+
if: matrix.python-version == '3.11'
8188
uses: actions/cache@v4
8289
with:
8390
path: ./delta_backend/.venv
84-
key: ${{ runner.os }}-venv-delta_backend-${{ hashFiles('delta_backend/poetry.lock') }}
91+
key: ${{ runner.os }}-venv-delta-py3.11-${{ hashFiles('delta_backend/poetry.lock') }}
8592
restore-keys: |
86-
${{ runner.os }}-venv-delta_backend-
93+
${{ runner.os }}-venv-delta-py3.11-
8794
8895
- name: Run unittest with filenameprocessor-coverage (S)
96+
if: matrix.python-version == '3.10'
8997
working-directory: filenameprocessor
9098
id: filenameprocessor
9199
continue-on-error: true
92-
run: |
93-
$TEST_SCRIPT 3.10 \
94-
"filenameprocessor" \
95-
"filenameprocessor-coverage.xml"
100+
run: $RUN_TEST 3.10 filenameprocessor filenameprocessor-coverage.xml
96101

97102
- name: Run unittest with recordprocessor-coverage (s)
103+
if: matrix.python-version == '3.10'
98104
working-directory: recordprocessor
99105
id: recordprocessor
100106
continue-on-error: true
101-
run: |
102-
$TEST_SCRIPT 3.10 \
103-
"recordprocessor" \
104-
"recordprocessor-coverage.xml"
107+
run: $RUN_TEST 3.10 recordprocessor recordprocessor-coverage.xml
105108

106109
- name: Run unittest with recordforwarder-coverage
110+
if: matrix.python-version == '3.11'
107111
working-directory: backend
108112
id: recordforwarder
109113
continue-on-error: true
110114
run: |
111-
$TEST_SCRIPT 3.11 \
112-
"recordforwarder" \
113-
"recordforwarder-coverage.xml"
115+
poetry config virtualenvs.in-project true
116+
$RUN_TEST 3.11 recordforwarder recordforwarder-coverage.xml
114117
115118
- name: Run unittest with coverage-ack-lambda
119+
if: matrix.python-version == '3.10'
116120
working-directory: ack_backend
117121
id: acklambda
118122
continue-on-error: true
119-
run: |
120-
$TEST_SCRIPT 3.10 \
121-
"ack-lambda" \
122-
"ack-lambda.xml"
123+
run: $RUN_TEST 3.10 ack-lambda ack-lambda.xml
123124

124125
- name: Run unittest with coverage-delta
126+
if: matrix.python-version == '3.11'
125127
working-directory: delta_backend
126128
id: delta
127129
env:
128130
PYTHONPATH: delta_backend/src:delta_backend/tests
129131
continue-on-error: true
130-
run: |
131-
$TEST_SCRIPT 3.11 \
132-
"delta_backend" \
133-
"delta.xml"
134-
135-
# - name: Run unittest with coverage-fhir-api
136-
# working-directory: backend
137-
# id: fhirapi
138-
# continue-on-error: true
139-
# run: |
140-
# $TEST_SCRIPT 3.11 \
141-
# "fhir-api" \
142-
# "fhir-api.xml"
143-
144-
# - name: Run unittest with coverage-mesh-processor
145-
# working-directory: mesh_processor
146-
# id: meshprocessor
147-
# continue-on-error: true
148-
# run: |
149-
# $TEST_SCRIPT 3.10 \
150-
# "mesh_processor" \
151-
# "mesh_processor-coverage.xml"
132+
run: $RUN_TEST 3.11 delta_backend delta.xml
152133

153134
- name: Run Test Failure Summary
154135
id: check_failure
Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
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+
TEST_SCRIPT: source ../.github/scripts/run_test.sh
12+
13+
jobs:
14+
sonarcloud:
15+
name: SonarCloud
16+
runs-on: ubuntu-latest
17+
strategy:
18+
matrix:
19+
include:
20+
- project: filenameprocessor
21+
python-version: "3.10"
22+
- project: recordprocessor
23+
python-version: "3.10"
24+
- project: backend
25+
python-version: "3.11"
26+
test-name: recordforwarder
27+
coverage-file: recordforwarder-coverage.xml
28+
- project: ack_backend
29+
python-version: "3.10"
30+
test-name: ack-lambda
31+
coverage-file: ack-lambda.xml
32+
- project: delta_backend
33+
python-version: "3.11"
34+
test-name: delta_backend
35+
coverage-file: delta.xml
36+
# Add more projects as needed
37+
38+
steps:
39+
- uses: actions/checkout@v4
40+
with:
41+
fetch-depth: 0
42+
43+
- name: Install poetry
44+
run: pip install poetry==1.8.4
45+
46+
- uses: actions/setup-python@v5
47+
with:
48+
python-version: ${{ matrix.python-version }}
49+
cache: 'poetry'
50+
51+
52+
- name: Set up AWS credentials
53+
env:
54+
AWS_ACCESS_KEY_ID: "FOOBARKEY"
55+
AWS_SECRET_ACCESS_KEY: "FOOBARSECRET"
56+
run: |
57+
aws configure set aws_access_key_id $AWS_ACCESS_KEY_ID
58+
aws configure set aws_secret_access_key $AWS_SECRET_ACCESS_KEY
59+
60+
- name: Chmod .github directory
61+
run: |
62+
chmod +x $SCRIPT_FOLDER/*.sh
63+
64+
- name: Set Poetry to use in-project venvs
65+
run: poetry config virtualenvs.in-project true
66+
67+
- name: Cache Poetry virtualenv
68+
uses: actions/cache@v4
69+
with:
70+
path: ./${{ matrix.project }}/.venv
71+
key: ${{ runner.os }}-venv-${{ matrix.project }}-py${{ matrix.python-version }}-${{ hashFiles(format('{0}/poetry.lock', matrix.project)) }}
72+
restore-keys: |
73+
${{ runner.os }}-venv-${{ matrix.project }}-py${{ matrix.python-version }}-
74+
75+
- name: Run unittest with filenameprocessor-coverage (S)
76+
working-directory: filenameprocessor
77+
id: filenameprocessor
78+
continue-on-error: true
79+
run: |
80+
$TEST_SCRIPT 3.10 \
81+
"filenameprocessor" \
82+
"filenameprocessor-coverage.xml"
83+
84+
- name: Run unittest with recordprocessor-coverage (s)
85+
working-directory: recordprocessor
86+
id: recordprocessor
87+
continue-on-error: true
88+
run: |
89+
$TEST_SCRIPT 3.10 \
90+
"recordprocessor" \
91+
"recordprocessor-coverage.xml"
92+
93+
- name: Run unittest with recordforwarder-coverage
94+
working-directory: backend
95+
id: recordforwarder
96+
continue-on-error: true
97+
run: |
98+
$TEST_SCRIPT 3.11 \
99+
"recordforwarder" \
100+
"recordforwarder-coverage.xml"
101+
102+
- name: Run unittest with coverage-ack-lambda
103+
working-directory: ack_backend
104+
id: acklambda
105+
continue-on-error: true
106+
run: |
107+
$TEST_SCRIPT 3.10 \
108+
"ack-lambda" \
109+
"ack-lambda.xml"
110+
111+
- name: Run unittest with coverage-delta
112+
working-directory: delta_backend
113+
id: delta
114+
env:
115+
PYTHONPATH: delta_backend/src:delta_backend/tests
116+
continue-on-error: true
117+
run: |
118+
$TEST_SCRIPT 3.11 \
119+
"delta_backend" \
120+
"delta.xml"
121+
122+
# - name: Run unittest with coverage-fhir-api
123+
# working-directory: backend
124+
# id: fhirapi
125+
# continue-on-error: true
126+
# run: |
127+
# $TEST_SCRIPT 3.11 \
128+
# "fhir-api" \
129+
# "fhir-api.xml"
130+
131+
# - name: Run unittest with coverage-mesh-processor
132+
# working-directory: mesh_processor
133+
# id: meshprocessor
134+
# continue-on-error: true
135+
# run: |
136+
# $TEST_SCRIPT 3.10 \
137+
# "mesh_processor" \
138+
# "mesh_processor-coverage.xml"
139+
140+
- name: Run Test Failure Summary
141+
id: check_failure
142+
run: |
143+
if [ -s failed_tests.txt ]; then
144+
echo "The following tests failed:"
145+
cat failed_tests.txt
146+
147+
while IFS= read -r line; do
148+
echo "##[error]Test Failures: $line"
149+
done < failed_tests.txt
150+
151+
exit 1
152+
else
153+
echo "All tests passed."
154+
fi
155+
156+
- name: SonarCloud Scan
157+
uses: SonarSource/sonarqube-scan-action@master
158+
env:
159+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
160+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

0 commit comments

Comments
 (0)