shyim/danger-php

将 danger 转换为 PHP 版本

安装量: 9,624

依赖项: 0

建议者: 0

安全: 0

星标: 78

关注者: 5

分支: 8

公开问题: 1

类型:项目


README

Danger 在 CI 流程中运行,并给团队提供了自动化常见代码审查任务的机会。本项目将 Danger 转换为 PHP。

目前仅支持 GitHub 和 Gitlab 作为平台

徽章

MIT License codecov

安装

Composer

使用 Composer 安装 danger-php

composer global require shyim/danger-php

Phar 归档

每个版本都附带 phar 归档

Docker

使用 预先构建的 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');
        }
    })
;

截图

Example Comment

许可

MIT