在您的预推送过程中生成readme徽章

1.1.0 2024-04-15 14:24 UTC

This package is auto-updated.

Last update: 2024-09-15 15:18:06 UTC


README

将徽章作为预推送钩子的一部分生成!

安装

  1. networkrailbusinesssystems/badges 添加到您的Composer开发依赖中
composer require --dev networkrailbusinesssystems/badges
  1. 确保PHPUnit以以下设置输出日志和覆盖率
<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>
  1. 将以下命令添加到预推送钩子中
php vendor/networkrailbusinesssystems/badges/badges.php
git add .github/*.svg
git diff-index --quiet --cached HEAD || git commit -m "Updated badges" --no-verify
  1. 将以下行添加到 readme.md,根据需要排除徽章
![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)

调试驱动器

您必须安装 xdebug 或 PCOV 以运行覆盖率检查,并启用覆盖率模式。

PCOV 通常比 XDebug 新且快,但可能不够准确。

XDebug

  1. sudo apt install php-xdebug
  2. 将以下内容添加到您的 php.ini 文件末尾
[xdebug]
xdebug.mode=coverage

PCOV

  1. sudo apt install php8.2-dev
  2. sudo apt install php-pear
  3. sudo pecl install pcov
  4. 将以下内容添加到您的 php.ini 文件末尾
[pcov]
extension=pcov.so

用法

  1. 正常运行 git push
  2. 预推送钩子将触发,运行您的测试和覆盖率
  3. 徽章将自动生成、更新并添加到提交中