PHPackages                             mgdsoft/bitbucket-pr-coverage - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Debugging &amp; Profiling](/categories/debugging)
4. /
5. mgdsoft/bitbucket-pr-coverage

ActiveLibrary[Debugging &amp; Profiling](/categories/debugging)

mgdsoft/bitbucket-pr-coverage
=============================

Create code coverage report in bitbucket

0.0.1(10mo ago)14MITPHPPHP ^8.0

Since Jun 24Pushed 6mo agoCompare

[ Source](https://github.com/MGDSoft/bitbucket-pr-coverage)[ Packagist](https://packagist.org/packages/mgdsoft/bitbucket-pr-coverage)[ RSS](/packages/mgdsoft-bitbucket-pr-coverage/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (6)Versions (2)Used By (0)

Bitbucket PR Coverage
=====================

[](#bitbucket-pr-coverage)

A tool to analyze PHPUnit code coverage for modified lines in Bitbucket pull requests.

Description
-----------

[](#description)

This tool analyzes PHPUnit code coverage reports and git diffs to calculate the test coverage percentage of modified lines in a pull request. It then creates a coverage report in Bitbucket, showing the overall coverage percentage and highlighting uncovered lines.

Key features:

- Focuses only on modified/new lines in the pull request
- Creates a coverage report directly in Bitbucket
- Adds annotations for uncovered lines
- Marks the report as PASSED if coverage is &gt; 80%, otherwise FAILED

[![annotation](docs/annotation.png)](docs/annotation.png)[![report](docs/report.png)](docs/report.png)

Sometimes your code may have many lines without tests, **but you can quickly disable them**.

[![hide_annotation](docs/hide_annotation.png)](docs/hide_annotation.png)

Installation
------------

[](#installation)

```
composer require mgdsoft/bitbucket-pr-coverage
```

Usage
-----

[](#usage)

### Basic Usage

[](#basic-usage)

```
php vendor/bin/pr-coverage coverage_report \
  --coverage_report_path=/path/to/clover.xml \
  --api_token=your-bitbucket-token
```

### Using Environment Variables

[](#using-environment-variables)

You can also set the following environment variables instead of passing command-line options:

- `BITBUCKET_PR_ID`: Pull request ID (default in Bitbucket pipelines)
- `BITBUCKET_WORKSPACE`: Bitbucket workspace/owner (default in Bitbucket pipelines)
- `BITBUCKET_REPO_SLUG`: Repository name (default in Bitbucket pipelines)

```
# generate clover.xml with PHPUnit
php -d memory_limit=-1 bin/phpunit --log-junit ./test-reports/phpunit.junit.xml --coverage-clover ./test-reports/phpunit.coverage.xml

export BITBUCKET_PR_ID=123
export BITBUCKET_WORKSPACE=your-workspace
export BITBUCKET_REPO_SLUG=your-repo
export BITBUCKET_TOKEN=your-bitbucket-token

php bin/pr-coverage coverage_report --coverage_report_path=$BITBUCKET_CLONE_DIR/test-reports/phpunit.coverage.xml
```

How It Works
------------

[](#how-it-works)

1. Reads the PHPUnit coverage report (XML format)
2. Generates a git diff between the current branch and the target branch
3. Identifies which lines were modified in the pull request
4. Calculates the coverage percentage for the modified lines
5. Creates a coverage report in Bitbucket
6. Adds annotations for uncovered lines

Requirements
------------

[](#requirements)

- PHP 8.0 or higher
- PHPUnit XML coverage report
- Bitbucket API token with appropriate permissions

License
-------

[](#license)

MIT License

Credits
-------

[](#credits)

This project is a fork of [orbeji /phpunit-pr-coverage-check](https://github.com/orbeji/phpunit-pr-coverage-check) with updated dependencies and code improvements. Thanks to the author Orbeji for their work.

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance61

Regular maintenance activity

Popularity5

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity31

Early-stage or recently created project

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

319d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/896bc1dc22720fe832ca4d74135728066f636f9604291176678d097c0dbfbed9?d=identicon)[MGDSoft](/maintainers/MGDSoft)

### Embed Badge

![Health badge](/badges/mgdsoft-bitbucket-pr-coverage/health.svg)

```
[![Health](https://phpackages.com/badges/mgdsoft-bitbucket-pr-coverage/health.svg)](https://phpackages.com/packages/mgdsoft-bitbucket-pr-coverage)
```

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M648](/packages/sylius-sylius)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[infection/infection

Infection is a Mutation Testing framework for PHP. The mutation adequacy score can be used to measure the effectiveness of a test set in terms of its ability to detect faults.

2.2k26.2M1.8k](/packages/infection-infection)[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[kimai/kimai

Kimai - Time Tracking

4.6k7.4k1](/packages/kimai-kimai)[drupal/core

Drupal is an open source content management platform powering millions of websites and applications.

19462.3M1.3k](/packages/drupal-core)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
