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
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ jobs:
- name: Check formatting
run: uv run ruff format --check .

- name: Run tests
run: uv run pytest
- name: Run tests with coverage
run: uv run pytest --cov=text_toolkit --cov-report=term-missing

- name: Run type checking
run: uv run mypy
Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ Before opening a pull request with code changes, run the local quality checks:
```bash
uv run ruff check .
uv run ruff format --check .
uv run pytest
uv run pytest --cov=text_toolkit --cov-report=term-missing
uv run mypy
uv build --no-sources
```
Expand All @@ -205,7 +205,7 @@ Then repeat the checks:
```bash
uv run ruff check .
uv run ruff format --check .
uv run pytest
uv run pytest --cov=text_toolkit --cov-report=term-missing
uv run mypy
uv build --no-sources
```
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ Run the same quality checks used by CI:
```bash
uv run ruff check .
uv run ruff format --check .
uv run pytest
uv run pytest --cov=text_toolkit --cov-report=term-missing
uv run mypy
uv build --no-sources
```
Expand Down
15 changes: 9 additions & 6 deletions docs/06_github_actions.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ In this project, the local checks are:
```bash
uv run ruff check .
uv run ruff format --check .
uv run pytest
uv run pytest --cov=text_toolkit --cov-report=term-missing
uv run mypy
uv build --no-sources
```
Expand Down Expand Up @@ -169,6 +169,7 @@ This is important in CI because the workflow should check the project using the
The `--group dev` option installs development dependencies such as:

- `pytest`,
- `pytest-cov`,
- `mypy`,
- `ruff`.

Expand Down Expand Up @@ -213,16 +214,18 @@ The developer can fix formatting locally with:
uv run ruff format .
```

## Tests
## Tests and coverage

The workflow runs tests:
The workflow runs tests and prints a coverage report:

```yaml
- name: Run tests
run: uv run pytest
- name: Run tests with coverage
run: uv run pytest --cov=text_toolkit --cov-report=term-missing
```

This verifies the behavior of the example package.
This verifies the behavior of the example package while measuring statement and
branch coverage. The terminal report shows missing source lines, but the project
does not fail the workflow based on a coverage percentage.

At this stage, the tests check:

Expand Down
2 changes: 1 addition & 1 deletion docs/07_git_commits_branches_prs.md
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ For code changes, run:
```bash
uv run ruff check .
uv run ruff format --check .
uv run pytest
uv run pytest --cov=text_toolkit --cov-report=term-missing
uv run mypy
```

Expand Down
2 changes: 1 addition & 1 deletion docs/08_common_mistakes.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ For code changes, run:
```bash
uv run ruff check .
uv run ruff format --check .
uv run pytest
uv run pytest --cov=text_toolkit --cov-report=term-missing
uv run mypy
```

Expand Down
25 changes: 22 additions & 3 deletions docs/09_checklist.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,24 @@ uv run mypy

Type checking complements tests and Ruff; it does not replace them.

## Test coverage

The project should use coverage as a diagnostic tool:

- [ ] pytest-cov is installed as a development dependency
- [ ] coverage is limited to production source code
- [ ] statement and branch coverage are measured
- [ ] missing lines are visible in the terminal report
- [ ] a percentage is not treated as proof of test quality

In this guide, tests and coverage run together:

```bash
uv run pytest --cov=text_toolkit --cov-report=term-missing
```

There is no minimum percentage gate.

## Continuous integration

The project should run checks automatically in CI:
Expand All @@ -150,7 +168,7 @@ The project should run checks automatically in CI:
- [ ] CI installs dependencies from the lockfile
- [ ] CI runs linting
- [ ] CI checks formatting
- [ ] CI runs tests
- [ ] CI runs tests with coverage reporting
- [ ] CI runs type checking
- [ ] CI builds a wheel and source distribution
- [ ] CI status is visible in the README
Expand Down Expand Up @@ -198,7 +216,7 @@ For code changes, run:
```bash
uv run ruff check .
uv run ruff format --check .
uv run pytest
uv run pytest --cov=text_toolkit --cov-report=term-missing
uv run mypy
uv build --no-sources
```
Expand All @@ -214,7 +232,7 @@ Then repeat:
```bash
uv run ruff check .
uv run ruff format --check .
uv run pytest
uv run pytest --cov=text_toolkit --cov-report=term-missing
uv run mypy
uv build --no-sources
```
Expand Down Expand Up @@ -250,6 +268,7 @@ How do I install it?
Where is the code?
Where are the tests?
How do I run the tests?
How do I inspect test coverage?
How do I check formatting and linting?
How do I check type annotations?
How do I build distribution files?
Expand Down
11 changes: 11 additions & 0 deletions docs/12_test_coverage.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,17 @@ The important columns are:

The exact counts will change when the package changes.

## Coverage in CI

The `Quality checks` job runs the same command:

```bash
uv run pytest --cov=text_toolkit --cov-report=term-missing
```

The report is visible in the GitHub Actions log. CI fails when tests or coverage
collection fail, but it does not fail because the percentage decreases.

## Why there is no percentage gate

This project intentionally does not configure `fail_under`.
Expand Down
5 changes: 1 addition & 4 deletions docs/ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ These parts are already included in the repository.
- [x] Run linting in CI
- [x] Run formatting checks in CI
- [x] Run tests in CI
- [x] Run coverage reporting in CI
- [x] Run type checking in CI
- [x] Build distributions in CI
- [x] Add a CI badge to the README
Expand Down Expand Up @@ -138,10 +139,6 @@ These parts are already included in the repository.

These are good candidates for upcoming small pull requests.

### Test coverage

- [ ] Run coverage reporting in CI and align workflow documentation

### Repository polish

- [ ] Add issue templates only if the repository starts receiving external feedback
Expand Down
17 changes: 12 additions & 5 deletions docs/cheatsheet.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ Examples:
uv add --group dev pytest
uv add --group dev ruff
uv add --group dev mypy
uv add --group dev pytest-cov
```

