shyim / danger-php
将 danger 转换为 PHP 版本
0.3.4
2024-08-07 09:40 UTC
Requires
- php: ^8.2
- ext-ctype: *
- ext-intl: *
- ext-mbstring: *
- knplabs/github-api: ^3.14
- m4tthumphrey/php-gitlab-api: ^11.14
- nyholm/psr7: ^1.8
- symfony/config: ^7.1
- symfony/console: ^7.1
- symfony/dependency-injection: ^7.1
- symfony/filesystem: ^7.1
- symfony/finder: ^7.1
- symfony/http-client: ^7.1
- symfony/process: ^7.1
Requires (Dev)
- friendsofphp/php-cs-fixer: dev-master
- infection/infection: ^0.29.6
- phpstan/extension-installer: ^1.4.1
- phpstan/phpstan: ^1.11.9
- phpstan/phpstan-deprecation-rules: ^1.2.0
- phpstan/phpstan-phpunit: ^1.4.0
- phpstan/phpstan-strict-rules: ^1.6.0
- phpunit/phpunit: ^11.3
This package is auto-updated.
Last update: 2024-09-23 07:21:38 UTC
README
Danger 在 CI 流程中运行,并给团队提供了自动化常见代码审查任务的机会。本项目将 Danger 转换为 PHP。
目前仅支持 GitHub 和 Gitlab 作为平台
徽章
安装
Composer
使用 Composer 安装 danger-php
composer global require shyim/danger-php
Phar 归档
每个版本都附带 phar 归档
Docker
文档
禁止提交具有相同消息的多个提交
<?php declare(strict_types=1); use Danger\Config; use Danger\Rule\DisallowRepeatedCommits; return (new Config()) ->useRule(new DisallowRepeatedCommits) // Disallows multiple commits with the same message ;
只允许 Pull Request 中有一个提交
<?php declare(strict_types=1); use Danger\Config; use Danger\Rule\MaxCommit; return (new Config()) ->useRule(new MaxCommit(1)) ;
检查 CHANGELOG.md 的修改
<?php declare(strict_types=1); use Danger\Config; use Danger\Context; return (new Config()) ->useRule(function (Context $context): void { if (!$context->platform->pullRequest->getFiles()->has('CHANGELOG.md')) { $context->failure('Please edit also the CHANGELOG.md'); } }) ;
检查 Pull Request 中的 Assignee
<?php declare(strict_types=1); use Danger\Config; use Danger\Context; return (new Config()) ->useRule(function (Context $context): void { if (count($context->platform->pullRequest->assignees) === 0) { $context->warning('This PR currently doesn\'t have an assignee'); } }) ;