Skippy-Cov

0.2.2 · active · verified Fri Apr 17

Skippy-cov is a pytest plugin that intelligently selects and runs only relevant tests based on the current Git diff and previously collected coverage data. It aims to speed up CI/CD pipelines by avoiding unnecessary test runs by analyzing which code changes affect which tests. The current version is 0.2.2, with releases occurring periodically to refine its Git and pytest integration.

Common errors

Warnings

Install

Quickstart

This quickstart demonstrates how to install skippy-cov, set up a minimal Git repository with a module and tests, run `pytest` to collect initial coverage data, then simulate code changes on a feature branch, and finally use `skippy-cov` with a Git diff to run only the affected tests.

mkdir my_skippy_project && cd my_skippy_project
git init -b main
pip install skippy-cov pytest coverage

# Create a simple module and test file
mkdir src && mkdir src/tests
echo "def func_a():\n    return 'A'\ndef func_b():\n    return 'B'" > src/my_module.py
echo "import pytest\nfrom src.my_module import func_a, func_b\n\ndef test_func_a():\n    assert func_a() == 'A'\n\ndef test_func_b():\n    assert func_b() == 'B'" > src/tests/test_my_module.py
touch src/__init__.py src/tests/__init__.py
git add .
git commit -m "Initial code and tests"

echo "\n--- First run: Collect all coverage data ---"
pytest --skippy-cov --cov=src --cov-report=xml src/tests/

# Simulate a change to func_a and add a new test on a feature branch
git checkout -b feature/new-func
echo "def func_a():\n    return 'A_modified'\ndef func_b():\n    return 'B'\ndef func_c():\n    return 'C'" > src/my_module.py
echo "import pytest\nfrom src.my_module import func_a, func_b, func_c\n\ndef test_func_a():\n    assert func_a() == 'A_modified'\n\ndef test_func_func_b():\n    assert func_b() == 'B'\n\ndef test_func_c():\n    assert func_c() == 'C'" > src/tests/test_my_module.py
git add .
git commit -m "Add func_c and modify func_a"

echo "\n--- Second run: Run only affected tests using diff ---"
# Generate a diff between 'main' branch and current 'feature/new-func' branch
git diff main...feature/new-func -- src/my_module.py > /tmp/my_skippy_diff.diff
pytest --skippy-cov=/tmp/my_skippy_diff.diff src/tests/
echo "Expected: Only tests related to func_a (modified) and func_c (new) should run."

view raw JSON →