Sync the local environment:
Expand All @@ -84,6 +85,12 @@ Run tests:
uv run pytest
```

Run tests with coverage:

```bash
uv run pytest --cov=text_toolkit --cov-report=term-missing
```

Run type checking:

```bash
Expand Down Expand Up @@ -113,7 +120,7 @@ Run all local checks:
```bash
uv run ruff check .
uv run ruff format --check .
uv run pytest
uv run pytest --cov=text_toolkit --cov-report=term-missing
uv run mypy
uv build --no-sources
```
Expand All @@ -136,7 +143,7 @@ If formatting fails:
uv run ruff format .
uv run ruff check .
uv run ruff format --check .
uv run pytest
uv run pytest --cov=text_toolkit --cov-report=term-missing
uv run mypy
uv build --no-sources
```
Expand All @@ -154,7 +161,7 @@ Then run:
```bash
uv run ruff check .
uv run ruff format --check .
uv run pytest
uv run pytest --cov=text_toolkit --cov-report=term-missing
uv run mypy
```

Expand Down Expand Up @@ -250,7 +257,7 @@ uv python install
uv sync --locked --group dev
uv run ruff check .
uv run ruff format --check .
uv run pytest
uv run pytest --cov=text_toolkit --cov-report=term-missing
uv run mypy
uv build --no-sources
```
Expand Down Expand Up @@ -305,7 +312,7 @@ git status
uv sync
uv run ruff check .
uv run ruff format --check .
uv run pytest
uv run pytest --cov=text_toolkit --cov-report=term-missing
uv run mypy
```

Expand Down
4 changes: 2 additions & 2 deletions docs/common_questions.md
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ This guide first teaches the commands directly:
```bash
uv run ruff check .
uv run ruff format --check .
uv run pytest
uv run pytest --cov=text_toolkit --cov-report=term-missing
uv run mypy
```

Expand Down Expand Up @@ -305,7 +305,7 @@ Then run the local checks:
```bash
uv run ruff check .
uv run ruff format --check .
uv run pytest
uv run pytest --cov=text_toolkit --cov-report=term-missing
uv run mypy
```

Expand Down
2 changes: 1 addition & 1 deletion docs/example_pull_request.md
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ For code changes, run:
```bash
uv run ruff check .
uv run ruff format --check .
uv run pytest
uv run pytest --cov=text_toolkit --cov-report=term-missing
uv run mypy
```

Expand Down
16 changes: 12 additions & 4 deletions docs/from_script_to_project.md
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ build-backend = "uv_build"
dev = [
"mypy>=2.3.1",
"pytest>=9.0.3",
"pytest-cov>=7.1.0",
"ruff>=0.15.12",
]

Expand All @@ -260,6 +261,13 @@ python_version = "3.12"
files = ["src", "tests"]
strict = true

[tool.coverage.run]
branch = true
source = ["text_toolkit"]

[tool.coverage.report]
show_missing = true

[tool.ruff]
line-length = 88
target-version = "py312"
Expand Down Expand Up @@ -308,7 +316,7 @@ In this guide, the main local checks are:
```bash
uv run ruff check .
uv run ruff format --check .
uv run pytest
uv run pytest --cov=text_toolkit --cov-report=term-missing
uv run mypy
uv build --no-sources
```
Expand All @@ -317,7 +325,7 @@ These commands check:

- linting,
- formatting,
- behavior,
- behavior and test coverage,
- type annotations,
- package distribution builds.

Expand Down Expand Up @@ -348,7 +356,7 @@ uv python install
uv sync --locked --group dev
uv run ruff check .
uv run ruff format --check .
uv run pytest
uv run pytest --cov=text_toolkit --cov-report=term-missing
uv run mypy
uv build --no-sources
```
Expand Down Expand Up @@ -429,7 +437,7 @@ The project now has:
- documentation in `docs/`,
- dependencies described in `pyproject.toml`,
- exact dependency versions in `uv.lock`,
- local checks with Ruff, pytest, and mypy,
- local checks with Ruff, pytest-cov, and mypy,
- CI with GitHub Actions,
- a branch and pull request workflow.

Expand Down
Loading
Loading