networkrailbusinesssystems / badges
Generate readme badges during your pre-push
Installs: 1 923
Dependents: 5
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
README
Generate badges as part of your pre-push hooks!
Installation
- Add
networkrailbusinesssystems/badges
to your Composer dev dependencies
composer require --dev networkrailbusinesssystems/badges
- Ensure that PHPUnit outputs logs and coverage with the following settings:
<coverage> <report> <html outputDirectory=".phpunit.cache/html" /> <text outputFile=".phpunit.cache/coverage.txt" showUncoveredFiles="false" showOnlySummary="true" /> </report> </coverage> <logging> <junit outputFile=".phpunit.cache/tests.xml" /> </logging>
- Add the following commands to the pre-push hook:
php vendor/networkrailbusinesssystems/badges/badges.php git add .github/*.svg git diff-index --quiet --cached HEAD || git commit -m "Updated badges" --no-verify
- Add the following lines to
readme.md
, excluding badges as required:
![Composer status](.github/composer.svg) ![Coverage status](.github/coverage.svg) ![Frontend version](.github/frontend.svg) ![Laravel version](.github/laravel.svg) ![NPM status](.github/npm.svg) ![PHP version](.github/php.svg) ![Tests status](.github/tests.svg)
Debug driver
You must have either xdebug or PCOV installed to run coverage checks, and enable the coverage mode.
PCOV is generally newer and faster than XDebug, however it may not be as accurate.
XDebug
sudo apt install php-xdebug
- Add the following to the end of your
php.ini
:
[xdebug] xdebug.mode=coverage
PCOV
sudo apt install php8.2-dev
sudo apt install php-pear
sudo pecl install pcov
- Add the following to the end of your
php.ini
:
[pcov] extension=pcov.so
Usage
- Run
git push
as normal - The pre-push hooks will fire, running your tests and coverage
- The badges will automatically generate, update, and be added to the commit