ghostwriter/合规

合规 - 通过 GitHub Actions 为 PHP 提供的 CI/CD & QA 测试自动化。

维护者

详细信息

github.com/ghostwriter/compliance

安装量: 1,269

依赖项: 0

建议者: 0

安全: 0

星标: 0

关注者: 2

分支: 0

类型:项目

此包尚未发布版本,信息较少。


README

Automation Supported PHP Version Type Coverage Latest Version on Packagist Downloads

自动化 - CI/CD & QA 测试 通过 GitHub ActionsPHP 提供测试自动化。

注意

该项目尚未完成,仍在进行中。

待办事项

  • 检查 composer 脚本部分以查看是否存在命令,

    • 如果不存在,则报告错误/警告
    • 如果不存在,则跳过作业
  • 所有工具都应该有一个匹配的 composer 脚本名称,我现在已经硬编码了 composer 脚本,但这是可配置的(短横线命名)

    • 命令将是 composer automation:composer-require-checker
      • composer automation:phpunit
        • 我喜欢 automation: 前缀,这样如果有 phpunit 脚本,
        • 它不会与 automation:phpunit 脚本冲突
  • 我将导入发布自动化到这个项目中

  • 我们将导入 composer.jsoncomposer.lock 验证到这个项目中

    • 我们将使用 composer.json 文件中的扩展字段来确定要安装哪些 PHP 扩展
    • 将扩展列表作为参数传递给 docker 镜像/工作流程 via shivammathur/setup-php@v2(这部分看起来已经完成,但我们需要测试它。)
    • 我做了大部分这些... 但我需要测试它。
    • 我们拥有从这两个 composer 文件中提取所需信息的所有东西

[!INFO]

哇哦!我们做到了!我们有一个可工作的原型!🎉

-- 我们需要从 GitHub secrets 中导入 gpg 密钥 GPG_KEYGPG_FINGERPRINT --- 以使用 gpg 签名标记发布 --- 使用 gpg 签名签名二进制文件 --- 使用 gpg 签名签名 git 提交(如果所有测试都通过,则自动更新 composer.json)

  • 我们需要添加一个命令将这些命令添加到用户的 composer.json 文件中,对于他们 composer.json 文件中支持的每个工具。
  • 如果它不存在,我们将将其添加到 scripts 部分。
  • 如果它存在,继续。
{
    "scripts": {
        "automation:composer-require-checker": [
            "composer-require-checker check --config-file=composer-require-checker.json"
        ],
        "automation:phpunit": [
              "@phpunit --configuration=phpunit.xml --coverage-clover=coverage.xml"
        ]
    }
}

工作流程

# .github/workflows/automation.yml
name: Automation

on:
  pull_request:
  push:
    branches:
      - "main"
      - "[0-9]+.[0-9]+.x" # 1.2.x
      - "v[0-9]+" # v1
  schedule:
    - cron: "0 * * * *" # Runs hourly
  workflow_dispatch: # Manually Trigger workflow

jobs:
  automation:
    uses: ghostwriter/automation/.github/workflows/automation.yml@v1
    secrets:
      CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
      GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
      INFECTION_DASHBOARD_API_KEY: ${{ secrets.INFECTION_DASHBOARD_API_KEY }}

安装

您可以通过 composer 安装此包

composer require ghostwriter/automation --dev
Automation - Automatically configure and execute multiple CI/CD & QA Tests via GitHub Actions. 1.x-dev

Usage:
  command [options] [arguments]

Options:
  -h, --help            Display help for the given command. When no command is given display help for the list command
  -q, --quiet           Do not output any message
  -V, --version         Display this application version
      --ansi|--no-ansi  Force (or disable --no-ansi) ANSI output
  -n, --no-interaction  Do not ask any interactive question
  -v|vv|vvv, --verbose  Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

Available commands:
  help        Display help for a command
  list        List commands
  matrix      Generates a job matrix for Github Actions.
  workflow    Creates a "automation.yml" workflow file.

用法

如果不存在,则生成 automation.php 配置文件,并确定 GitHub Actions 的工作矩阵。

vendor/bin/automation matrix

为您的项目生成 .github/workflows/automation.yml 工作流程文件。

vendor/bin/automation workflow

Docker

# Install from the command line:

docker pull ghcr.io/ghostwriter/automation:v1

# Usage from the command line:

docker run -v $(PWD):/app -w=/app ghcr.io/ghostwriter/automation workflow
docker run -v $(PWD):/app -w=/app ghcr.io/ghostwriter/automation matrix

# Use as base image in Dockerfile:

FROM ghcr.io/ghostwriter/automation:v1

支持的工具?!

<?php

declare(strict_types=1);

use Ghostwriter\Automation\Automation;
use Ghostwriter\Automation\Enum\ComposerStrategy;
use Ghostwriter\Automation\Enum\OperatingSystem;
use Ghostwriter\Automation\Enum\PhpVersion;
use Ghostwriter\Automation\Enum\Tool;
use Ghostwriter\Automation\Tool\Infection;
use Ghostwriter\Automation\Tool\PHPUnit;
use Ghostwriter\Automation\Tool\Psalm;

return Automation::new()
    ->composerStrategies(...ComposerStrategy::cases()) // ComposerStrategy::LATEST, ComposerStrategy::LOCKED, ComposerStrategy::LOWEST
    ->operatingSystems(...OperatingSystem::cases()) // OperatingSystem::UBUNTU, OperatingSystem::MACOS, OperatingSystem::WINDOWS
    ->phpVersions(...PhpVersion::cases()) // PhpVersion::PHP_54 - PhpVersion::PHP_84
    ->tools(...Tool::cases()) // Tool::Infection, Tool::PHPUnit, Tool::Psalm
    ->skip(OperatingSystem::WINDOWS) // Skip one or more: Composer Strategy, Operating System, PHP Version, or Tool 
;

测试

composer test

变更日志

有关最近更改的更多信息,请参阅 CHANGELOG.md

安全

如果您发现任何安全相关的问题,请通过电子邮件 nathanael.esayeas@protonmail.com 而不是使用问题跟踪器。

赞助商

[成为 GitHub 赞助商]

鸣谢

许可证

BSD-3-Clause 许可证。有关更多信息,请参阅 许可证文件