Metadata-Version: 2.4
Name: skippy-cov
Version: 0.2.2
Summary: Selectively run tests based on the current git diff and the collected data from previous tests runs
Keywords: python
Author-email: Mariano Garcia Berrotaran <mariano.garciaberrotaran@shiphero.com>, Martín Gaitán <marting@shiphero.com>
Requires-Python: >=3.8,<4.0
Description-Content-Type: text/markdown
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Libraries :: Python Modules
License-File: LICENSE
Requires-Dist: unidiff >=0.7.5
Requires-Dist: coverage>=7.6
Requires-Dist: tomli; python_version < '3.11'
Project-URL: Repository, https://github.com/shiphero/skippy-cov

# skippy-cov

## Overview

`skippy-cov` is a tool that optimizes your Python testing workflow by filtering tests based on code changes. It takes a diff file from git and a `.coverage` database (generated by [`coverage.py`](https://coverage.readthedocs.io/)) to identify and run only the tests relevant to the modified code. This significantly reduces testing time and resources.


## Usage

To use this, you first need to generate the following required files:

* **Run Coverage Analysis:** Generate a `.coverage` database using `coverage.py` via `pytest-cov` with [test contexts](https://pytest-cov.readthedocs.io/en/latest/contexts.html)

```bash
    pytest --cov=myproj --cov-context=test myproj/tests/
```

Then change your code and run

```
pytest --skippy-cov
```

In this case, `skippy-cov` will analyze the changes and run only the tests that are relevant to the modified code.

You can also use `skippy-cov` as a CLI on its own.

```
skippy-cov
```

that will list the tests selected.


## Configuration

The inputs for skippy-cov are the coverage file (default: `.coverage`) and the diff information. By default, the diff is generated in the same way as a pull request (PR) on GitHub: only the changes introduced by your branch compared to the target branch are considered. This is done using the `git diff <target>...HEAD` (triple-dot) syntax.

You can specify the coverage file and a branch or ref to diff against (e.g., the main branch):

```bash
skippy-cov --diff main --coverage-file .coverage
```

or equivalently

```bash
pytest --skippy-cov --skippy-cov-diff main --skippy-cov-coverage-file .coverage
```

You can also provide a diff file:

```bash
git diff > changes.diff
skippy-cov --diff changes.diff --coverage-file .coverage
```

If you omit the `--diff` argument, it will default to the main branch as determined by your `git remote` (usually "main" or "master").

**Advanced:**  
You may pass any valid git diff refspec to `--diff`, including triple-dot syntax (e.g., `main...HEAD` or `origin/master...feature-branch`). If you provide a triple-dot ref, it will be used as-is, giving you full control over the comparison range.

See `skippy-cov --help` for more information.


## Contributing

See `CONTRIBUTING.md` for information on how to contribute to the project.

## License

See `LICENSE` for licensing information.

