Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Coverage cleanups #1674

Merged
merged 9 commits into from
Nov 14, 2022
95 changes: 17 additions & 78 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install tox coverage[toml]
# See https://github.com/nedbat/coveragepy/issues/991
python -m pip install tox coverage[toml]~=6.6.0b1
- name: Get packages
uses: actions/download-artifact@v3
with:
Expand All @@ -93,26 +94,21 @@ jobs:
env:
TOGA_INSTALL_COMMAND: 'bash -c "pip install ../{core,dummy}/dist/*.whl"'
run: |
tox -e py-core
cd core
tox -e py
mv .coverage.* ..
python -m coverage xml
mv .coverage .coverage.${{ matrix.platform }}.${{ matrix.python-version }}
- name: Store coverage data
uses: actions/upload-artifact@v3
with:
name: core-coverage-data
path: ".coverage.*"
if-no-files-found: ignore
- name: Report platform coverage
run: |
python -m coverage combine
python -m coverage report
# Generate XML report for CodeCov
python -m coverage xml
path: "core/.coverage.*"
if-no-files-found: error
- name: Upload coverage data to CodeCov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.xml
file: core/coverage.xml
flags: unittests
fail_ci_if_error: true

Expand All @@ -130,29 +126,24 @@ jobs:
python-version: ${{ env.max_python_version }}
- name: Install dependencies
run: |
python -m pip install coverage[toml]
# See https://github.com/nedbat/coveragepy/issues/991
python -m pip install coverage[toml]~=6.6.0b1
- name: Retrieve coverage data
uses: actions/download-artifact@v3
with:
name: core-coverage-data
- name: Normalize paths in coverage data
run: |
# See https://github.com/nedbat/coveragepy/issues/991
for coverage in `ls .coverage.*`; do
sqlite3 $coverage "update file set path = replace(path, '\\', '/')"
done
- name: Combine coverage
run: |
python -m coverage combine
path: core
- name: Generate coverage report
run: |
cd core
python -m coverage combine
python -m coverage html --skip-covered --skip-empty
python -m coverage report # --fail-under=100
python -m coverage report --rcfile ../pyproject.toml # --fail-under=100
- name: Upload HTML report if check failed.
uses: actions/upload-artifact@v3
with:
name: html-coverage-report
path: htmlcov
path: core/htmlcov
if: ${{ failure() }}

backend:
Expand Down Expand Up @@ -193,61 +184,9 @@ jobs:
- name: Install dependencies
run: |
${{ matrix.pre-command }}
python -m pip install tox coverage[toml]
python -m pip install tox
- name: Test
env:
TOGA_INSTALL_COMMAND: 'bash -c "pip install ../{core,dummy,${{ matrix.backend }}}/dist/*.whl"'
run: |
cd ${{ matrix.backend }}
tox -e py
mv .coverage.* ..
- name: Store coverage data
uses: actions/upload-artifact@v3
with:
name: backend-coverage-data
path: ".coverage.*"
if-no-files-found: ignore
- name: Report platform coverage
run: |
python -m coverage combine
python -m coverage report

backend-coverage:
name: Combine & check backend coverage.
runs-on: ubuntu-latest
needs:
- backend
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-python@v4.3.0
with:
# Use latest, so it understands all syntax.
python-version: ${{ env.max_python_version }}
- name: Install dependencies
run: |
python -m pip install coverage[toml]
- name: Retrieve coverage data
uses: actions/download-artifact@v3
with:
name: backend-coverage-data
- name: Normalize paths in coverage data
run: |
# See https://github.com/nedbat/coveragepy/issues/991
for coverage in `ls .coverage.*`; do
sqlite3 $coverage "update file set path = replace(path, '\\', '/')"
done
- name: Combine coverage
run: |
python -m coverage combine
- name: Generate coverage report
run: |
python -m coverage html --skip-covered --skip-empty
python -m coverage report # --fail-under=100
- name: Upload HTML report if check failed.
uses: actions/upload-artifact@v3
with:
name: html-coverage-report
path: htmlcov
if: ${{ failure() }}
tox -e py-${{ matrix.backend }}
18 changes: 5 additions & 13 deletions android/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,13 @@ build-backend = "setuptools.build_meta"
parallel = true
branch = true
relative_files = true

# See notes in the root pyproject.toml file.
source = ["src"]
source_pkgs = ["toga_android"]

[tool.coverage.paths]
source = [
"src",
"**/site-packages"
]

[tool.coverage.report]
show_missing = true
skip_covered = true
skip_empty = true
precision = 1
exclude_lines = [
"pragma: no cover",
"@(abc\\.)?abstractmethod",
"NotImplementedError\\(\\)"
"src/toga_android",
"**/toga_android",
]
22 changes: 0 additions & 22 deletions android/tox.ini

This file was deleted.

1 change: 1 addition & 0 deletions changes/1673.misc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Corrected coverage path mapping.
18 changes: 5 additions & 13 deletions cocoa/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,13 @@ build-backend = "setuptools.build_meta"
parallel = true
branch = true
relative_files = true

# See notes in the root pyproject.toml file.
source = ["src"]
source_pkgs = ["toga_cocoa"]

[tool.coverage.paths]
source = [
"src",
"**/site-packages"
]

[tool.coverage.report]
show_missing = true
skip_covered = true
skip_empty = true
precision = 1
exclude_lines = [
"pragma: no cover",
"@(abc\\.)?abstractmethod",
"NotImplementedError\\(\\)"
"src/toga_cocoa",
"**/toga_cocoa",
]
22 changes: 0 additions & 22 deletions cocoa/tox.ini

This file was deleted.

20 changes: 6 additions & 14 deletions core/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,13 @@ build-backend = "setuptools.build_meta"
parallel = true
branch = true
relative_files = true
source_pkgs = ["toga", "toga_dummy"]

# See notes in the root pyproject.toml file.
source = ["src"]
source_pkgs = ["toga"]

[tool.coverage.paths]
source = [
"src",
"**/site-packages"
]

[tool.coverage.report]
show_missing = true
skip_covered = true
skip_empty = true
precision = 1
exclude_lines = [
"pragma: no cover",
"@(abc\\.)?abstractmethod",
"NotImplementedError\\(\\)"
"src/toga",
"**/toga",
]
22 changes: 0 additions & 22 deletions core/tox.ini

This file was deleted.

Loading