Skip to content

Commit 57a7076

Browse files
committed
added python and c++ test and combined into single report
1 parent 321f6f4 commit 57a7076

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed

.github/workflows/ci.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,3 +200,64 @@ jobs:
200200
- name: Build Documentation
201201
run: |
202202
sphinx-build -b html docs/source/ docs/build/html
203+
204+
test-python-c++-unified-report:
205+
runs-on: ubuntu-latest
206+
timeout-minutes: 20
207+
steps:
208+
# Step 1: Checkout Repository
209+
- name: Checkout Repository
210+
uses: actions/checkout@v4
211+
212+
# Step 2: Set up Python
213+
- name: Set up Python
214+
uses: actions/setup-python@v5
215+
with:
216+
python-version: "3.11"
217+
218+
# Step 3: Install Python Dependencies
219+
- name: Install Python Dependencies
220+
run: |
221+
python -m pip install --upgrade pip
222+
python -m pip install pytest pytest-cov cobertura-merge
223+
224+
# Step 4: Run Python Tests and Generate Coverage
225+
- name: Run Python Tests
226+
run: |
227+
pytest tests/ --cov=src --cov-report xml:coverage-python.xml --cov-report html:coverage-html
228+
229+
# Step 5: Install C++ Dependencies
230+
- name: Install C++ Dependencies
231+
run: |
232+
sudo apt-get update
233+
sudo apt-get install -y g++ gcov lcov
234+
235+
# Step 6: Compile and Run C++ Tests
236+
- name: Compile and Run C++ Tests
237+
run: |
238+
g++ -o tests/test_cpp tests/test.cpp
239+
./tests/test_cpp
240+
lcov --capture --directory . --output-file coverage-cpp.info
241+
242+
# Step 7: Convert C++ Coverage to XML (Using `gcovr`)
243+
- name: Convert C++ Coverage to XML
244+
run: |
245+
python -m pip install gcovr
246+
gcovr -r . --xml-pretty --output coverage-cpp.xml
247+
248+
# Step 8: Combine Coverage Reports
249+
- name: Combine Coverage Reports
250+
run: |
251+
python -m cobertura_merge coverage-python.xml coverage-cpp.xml -o unified-reports/combined-coverage.xml
252+
253+
# Step 9: Generate HTML Report from Combined Coverage
254+
- name: Generate HTML Report
255+
run: |
256+
python -m pip install coverage html-report
257+
coverage html -i --data unified-reports/combined-coverage.xml --directory unified-reports/html
258+
259+
# Step 10: Upload Combined Coverage to Codecov
260+
- name: Upload Combined Coverage to Codecov
261+
run: bash <(curl -s https://codecov.io/bash) -f unified-reports/combined-coverage.xml
262+
env:
263+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

0 commit comments

Comments
 (0)