Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
29a02b3
Merge pull request #2 from codeclimate/pb-min-stability
noahd1 May 28, 2014
1f64088
Report coverage to Code Climate
pbrisbin Jul 2, 2014
bf394ce
Add coverage logging to phpunit.xml.dist
pbrisbin Jul 2, 2014
331a602
Added --coverage-report option to support custom covarage file locati…
Jul 8, 2014
5451dd2
Added exec mode to composer/bin/test-reporter file
Jul 8, 2014
ccb3203
Added code comments
Jul 8, 2014
c80ff60
Added support for aboslute & relative paths to clover files
Jul 9, 2014
1609688
Note cert error workaround in README
pbrisbin Jul 10, 2014
1427067
Update README.md
jonathancadepowers Jul 11, 2014
19bb3c8
Merge pull request #8 from codeclimate/pb-cert-workaround
pbrisbin Jul 11, 2014
ad153de
Merge pull request #7 from martinssipenko/master
pbrisbin Jul 14, 2014
dd461f4
Use stable version of satooshi/php-coveralls
Jul 14, 2014
c007d2d
Added branch alias for v0.x
Jul 14, 2014
aef7a9d
Merge pull request #9 from martinssipenko/master
pbrisbin Jul 14, 2014
eb7ccf1
Check packagist autohook
mrb Jul 15, 2014
f077af4
Use cURL extension instead of Guzzle.
sun Jul 1, 2014
95c8bc0
Correctly handle 100 Continue HTTP status
pbrisbin Jul 17, 2014
88b34d7
Bump version to 0.1.1
pbrisbin Jul 17, 2014
da5edcb
Fix #13
Jul 21, 2014
8be500d
Fix #13 Use old namespaces from satooshi/php-coveralls 0.6.*
Jul 21, 2014
12f1e31
Fix #13 fixed composer to use satooshi/php-coveralls 0.6.*
Jul 21, 2014
dfcc7d8
Merge pull request #14 from martinssipenko/master
marshally Jul 22, 2014
624776d
Bump version to 0.1.2
marshally Jul 23, 2014
c73f55b
Add buildbox CI info support
xzyfer Sep 30, 2014
2aee70a
Merge pull request #16 from xzyfer/feat/buildbox
marshally Oct 7, 2014
c06e089
Fixes #20: Adds CI service info for Wercker
Nov 10, 2014
12d2786
Update README.md
rdohms Nov 12, 2014
85c584d
Merge pull request #22 from rdohms/patch-1
marshally Nov 12, 2014
22121ea
Update README.md
jonathancadepowers Dec 29, 2014
0fee4d8
adding information about required software to install the library;
Jan 12, 2015
ff9319a
adding Xdebug extension check to require-dev to warn user of missing …
Jan 12, 2015
d6c055f
adding certificate to the repo
Jan 14, 2015
23a1aad
adding certificate use to the ApiClient curl request
Jan 14, 2015
486d6f2
trying out adding the www to the domain on a whim
Jan 14, 2015
29070c5
Revert "trying out adding the www to the domain on a whim"
Jan 14, 2015
c936b30
Revert "adding certificate use to the ApiClient curl request"
Jan 14, 2015
e121e6f
Revert "adding certificate to the repo"
Jan 14, 2015
7f5c3bf
removing curl, using native PHP streams instead
Jan 26, 2015
23a2edd
Merge pull request #26 from enygma/readme-update-required-software
jeffrafter Feb 20, 2015
2afed92
Merge pull request #27 from enygma/remove-curl
JacobNinja Mar 16, 2015
f975069
Update README.md
jonathancadepowers Apr 2, 2015
6e999f4
Added clarification tip to cURL workaround.
jonathancadepowers Apr 17, 2015
cb65432
Added bold tags around a note.
jonathancadepowers Apr 17, 2015
657bf80
Fixed a markdown syntax error.
jonathancadepowers Apr 17, 2015
13a822d
Merge pull request #21 from mshmsh5000/master
noahd1 Apr 18, 2015
e0da374
Enhancement: Use SVG badge for Code Climate GPA
localheinz Jul 25, 2015
4e7e1af
Fix: stcClass vs stdClass
localheinz Jul 25, 2015
eff5264
Rename Buildbox to Buildkite
toolmantim Aug 19, 2015
f719c21
Merge pull request #37 from localheinz/fix/stdclass
Aug 24, 2015
03c740e
Merge pull request #39 from buildkite/rename-buildbox-to-buildkite
gdiggs Sep 8, 2015
6a76919
Fix composer branch alias
soullivaneuh Oct 15, 2015
19875e1
Merge pull request #41 from Soullivaneuh/patch-1
gdiggs Oct 15, 2015
2ed9862
Merge pull request #32 from localheinz/fix/code-climate-badge
jpignata Dec 17, 2015
83d7fc8
Updating 'satooshi/php-coveralls' to use version 1.0.*
ericdowell Feb 2, 2016
79059d4
Missed reference to old namespace 'Contrib'.
ericdowell Feb 2, 2016
a668680
Merge pull request #45 from ericdowell/update-php-coveralls
gdiggs Feb 16, 2016
d554a87
Bump version
gdiggs Feb 16, 2016
2fdeded
Fix: Travis configuration
localheinz Jul 25, 2015
d023577
Merge pull request #33 from localheinz/fix/travis
dblandin Mar 11, 2016
6ebbac0
Added cURL backup method to ApiClient.
aensley Apr 18, 2016
ca9748c
Merge pull request #48 from aensley/master
jpignata Apr 18, 2016
b5bfae3
Reduce cURL verbosity. codeclimate/php-test-reporter#48
aensley Apr 19, 2016
8ebc50e
Merge pull request #49 from aensley/master
jpignata Apr 19, 2016
f36cdd5
Fox reference to phpunit XML file name
tjchambers May 9, 2016
b231597
Fix reference to phpunit XML file name (#50)
wfleming May 9, 2016
d2af420
Fix typo and link to docs
May 17, 2016
a965b4d
Merge pull request #51 from codeclimate/abh-fix-typo
May 17, 2016
966cfe8
added box.json
1ma Jun 2, 2016
8fdd541
renamed artifact to codeclimate-test-reporter.phar, as per request
1ma Jun 7, 2016
35d7d65
Merge pull request #52 from 1ma/boxify
dblandin Jun 7, 2016
92831c3
Use PSR-4-compatible namespaces
hollodotme Jul 19, 2016
c0d9e17
Remove secure env var
pbrisbin Jul 29, 2016
fc1aa7d
Configure CC
pbrisbin Jul 29, 2016
4c05266
Enable phpcodesniffer
pbrisbin Jul 29, 2016
c68cf8c
Tabs -> Spaces
pbrisbin Jul 29, 2016
c14eadd
Correct brace and parenthesis style
pbrisbin Jul 29, 2016
e746f41
Merge pull request #58 from codeclimate/pb-psr-4-etc
pbrisbin Jul 29, 2016
f894ec3
Removed obsolete root dir in stub, Application and TestReporterCommand
hollodotme Jul 19, 2016
a0c408c
Added added self-update & rollback command, CHANGELOG, documentation,…
hollodotme Jul 19, 2016
7ff4a73
Fixed code formatting
Aug 9, 2016
5c32d13
Fixed code formatting issues
Aug 9, 2016
d5c4cbb
Removed side effects
Aug 9, 2016
187c737
Removed obsolete WORKING_DIR
Aug 9, 2016
30068f5
Fixed unused parameter
Aug 9, 2016
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
27 changes: 27 additions & 0 deletions .codeclimate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
engines:
duplication:
enabled: true
config:
languages:
- php
phpcodesniffer:
enabled: true
phpmd:
enabled: true
checks:
CleanCode/ElseExpression:
enabled: false
Controversial/Superglobals:
enabled: false
exclude_fingerprints:
# High complexity in CiInfo#toArray()
- 8f1ff5077ea52a5fee818bde73a0dbb7
- efc665f3aa41cbbd0bbd0ec9c945a453
ratings:
paths:
- "**.inc"
- "**.module"
- "**.php"
exclude_paths:
- tests/
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
.idea/
.vagrant/
Vagrantfile
build/
vendor/
composer.lock
Expand Down
21 changes: 20 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,26 @@
language: php

sudo: false

php:
- 5.5
install: composer install --dev

cache:
directories:
- $HOME/.composer/cache

before_install:
- composer self-update

install:
- composer install --prefer-dist

before_script:
- git config --global user.email "[email protected]"
- git config --global user.name "Travis CI"

script:
- vendor/bin/phpunit

after_script:
- php composer/bin/test-reporter
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Change Log

All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/) and [Keep a CHANGELOG](http://keepachangelog.com).

## [Unreleased]

### Added

- Executable .phar file for download
- `upload` command (PHAR only) - same as calling the tool without a command when installed via composer.
- `self-update` / `selfupdate` command (PHAR only)
- `rollback` command (PHAR only)
- [Installation / Usage](./README.md) / [Distribution instructions](./DEVELOPING.md) for the PHAR tool

[Unreleased]: https://github.com/codeclimate/php-test-reporter/compare/v0.3.2...HEAD
38 changes: 32 additions & 6 deletions DEVELOPING.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,44 @@
# Developing

- Get the source
## Get the source

$ git clone https://github.com/codeclimate/php-test-reporter

- Install dependencies
## Install dependencies

$ curl -sS https://getcomposer.org/installer | php
$ php composer.phar install --dev
$ php composer.phar update -o -v

- Run the tests
## Run the tests

$ ./vendor/bin/phpunit

### With HTML coverage output:

- Submit PRs to https://github.com/codeclimate/php-test-reporter
$ ./vendor/bin/phpunit --coverage-html=build/logs/coverage

*Note*: all changes and fixes must have appropriate test coverage.
## Build the PHAR tool

# Create a new git tag (optional)
$ git tag v1.x.x -m 'Version 1.x.x'
# Build the PHAR using box project
$ ./vendor/bin/box build

## Distribute the PHAR tool

### With verification and compatibility for phar.io / PhiVE

* [Create a GPG key](https://phar.io/howto/generate-gpg-key.html) (Should be the repositoy's maintainer one)
* [Create a signature and upload to Github](https://phar.io/howto/sign-and-upload-to-github.html)

### Without verification

* Go to the [releases section on Github](https://github.com/codeclimate/php-test-reporter/releases)
* Click "Edit" on the latest tag/release
* Add the `codeclimate-test-reporter.phar` in the "Attach binaries..." section
* Click "Update release"

## Contribute

* Submit PRs to: https://github.com/codeclimate/php-test-reporter
* *Note*: all changes and fixes must have appropriate test coverage.
115 changes: 87 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,48 +1,79 @@
[![Code Climate](https://codeclimate.com/github/codeclimate/php-test-reporter.png)](https://codeclimate.com/github/codeclimate/php-test-reporter) [![Build Status](https://travis-ci.org/codeclimate/php-test-reporter.svg?branch=master)](https://travis-ci.org/codeclimate/php-test-reporter)
[![Code Climate](https://codeclimate.com/github/codeclimate/php-test-reporter.svg)](https://codeclimate.com/github/codeclimate/php-test-reporter)
[![Build Status](https://travis-ci.org/codeclimate/php-test-reporter.svg?branch=master)](https://travis-ci.org/codeclimate/php-test-reporter)

# codeclimate-test-reporter

Collects test coverage data from your PHP test suite and sends it to
Collects test coverage data from your PHP test suite and sends it to
Code Climate's hosted, automated code review service.

Code Climate - https://codeclimate.com

**Important:** If you encounter an error involving SSL certificates, see the **Known Issue: SSL Certificate Error** section below.

# Important FYIs

Across the many different testing frameworks, setups, and environments, there are lots of variables at play. Before setting up test coverage, it's important to understand what we do and do not currently support:

* **Default branch only:** We only support test coverage for your [default branch](https://docs.codeclimate.com/docs/code-climate-glossary#default-branch). Be sure to check out this branch before running your tests.
* **Single payload:** We currently only support a single test coverage payload per commit. If you run your tests in multiple steps, or via parallel tests, Code Climate will only process the first payload that we receive. If you are using a CI, be sure to check if you are running your tests in a parallel mode.

**Note:** There is one exception to this rule. We've specifically built an integration with [Solano Labs](https://www.solanolabs.com/) to support parallel tests.

**Note:** If you've configured Code Climate to analyze multiple languages in the same repository (e.g., Ruby and JavaScript), we can nonetheless only process test coverage information for one of these languages. We'll process the first payload that we receive.
* **Invalid File Paths:** By default, our test reporters expect your application to exist at the root of your repository. If this is not the case, the file paths in your test coverage payload will not match the file paths that Code Climate expects.

## Requirements

There are several requirements you'll need in order to use the PHP test reporter on your system:

- [PHPUnit](http://phpunit.de)
- [Xdebug](http://xdebug.org)
- [Composer](http://getcomposer.org)

The test reporter uses the [PHPUnit](http://phpunit.de) testing tool to generate [code coverage](http://en.wikipedia.org/wiki/Code_coverage) information. These results show how much of your application's code is being executed by your unit tests. PHPUnit can't generate this information on its own though - it needs another tool, [Xdebug](http://xdebug.org). This is *not* included as a part of the PHPUnit (or PHP) install by default so you'll need to install it yourself.

Xdebug is installed as an extension to PHP, not a library. You can find more information about installing the tool via PECL [on the project website](http://xdebug.org/docs/install).

If you execute your PHPUnit tests with the `--coverage-clover` option and receive the message "The Xdebug extension is not loaded. No code coverage will be generated." you will need to visit the Xdebug website and install the extension. If you do not, you'll most likely get an error something like this:

```
PHP Warning: simplexml_load_file(): I/O warning : failed to load external entity "[...]/build/logs/clover.xml" in [...]/vendor/satooshi/php-coveralls/src/Contrib/Bundle/CoverallsV1Bundle/Api/Jobs.php on line 52
```

## Installation

This package requires a user, but not necessarily a paid account, on
Code Climate, so if you don't have one the first step is to signup at:
This package requires a user, but not necessarily a paid account, on
Code Climate, so if you don't have one the first step is to signup at:
https://codeclimate.com.

To install php-test-reporter with Composer first add the following to
your composer.json file:
### Via composer

**composer.json**
To install php-test-reporter with Composer run the following command.

```javascript
{
"require-dev": {
"codeclimate/php-test-reporter": "dev-master"
}
}
```shell
$ composer require codeclimate/php-test-reporter --dev
```

Then, run:
This will get you the latest version of the reporter and install it. If you do want the master, untagged, version you may use the command below:

```
$ php composer.phar install --dev
```shell
$ composer require codeclimate/php-test-reporter:@dev --dev
```

If adding the test-reporter to an existing project, run:
### As PHAR tool

```
$ php composer.phar update codeclimate/php-test-reporter --dev
Checkout the [latest release here](https://github.com/codeclimate/php-test-reporter/releases) and replace `X.X.X` with the latest version.

```shell
$ RELEASE=X.X.X
$ wget -c "https://github.com/codeclimate/php-test-reporter/releases/download/$RELEASE/codeclimate-test-reporter.phar"
```

## Usage

- Generate coverage data to `build/logs/clover.xml`

Add the following to phpunit.dist.xml:
Add the following to phpunit.xml.dist:

```xml
<?xml version="1.0" encoding="UTF-8"?>
Expand All @@ -57,27 +88,54 @@ Add the following to phpunit.dist.xml:

Or invoke `phpunit` as follows:

```
```shell
$ phpunit --coverage-clover build/logs/clover.xml
```

- Specifying your repo token as an environment variable, invoke the
- Specifying your repo token as an environment variable, invoke the
test-reporter:

```
```shell
$ CODECLIMATE_REPO_TOKEN="..." vendor/bin/test-reporter

# ... or via PHAR ...

$ CODECLIMATE_REPO_TOKEN="..." codeclimate-test-reporter.phar upload
```

The `CODECLIMATE_REPO_TOKEN` value is provided after you add your repo
to your Code Climate account by clicking on "Setup Test Coverage" on the
The `CODECLIMATE_REPO_TOKEN` value is provided after you add your repo
to your Code Climate account by clicking on "Setup Test Coverage" on the
right hand side of your feed.

Please contact [email protected] if you need any assistance setting
Please contact [email protected] if you need any assistance setting
this up.

## Troubleshooting

If you're having trouble setting up or working with our test coverage feature, [see our detailed help doc](http://docs.codeclimate.com/article/220-help-im-having-trouble-with-test-coverage), which covers the most common issues encountered.

## Known Issue: SSL Certificate Error

If you encounter an error involving SSL certificates when trying to report
coverage data from your CI server, you can work around it by manually posting
the data via `curl`:

```yaml
after_script:
- CODECLIMATE_REPO_TOKEN="..." bin/test-reporter --stdout > codeclimate.json
- "curl -X POST -d @codeclimate.json -H 'Content-Type: application/json' -H 'User-Agent: Code Climate (PHP Test Reporter v0.1.1)' https://codeclimate.com/test_reports"
```

**Note:** In the command above, you may need to change `bin/test-reporter` to `vendor/bin/test-reporter`, depending on your project's directory structure.

More details can be found in [this issue][issue].

[issue]: https://github.com/codeclimate/php-test-reporter/issues/3


## Contributions

Patches, bug fixes, feature requests, and pull requests are welcome on
Patches, bug fixes, feature requests, and pull requests are welcome on
the GitHub page for this project:

https://github.com/codeclimate/php-test-reporter
Expand All @@ -88,5 +146,6 @@ This package is maintained by Bryan Helmkamp ([email protected]).

See LICENSE.txt

Portions of the implementation were inspired by the php-coveralls
Portions of the implementation were inspired by the php-coveralls
project.

39 changes: 39 additions & 0 deletions box.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"chmod": "0755",
"compression": "GZ",
"alias": "codeclimate-test-reporter.phar",
"directories": [
"src"
],
"compactors": [
"Herrera\\Box\\Compactor\\Php"
],
"extract": false,
"intercept": true,
"files": [
"LICENSE"
],
"finder": [
{
"name": [
"*.php",
"*.pem"
],
"exclude": [
"bin",
"tests",
"phpunit",
"tm"
],
"in": [
"vendor"
]
}
],
"git-version": "package_version",
"main": "phar/bin/main.php",
"metadata": "The code climate php test reporter",
"output": "build/codeclimate-test-reporter.phar",
"shebang": "#!/usr/bin/env php",
"stub": true
}
Loading