Git Product home page Git Product logo

annotate-pull-request-from-checkstyle's Introduction

Annotate a Pull Request based on a Checkstyle XML-report

Turns checkstyle based XML-Reports into Github Pull Request Annotations via the Checks API. This script is meant for use within your GithubAction.

That means you no longer search thru your GithubAction logfiles. No need to interpret messages which are formatted differently with every tool. Instead you can focus on your Pull Request, and you don't need to leave the Pull Request area.

Logs Example

Context Example Images from https://github.com/mheap/phpunit-github-actions-printer

Installation

Install the binary via composer

composer require staabm/annotate-pull-request-from-checkstyle

Example Usage

Run one of the following commands within your GithubAction workflow:

Process a checkstyle formated file

vendor/bin/cs2pr /path/to/checkstyle-report.xml

Pipe the output of another commmand

Using PHPStan

phpstan analyse --error-format=checkstyle | vendor/bin/cs2pr

Using Psalm

psalm --output-format=checkstyle | vendor/bin/cs2pr`

Using PHP Coding Standards Fixer

php-cs-fixer --format=checkstyle | vendor/bin/cs2pr

... works for any command which produces a checkstyle-formatted report.

Example GithubAction workflow

# ...

jobs:
    phpstan-analysis:
      name: phpstan static code analysis
      runs-on: ubuntu-latest
      steps:
          - uses: actions/checkout@v2
          - name: Setup PHP
            uses: shivammathur/setup-php@v1
            with:
                php-version: 7.3
                coverage: none # disable xdebug, pcov
          - run: |
                composer install # install your apps dependencies
                composer require staabm/annotate-pull-request-from-checkstyle # install cs2pr
                vendor/bin/phpstan analyse --error-format=checkstyle | vendor/bin/cs2pr

Idea

This script is based on a suggestion of Benjamin Eberlei

The Code is inspired by https://github.com/mheap/phpunit-github-actions-printer

annotate-pull-request-from-checkstyle's People

Contributors

staabm avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.