Skip to content

Commit 23e1541

Browse files
committedJul 18, 2024
feat: add test coverage
1 parent d3b532c commit 23e1541

File tree

3 files changed

+35
-5
lines changed

3 files changed

+35
-5
lines changed
 

‎.github/workflows/test.yml

+29-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,35 @@ jobs:
1414
python-version: ${{ matrix.python-version }}
1515
- name: Install dependencies
1616
run: |
17-
python -m pip install --upgrade pip pytest
17+
python -m pip install --upgrade pip pytest pytest-cov
1818
pip install .
1919
- name: Test with pytest
2020
run: |
21-
pytest tests
21+
pytest --junitxml=pytest.xml --cov-report=term-missing:skip-covered --cov=git_hg_sync tests/ | tee pytest-coverage.txt
22+
- name: Pytest coverage comment
23+
uses: MishaKav/pytest-coverage-comment@main
24+
with:
25+
pytest-coverage-path: ./pytest-coverage.txt
26+
junitxml-path: ./pytest.xml
27+
- name: Check the output coverage
28+
run: |
29+
echo "Coverage Percentage - ${{ steps.coverageComment.outputs.coverage }}"
30+
echo "Coverage Color - ${{ steps.coverageComment.outputs.color }}"
31+
echo "Coverage Html - ${{ steps.coverageComment.outputs.coverageHtml }}"
32+
echo "Coverage Warnings - ${{ steps.coverageComment.outputs.warnings }}"
33+
echo "Coverage Errors - ${{ steps.coverageComment.outputs.errors }}"
34+
echo "Coverage Failures - ${{ steps.coverageComment.outputs.failures }}"
35+
echo "Coverage Skipped - ${{ steps.coverageComment.outputs.skipped }}"
36+
echo "Coverage Tests - ${{ steps.coverageComment.outputs.tests }}"
37+
echo "Coverage Time - ${{ steps.coverageComment.outputs.time }}"
38+
echo "Not Success Test Info - ${{ steps.coverageComment.outputs.notSuccessTestInfo }}"
39+
- name: Create the Badge
40+
uses: schneegans/dynamic-badges-action@v1.7.0
41+
with:
42+
auth: ${{ secrets.PYTEST_COVERAGE_COMMENT }}
43+
gistID: 5e90d640f8c212ab7bbac38f72323f80
44+
filename: pytest-coverage-comment__main.json
45+
label: Coverage Report
46+
message: ${{ steps.coverageComment.outputs.coverage }}
47+
color: ${{ steps.coverageComment.outputs.color }}
48+
namedLogo: python

‎.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
clones
22
.tox
33
**/__pycache__/
4-
config.ini
4+
config.ini
5+
.coverage

‎tox.ini

+4-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@ setenv = PYTHONPATH = ""
88
[testenv:pytest]
99
changedir = tests
1010
passenv = PULSE_PASSWORD
11-
deps = pytest
12-
commands = pytest
11+
deps =
12+
pytest
13+
pytest-cov
14+
commands = pytest --cov=git_hg_sync --cov-report=html
1315

1416
[testenv:lint]
1517
description = lint source code

0 commit comments

Comments
 (0)
Failed to load comments.