Skip to content

Commit

Permalink
run coverage in better way
Browse files Browse the repository at this point in the history
  • Loading branch information
Czaki committed Dec 18, 2023
1 parent 33f108a commit bd8a9c5
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 23 deletions.
23 changes: 5 additions & 18 deletions .github/workflows/base_test_workflow.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
name: Base Test Workflow

on:
workflow_call:
inputs:
Expand Down Expand Up @@ -97,25 +99,10 @@ jobs:
./report-*.json
retention-days: 7

- name: Upload coverage report ${{ inputs.tox_args }}
- name: Upload coverage data
uses: actions/upload-artifact@v3
if: ${{ inputs.coverage }}
with:
name: coverage_report ${{ inputs.tox_args }}
name: coverage reports
path: |
./htmlcov
retention-days: 7

- name: Upload coverage raw data
uses: actions/upload-artifact@v3
with:
name: coverage_raw ${{ inputs.tox_args }}
path: ./coverage.xml
retention-days: 7

- uses: codecov/codecov-action@v3
if: ${{ inputs.coverage }}
with:
file: ./coverage.xml
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}
./.coverage.*
43 changes: 43 additions & 0 deletions .github/workflows/reusable_coverage_upload.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Coverage Upload

on:
workflow_call:


jobs:
upload_coverage:
name: Upload coverage
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: "3.x"
cache-dependency-path: setup.cfg
cache: 'pip'

- name: Install Dependencies
run: |
pip install --upgrade pip
pip install codecov
- name: Download coverage data
uses: actions/download-artifact@v3
with:
name: coverage reports
path: coverage

- name: combine coverage data
run: |
python -Im coverage combine coverage
python -Im coverage xml -o coverage.xml
# Report and write to summary.
python -Im coverage report --format=markdown --skip-empty --skip-covered >> $GITHUB_STEP_SUMMARY
- name: Upload coverage data
uses: codecov/codecov-action@v3
with:
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}
5 changes: 5 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@ jobs:
tox_args: "-e py38-PyQt5-minimal"
coverage: true

coverage_upload:
name: Upload coverage
needs: [test_coverage, test_minimal]
uses: ./.github/workflows/reusable_coverage_upload.yml

test_conda:
name: Test PartSeg conda
runs-on: ubuntu-20.04
Expand Down
8 changes: 5 additions & 3 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ package_dir =
=package
tests_require =
pytest
pytest-cov
pytest-qt
lxml

Expand Down Expand Up @@ -120,9 +119,9 @@ pyside2 =
pyside6 =
PySide6
test =
coverage
lxml
pytest>=7.0.0
pytest-cov
pytest-qt
pytest-timeout
scikit-image
Expand Down Expand Up @@ -166,7 +165,10 @@ source =
PartSeg
PartSegCore
PartSegImage
omit = .tox/*
omit =
.tox/*
package/PartSeg/changelog.py
package/ParsSeg/version.py
parallel = True

[coverage:report]
Expand Down
4 changes: 2 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,11 @@ commands =
!repo: python -m pytest -v package/tests/test_PartSeg/test_napari_widgets.py --no-cov --json-report --json-report-file={toxinidir}/report-{envname}-{sys_platform}.json
repo: python -m pytest --no-cov --json-report --json-report-file={toxinidir}/report-{envname}-{sys_platform}.json

[testenv:py{38,39,310,311s}-PyQt5-coverage]
[testenv:py{38,39,310,311}-PyQt5-coverage]
deps =
{[testenv]deps}
commands =
python -m pytest --cov-report=xml --cov-report html --cov-append --cov {envsitepackagesdir}/PartSeg --cov {envsitepackagesdir}/PartSegCore --cov {envsitepackagesdir}/PartSegImage --cov package/tests --json-report --json-report-file={toxinidir}/report-{envname}-{sys_platform}.json
coverage run -m pytest --json-report --json-report-file={toxinidir}/report-{envname}-{sys_platform}.json

[testenv:py38-PyQt5-minimal]
min_req = 1
Expand Down

0 comments on commit bd8a9c5

Please sign in to comment.