ludofleury/github-annotation-path-mapper

从 GitHub Action 工作流程命令中前缀 GitHub 注解文件位置

v1.1.0 2020-12-01 20:11 UTC

This package is auto-updated.

Last update: 2024-08-29 05:37:14 UTC


README

ci Latest Stable Version Total Downloads License

Github 注解路径映射器

TL;DR:基本上在 PHP 中使用 | sed "",如果发生替换,则使用 sigterm 2。

从 GitHub Action 工作流程命令中前缀 GitHub 注解文件位置。

通常,如果您在 Docker 容器中运行 GitHub Action,并且目录结构不匹配您的 Git 仓库。

为 PHP 项目的 PHP 编写。

示例用例

  • git 仓库基本路径:backend/src/
  • docker 基本路径:src

考虑一个这样的 git 仓库

  • .git/
  • frontend/
  • backend/composer.json
  • backend/src/File1.php
  • backend/src/File2.php
  • backend/vendors/*
  • backend/tests/*

如果您在这种类型的 Docker 容器中运行 phpstan,则 STDOUT 将为 src/File1.php,GitHub 注解将无法匹配路径。

docker run --volume backend/:/app php /app/vendors/bin/phpstan analyse --error-format=github

# ::error file=src/File1.php,line=10,col=15::Something went wrong

⛑️ 但通过将管道传递到这个小巧的库,将调整 STDOUTbackend/src/File1.php

phpstan analyse --error-format=github | vendor/bin/github-annotation-mappe backend/

::error file=backend/src/File1.php,line=10,col=15::Something went wrong

然后 GitHub 注解最终将出现在您的 PR 中的代码中! 带有注解的 GitHub pull request

设置

$ composer require --dev ludofleury/github-annotation-path-mapper

或 git clone,复制粘贴,随便。

用法

简单地将其传递给 bin 映射器

$ my-command-to-run | vendor/bin/github-annotation-mapper [path prefix with trailling slash]