diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b177e2e..04d66cc 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -9,6 +9,13 @@ jobs: pytest: name: Pytest runs-on: ubuntu-latest + permissions: + # contents: write lets the action store coverage data and the badge on + # its data branch (on push to master). pull-requests: write lets it post + # the coverage comment on pull requests. Note: fork PRs get a read-only + # token from GitHub regardless, so they will not receive a comment. + contents: write + pull-requests: write steps: - uses: actions/checkout@v4 @@ -21,4 +28,9 @@ jobs: run: pip install -e ".[dev]" - name: Run pytest - run: pytest + run: pytest --cov=mergai --cov-report=term-missing + + - name: Coverage comment + uses: py-cov-action/python-coverage-comment-action@v3 + with: + GITHUB_TOKEN: ${{ github.token }} diff --git a/README.md b/README.md index 2a68b59..e3f0c0b 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # mergai -[![Format Check](https://github.com/Percona-Lab/mergai/actions/workflows/format-check.yml/badge.svg)](https://github.com/Percona-Lab/mergai/actions/workflows/format-check.yml) [![Lint](https://github.com/Percona-Lab/mergai/actions/workflows/lint.yml/badge.svg)](https://github.com/Percona-Lab/mergai/actions/workflows/lint.yml) [![Dependency Check](https://github.com/Percona-Lab/mergai/actions/workflows/deps-check.yml/badge.svg)](https://github.com/Percona-Lab/mergai/actions/workflows/deps-check.yml) [![Security Scan](https://github.com/Percona-Lab/mergai/actions/workflows/security.yml/badge.svg)](https://github.com/Percona-Lab/mergai/actions/workflows/security.yml) +[![Format Check](https://github.com/Percona-Lab/mergai/actions/workflows/format-check.yml/badge.svg)](https://github.com/Percona-Lab/mergai/actions/workflows/format-check.yml) [![Lint](https://github.com/Percona-Lab/mergai/actions/workflows/lint.yml/badge.svg)](https://github.com/Percona-Lab/mergai/actions/workflows/lint.yml) [![Dependency Check](https://github.com/Percona-Lab/mergai/actions/workflows/deps-check.yml/badge.svg)](https://github.com/Percona-Lab/mergai/actions/workflows/deps-check.yml) [![Security Scan](https://github.com/Percona-Lab/mergai/actions/workflows/security.yml/badge.svg)](https://github.com/Percona-Lab/mergai/actions/workflows/security.yml) [![Coverage](https://raw.githubusercontent.com/Percona-Lab/mergai/python-coverage-comment-action-data/badge.svg)](https://htmlpreview.github.io/?https://github.com/Percona-Lab/mergai/blob/python-coverage-comment-action-data/htmlcov/index.html) A CLI tool for AI-assisted merge conflict resolution, designed for maintaining long-running forks that regularly sync with upstream repositories. diff --git a/pyproject.toml b/pyproject.toml index 2219975..69a3a0e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -44,11 +44,18 @@ dev = [ "pip-audit>=2.7.0", "deptry>=0.12.0", "pytest>=7.0.0", + "pytest-cov>=5.0.0", ] [tool.pytest.ini_options] testpaths = ["tests"] +[tool.coverage.run] +# relative_files is required by python-coverage-comment-action so the +# recorded paths match across the CI checkout and the reporting workflow. +relative_files = true +source = ["mergai"] + [tool.black] line-length = 88 target-version = ['py310'] @@ -98,4 +105,4 @@ exclude = [ [tool.deptry] # Ignore dev tools that are CLI-based and not imported in code [tool.deptry.per_rule_ignores] -DEP002 = ["pre-commit", "ruff", "mypy", "types-PyYAML", "pip-audit", "deptry", "pytest"] \ No newline at end of file +DEP002 = ["pre-commit", "ruff", "mypy", "types-PyYAML", "pip-audit", "deptry", "pytest", "pytest-cov"] \ No newline at end of file