Skip to content

Commit ab4e6c3

Browse files
committed
min test
1 parent 7e4d8d1 commit ab4e6c3

3 files changed

Lines changed: 205 additions & 57 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/workflows/sonarcloud.yml

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ jobs:
1818
matrix:
1919
python-version: ['3.10', '3.11']
2020

21-
2221
steps:
2322
- uses: actions/checkout@v4
2423
with:
@@ -56,33 +55,6 @@ jobs:
5655
restore-keys: |
5756
${{ runner.os }}-venv-fp-py3.10-
5857
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-
67-
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-
85-
8658
- name: Cache Poetry virtualenv (delta_backend)
8759
if: matrix.python-version == '3.11'
8860
uses: actions/cache@v4
@@ -99,29 +71,6 @@ jobs:
9971
continue-on-error: true
10072
run: $RUN_TEST 3.10 filenameprocessor filenameprocessor-coverage.xml
10173

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
114-
run: |
115-
poetry config virtualenvs.in-project true
116-
$RUN_TEST 3.11 recordforwarder recordforwarder-coverage.xml
117-
118-
- name: Run unittest with coverage-ack-lambda
119-
if: matrix.python-version == '3.10'
120-
working-directory: ack_backend
121-
id: acklambda
122-
continue-on-error: true
123-
run: $RUN_TEST 3.10 ack-lambda ack-lambda.xml
124-
12574
- name: Run unittest with coverage-delta
12675
if: matrix.python-version == '3.11'
12776
working-directory: delta_backend
@@ -148,9 +97,3 @@ jobs:
14897
else
14998
echo "All tests passed."
15099
fi
151-
152-
- name: SonarCloud Scan
153-
uses: SonarSource/sonarqube-scan-action@master
154-
env:
155-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
156-
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
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.10', '3.11']
20+
21+
22+
steps:
23+
- uses: actions/checkout@v4
24+
with:
25+
fetch-depth: 0
26+
27+
- name: Install poetry
28+
run: pip install poetry==1.8.4
29+
30+
- uses: actions/setup-python@v5
31+
with:
32+
python-version: ${{ matrix.python-version }}
33+
cache: 'poetry'
34+
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
46+
47+
- name: Set Poetry to use in-project venvs
48+
run: poetry config virtualenvs.in-project true
49+
50+
- name: Cache Poetry virtualenv (filenameprocessor)
51+
if: matrix.python-version == '3.10'
52+
uses: actions/cache@v4
53+
with:
54+
path: ./filenameprocessor/.venv
55+
key: ${{ runner.os }}-venv-fp-py3.10-${{ hashFiles('filenameprocessor/poetry.lock') }}
56+
restore-keys: |
57+
${{ runner.os }}-venv-fp-py3.10-
58+
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-
67+
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-
85+
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
114+
run: |
115+
poetry config virtualenvs.in-project true
116+
$RUN_TEST 3.11 recordforwarder recordforwarder-coverage.xml
117+
118+
- name: Run unittest with coverage-ack-lambda
119+
if: matrix.python-version == '3.10'
120+
working-directory: ack_backend
121+
id: acklambda
122+
continue-on-error: true
123+
run: $RUN_TEST 3.10 ack-lambda ack-lambda.xml
124+
125+
- name: Run unittest with coverage-delta
126+
if: matrix.python-version == '3.11'
127+
working-directory: delta_backend
128+
id: delta
129+
env:
130+
PYTHONPATH: delta_backend/src:delta_backend/tests
131+
continue-on-error: true
132+
run: |
133+
poetry config virtualenvs.in-project true
134+
$RUN_TEST 3.11 delta_backend delta.xml
135+
136+
- name: Run Test Failure Summary
137+
id: check_failure
138+
run: |
139+
if [ -s failed_tests.txt ]; then
140+
echo "The following tests failed:"
141+
cat failed_tests.txt
142+
143+
while IFS= read -r line; do
144+
echo "##[error]Test Failures: $line"
145+
done < failed_tests.txt
146+
147+
exit 1
148+
else
149+
echo "All tests passed."
150+
fi
151+
152+
- name: SonarCloud Scan
153+
uses: SonarSource/sonarqube-scan-action@master
154+
env:
155+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
156+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

0 commit comments

Comments
 (0)