Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,18 @@ jobs:
python_package_manager: "uv pip"
- name: Run Tests
run: hatch run cov:test
- uses: jupyterlab/maintainer-tools/.github/actions/upload-coverage@v1

coverage:
runs-on: ubuntu-latest
needs:
- tests
steps:
- uses: actions/checkout@v7
- uses: jupyterlab/maintainer-tools/.github/actions/report-coverage@v1
# Codecov merges the uploads of every matrix job into one report for
# the commit, so each job uploads its own and nothing combines them here.
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
with:
files: coverage.xml
disable_search: true
flags: ${{ matrix.os }}-${{ matrix.python-version }}
# Empty on pull requests from forks, where Codecov falls back to a
# tokenless upload. Flip fail_ci_if_error on once the secret is set.
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: false

test_minimum_versions:
name: Test Minimum Versions
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ __pycache__
\#*#
.#*
.coverage
coverage.xml
.cache
htmlcov
docs/source/CHANGELOG.md
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Traitlets

[![Tests](https://github.com/ipython/traitlets/actions/workflows/tests.yml/badge.svg)](https://github.com/ipython/traitlets/actions/workflows/tests.yml)
[![Coverage](https://codecov.io/gh/ipython/traitlets/branch/main/graph/badge.svg)](https://codecov.io/gh/ipython/traitlets)
[![Documentation Status](https://readthedocs.org/projects/traitlets/badge/?version=latest)](https://traitlets.readthedocs.io/en/latest/?badge=latest)
[![Tidelift](https://tidelift.com/subscription/pkg/pypi-traitlets)](https://tidelift.com/badges/package/pypi/traitlets)

Expand Down
45 changes: 45 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# https://docs.codecov.com/docs/codecov-yaml
codecov:
# Every job of the test matrix uploads its own report. Waiting for CI to
# finish keeps the comment and the statuses off a partial set of uploads,
# without pinning a build count that the matrix would drift away from.
require_ci_to_pass: true

coverage:
precision: 2
round: down
range: "70...90"
status:
project:
default:
target: auto
# Don't fail a pull request over the rounding noise of a refactor
# that only moves code around.
threshold: 0.5%
patch:
default:
target: 80%
threshold: 5%

# The test suite is measured alongside the library, so the overall number
# blends the two. These components report on each separately: `traitlets` is
# the one to watch, while `tests` mostly surfaces test code that never runs.
component_management:
default_rules:
statuses:
- type: project
target: auto
threshold: 0.5%
individual_components:
- component_id: library
name: traitlets
paths:
- traitlets/**
- component_id: tests
name: tests
paths:
- tests/**

comment:
layout: "condensed_header, components, condensed_files, condensed_footer"
require_changes: true
19 changes: 17 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ nowarn = "test -W default {args}"
features = ["test"]
dependencies = ["coverage[toml]", "pytest-cov"]
[tool.hatch.envs.cov.scripts]
test = "python -m pytest -vv --cov traitlets --cov-branch --cov-report term-missing:skip-covered {args}"
test = "python -m pytest -vv --cov --cov-report term-missing:skip-covered --cov-report xml {args}"
nowarn = "test -W default {args}"

[tool.hatch.envs.typing]
Expand Down Expand Up @@ -174,8 +174,23 @@ exclude_lines = [
]

[tool.coverage.run]
branch = true
# Keeps the paths in coverage.xml relative to the repository root, so that the
# uploads from every matrix job line up with each other on Codecov.
relative_files = true
source = ["traitlets"]
# The test suite is measured too, so that Codecov's `tests` component can
# report on it: a test file with uncovered lines is a test that never runs.
# Measuring from the repository root rather than listing the two directories
# keeps the paths in coverage.xml distinct -- with `source = ["traitlets",
# "tests"]` both config/__init__.py files are written out under the same name.
source = ["."]
omit = [
"docs/*",
"examples/*",
# mypy type-checks this file, pytest-mypy-testing never executes its bodies,
# so every line in it reads as uncovered. It is a fixture, not dead code.
"tests/test_typing.py",
]

[tool.repo-review]
# traitlets publishes `traitlets[test]` / `traitlets[docs]` as documented
Expand Down
Loading
Loading