Code Quality

There are lots of code quality tools available! Some concentrate on coding style, some on test coverage, some on static analysis/type checking, and many more.

Quality Tools

Chipper CI lets you download and install any tools you need! For example, you may want to install PHP Codesniffer and use it to generate a report of your code versus a coding style.

Note that Chipper CI currently doesn't have write-access to your repositories - it will not change your code and create PR's or commits against your repositories.

Some other tools to look into:

Coverage Testing

While PHPUnit can generate coverage reports, it does not plan on supporting a way to return errors (and thus fail a build) based on coverage.

This means we need some tools to help us!

To have your pipeline pass or fail a build based on test coverage, we can use a little utility as outlined here.

What we'll do is:

  1. Enable xDebug
  2. Have PHPUnit generate a coverage report
  3. Run a utility to check coverage and return a success or error response based on the coverage
# Download the coverage checker script
chmod +x coverage.php

# Enable xdebug and run phpunit
sudo phpenmod xdebug
phpunit --coverage-clover clover.xml

# Check the code coverage and return an error
# if code coverage is below 80%
./coverage.php clover.xml 80