{"id":21823525,"url":"https://github.com/jbzoo/ci-report-converter","last_synced_at":"2025-04-06T03:10:40.532Z","repository":{"id":38182656,"uuid":"361559511","full_name":"JBZoo/CI-Report-Converter","owner":"JBZoo","description":"The tool converts different error reporting standards for deep compatibility with popular CI systems (TeamCity, IntelliJ IDEA, GitHub Actions, etc).","archived":false,"fork":false,"pushed_at":"2024-11-06T18:18:41.000Z","size":2474,"stargazers_count":29,"open_issues_count":3,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-30T02:08:25.545Z","etag":null,"topics":["actions","checkstyle","ci","codestyle","github","inspections","jbzoo","junit","phan","phpcs","phpstan","phpstorm","psalm","report","teamcity","test","testing"],"latest_commit_sha":null,"homepage":"https://github.com/JBZoo","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JBZoo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-04-25T23:13:45.000Z","updated_at":"2025-01-07T16:53:46.000Z","dependencies_parsed_at":"2024-01-27T22:28:19.989Z","dependency_job_id":"0849b21c-cc5c-4904-bf88-45157968fc90","html_url":"https://github.com/JBZoo/CI-Report-Converter","commit_stats":{"total_commits":65,"total_committers":2,"mean_commits":32.5,"dds":"0.32307692307692304","last_synced_commit":"5f4dc8957bbbb690e59e66fd631f63cf31ef141d"},"previous_names":[],"tags_count":25,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JBZoo%2FCI-Report-Converter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JBZoo%2FCI-Report-Converter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JBZoo%2FCI-Report-Converter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JBZoo%2FCI-Report-Converter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JBZoo","download_url":"https://codeload.github.com/JBZoo/CI-Report-Converter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247427006,"owners_count":20937201,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["actions","checkstyle","ci","codestyle","github","inspections","jbzoo","junit","phan","phpcs","phpstan","phpstorm","psalm","report","teamcity","test","testing"],"created_at":"2024-11-27T17:33:12.226Z","updated_at":"2025-04-06T03:10:40.512Z","avatar_url":"https://github.com/JBZoo.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# JBZoo / CI-Report-Converter\n\n[![CI](https://github.com/JBZoo/CI-Report-Converter/actions/workflows/main.yml/badge.svg?branch=master)](https://github.com/JBZoo/CI-Report-Converter/actions/workflows/main.yml?query=branch%3Amaster)    [![Coverage Status](https://coveralls.io/repos/github/JBZoo/CI-Report-Converter/badge.svg?branch=master)](https://coveralls.io/github/JBZoo/CI-Report-Converter?branch=master)    [![Psalm Coverage](https://shepherd.dev/github/JBZoo/CI-Report-Converter/coverage.svg)](https://shepherd.dev/github/JBZoo/CI-Report-Converter)    [![Psalm Level](https://shepherd.dev/github/JBZoo/CI-Report-Converter/level.svg)](https://shepherd.dev/github/JBZoo/CI-Report-Converter)    [![CodeFactor](https://www.codefactor.io/repository/github/jbzoo/ci-report-converter/badge)](https://www.codefactor.io/repository/github/jbzoo/ci-report-converter/issues)    \n[![Stable Version](https://poser.pugx.org/jbzoo/ci-report-converter/version)](https://packagist.org/packages/jbzoo/ci-report-converter/)    [![Total Downloads](https://poser.pugx.org/jbzoo/ci-report-converter/downloads)](https://packagist.org/packages/jbzoo/ci-report-converter/stats)    [![Docker Pulls](https://img.shields.io/docker/pulls/jbzoo/ci-report-converter.svg)](https://hub.docker.com/r/jbzoo/ci-report-converter)    [![Dependents](https://poser.pugx.org/jbzoo/ci-report-converter/dependents)](https://packagist.org/packages/jbzoo/ci-report-converter/dependents?order_by=downloads)    [![GitHub License](https://img.shields.io/github/license/jbzoo/ci-report-converter)](https://github.com/JBZoo/CI-Report-Converter/blob/master/LICENSE)\n\n\n\u003c!--ts--\u003e\n   * [Why?](#why)\n   * [Installing](#installing)\n   * [Using as GitHub Action](#using-as-github-action)\n      * [Example GitHub Action workflow](#example-github-action-workflow)\n   * [Available Directions](#available-directions)\n   * [Help description in terminal](#help-description-in-terminal)\n      * [Converting](#converting)\n      * [Custom Metrics in TeamCity](#custom-metrics-in-teamcity)\n   * [Examples](#examples)\n      * [JetBrains IDE (IntelliJ IDEA, PhpStorm, WebStorm, etc)](#jetbrains-ide-intellij-idea-phpstorm-webstorm-etc)\n         * [Mess Detector (phpmd-json)](#mess-detector-phpmd-json)\n         * [Magic Number Detector (phpmnd)](#magic-number-detector-phpmnd)\n         * [Copy/Paste Detector (pmd-cpd)](#copypaste-detector-pmd-cpd)\n         * [PHPStan (checkstyle)](#phpstan-checkstyle)\n         * [Psalm (psalm-json)](#psalm-psalm-json)\n         * [Phan (checkstyle)](#phan-checkstyle)\n      * [TeamCity - Style Issue As Failed Unit test](#teamcity---style-issue-as-failed-unit-test)\n      * [TeamCity - Style Issue As Code Inspections](#teamcity---style-issue-as-code-inspections)\n      * [TeamCity - Reported Statistic Values](#teamcity---reported-statistic-values)\n      * [GitHub Actions](#github-actions)\n      * [GitLab CI](#gitlab-ci)\n      * [Use tool as SDK to generate reports](#use-tool-as-sdk-to-generate-reports)\n         * [JUnit.xml (API)](#junitxml-api)\n         * [GitHub Actions (API)](#github-actions-api)\n   * [Contributing](#contributing)\n   * [License](#license)\n   * [See Also](#see-also)\n\u003c!--te--\u003e\n\n\n## Why?\n\nI believe you are familiar with the huge zoo of various utilities for testing, checking code standards, linters etc.\nIt's really often the output of utilities is not supported in popular CI systems (TeamCity, GitHub, etc...).\nI guess you are lucky if the utility saves the error report in the `junit.xml` format, because it works pretty fine with almost all modern dev software.\n\nBut... My experience tells me it's the exception rather than the rule.\nFor example, I really like the good old [phpmd](https://github.com/phpmd/phpmd) utility (perhaps you have another _right_ opinion about the benefits. At least, it's just an example).\nIt doesn't integrate well with TeamCity/PhpStorm/GitHub. Everytime I spend a lot of time looking for results in the logs. Though I really want to see instant and well-printed error report.\n\nTherefore, I developed a converter that changes the report format for deep integration with CI systems and JetBrain IDEs.\n\nWell... It may seem to you it's a useless thing, and _your favorite super tool_ works fine in TeamCity/PhpStorm. Just take a look at [the examples below](#examples).\n\n\n\n## Installing\n\n```shell\ncomposer require jbzoo/ci-report-converter\nphp ./vendor/bin/ci-report-converter --help\n\n# OR use phar file\nwget https://github.com/JBZoo/CI-Report-Converter/releases/latest/download/ci-report-converter.phar\nchmod +x ./ci-report-converter.phar\n./ci-report-converter.phar --help\n\n# OR just pull the Docker Image\ndocker run --rm jbzoo/ci-report-converter --help\n```\n\n\n\n## Using as GitHub Action\n\nAction allows you to convert error reports to the [GitHub Annotations format](https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-a-warning-message)\n * See [demo of error output](https://github.com/JBZoo/CI-Report-Converter/actions/workflows/gh-action.yml?query=is%3Asuccess)\n * To learn more [see different examples](.github/workflows/gh-action.yml)\n\n```yaml\n- uses: jbzoo/ci-report-converter@master # or see the specific version on releases page\n  with:\n    # File path with the original report format. If not set or empty, then the STDIN is used.\n    # Required: true\n    input-file: ./build/checkstyle.xml\n\n    # Source format. Available options: checkstyle, junit, phpmd-json, phpmnd, pmd-cpd, psalm-json\n    # Default value: checkstyle\n    # Required: true\n    input-format: checkstyle\n\n    # Will exit with the code=1, if any violations are found.\n    # Default value: no\n    non-zero-code: yes\n\n    # File path with the result report format. If not set or empty, then the STDOUT is used.\n    output-file: ./build/junit.xml\n\n    # Target format. Available options: gitlab-json, github-cli, junit, plain, tc-inspections, tc-tests\n    # Default value: github-cli\n    # Required: true\n    output-format: junit\n\n    # If option is set, all absolute file paths will be converted to relative once.\n    # Default value: .\n    root-path: ./custom/project/path\n\n    # Set custom name of root group/suite (if it's possible).\n    # Required: true\n    suite-name: My Tests\n\n```\n\n### Example GitHub Action workflow\n```yml\nname: Linters\n\non:\n  pull_request:\n    branches:\n      - \"*\"\n\njobs:\n  linters:\n    name: PHPcs\n    runs-on: ubuntu-latest\n    steps:\n      - name: Checkout Code\n        uses: actions/checkout@v2\n\n      - name: PHP Code Sniffer\n        run: ./vendor/bin/phpcs --report=checkstyle --standard=PSR12 -q ./src \u003e ./build/phpcs-checkstyle.xml\n\n      - name: Converting checkstyle.xml to Github Annotations\n        uses: jbzoo/ci-report-converter@master\n        with:\n          input-file: build/phpcs-checkstyle.xml\n\n```\n\n\n## Available Directions\n\n```mermaid\ngraph LR;\n    checkstyle_src(\"CheckStyle.xml\");\n    ci-report-converter((\"CI-Report\u003cbr\u003eConverter\"));\n    github-cli_target(\"GitHub Actions - CLI\");\n    gitlab-json_target(\"GitLab - JSON\");\n    junit_src(\"JUnit.xml\");\n    junit_target(\"JUnit.xml\");\n    phpmd-json_src(\"PHPmd.json\");\n    phpmnd_src(\"PHPmnd.xml\");\n    plain_target(\"Plain Text\");\n    pmd-cpd_src(\"PmdCpd.xml\");\n    psalm-json_src(\"Psalm.json\");\n    tc-inspections_target(\"TeamCity - Inspections\");\n    tc-tests_target(\"TeamCity - Tests\");\n\n    checkstyle_src ==\u003e ci-report-converter;\n    ci-report-converter ==\u003e github-cli_target;\n    ci-report-converter ==\u003e gitlab-json_target;\n    ci-report-converter ==\u003e junit_target;\n    ci-report-converter ==\u003e plain_target;\n    ci-report-converter ==\u003e tc-inspections_target;\n    ci-report-converter ==\u003e tc-tests_target;\n    junit_src ==\u003e ci-report-converter;\n    phpmd-json_src ==\u003e ci-report-converter;\n    phpmnd_src ==\u003e ci-report-converter;\n    pmd-cpd_src ==\u003e ci-report-converter;\n    psalm-json_src ==\u003e ci-report-converter;\n\nlinkStyle default interpolate basis;\n```\n\n\nAt the moment, converting of reports works with\n  * Input Formats:\n    * [checkstyle](tests/fixtures/origin/phpcs/codestyle.xml) - the most popular sort of error report. It works for [Phan](https://github.com/phan/phan), [PHPcs](https://github.com/squizlabs/PHP_CodeSniffer) and others.\n    * [junit](tests/fixtures/origin/phpunit/junit-simple.xml) - also it's really popular sort of error report. Usually, the format is used to display unit test results.\n    * [phpmd-json](tests/fixtures/origin/phpmd/json.json) - the most detailed report of [PHPMD](https://github.com/phpmd/phpmd).\n    * [phpmnd](tests/fixtures/origin/phpmnd/phpmnd.xml) - I know only [PHP Magic Numbers Detector](https://github.com/povils/phpmnd).\n    * [psalm-json](tests/fixtures/origin/psalm/json.json) - the most detailed report of [Psalm](https://github.com/vimeo/psalm).\n    * [pmd-cpd](tests/fixtures/origin/phpcpd/pmd-cpd.xml) - it's PMD-CPD XML format. An example of tool is [Copy/Paste Detector](https://github.com/sebastianbergmann/phpcpd).\n  * Output Formats:\n    * [gitlab-json](tests/fixtures/origin/phpstan/gitlab.json) - [GitLab Custom Report](https://docs.gitlab.com/ee/user/project/merge_requests/code_quality.html#implementing-a-custom-tool).\n    * [junit](tests/fixtures/origin/phpunit/junit-simple.xml) - The most popular sort of reporting.\n    * [tc-tests](tests/fixtures/test-cases/ConverterTeamCityTest/testJUnit.txt) - [Reporting Tests in TeamCity/PhpStorm/JetBrains](https://www.jetbrains.com/help/teamcity/service-messages.html#Reporting+Tests).\n    * [tc-inspections](tests/fixtures/test-cases/ConverterTeamCityInspectionsTest) - [Reporting Inspections in TeamCity](https://www.jetbrains.com/help/teamcity/service-messages.html#Reporting+Inspections).\n\n\nAlso, you can follow [metrics around your code in TeamCity](https://www.jetbrains.com/help/teamcity/service-messages.html#Reporting+Build+Statistics) via `teamcity:stats`\n * [JUnit.xml](tests/fixtures/origin/phpunit/junit-nested.xml) =\u003e [Example in TeamCity](tests/fixtures/test-cases/ConverterTeamCityStatsTest/testJUnitXml.txt)\n * [PHPUnitClover.xml](tests/fixtures/origin/phpunit/clover.xml) =\u003e [Example in TeamCity](tests/fixtures/test-cases/ConverterTeamCityStatsTest/testPhpUnitCloverXml.txt)\n * [PHPDepend.xml](tests/fixtures/origin/pdepend/pdepend-old.xml) =\u003e [Example in TeamCity](tests/fixtures/test-cases/ConverterTeamCityStatsTest/testPhpDependXml.txt)\n * [PHPloc.json](tests/fixtures/origin/phploc/json.json) =\u003e [Example in TeamCity](tests/fixtures/test-cases/ConverterTeamCityStatsTest/testPhpLocJson.txt)\n * [PHPMetrics.xml](tests/fixtures/origin/phpmetrics/phpmetrics.xml) =\u003e [Example in TeamCity](tests/fixtures/test-cases/ConverterTeamCityStatsTest/testPhpMetricsXml.txt)\n\n\n## Help description in terminal\n\n### Converting\n\n```\n$ php ./vendor/bin/ci-report-converter convert --help\nDescription:\n  Convert one report format to another one\n\nUsage:\n  convert [options]\n\nOptions:\n  -S, --input-format=INPUT-FORMAT      Source format. Available options: checkstyle, junit, phpmd-json, phpmnd, pmd-cpd, psalm-json [default: \"checkstyle\"]\n  -I, --input-file[=INPUT-FILE]        File path with the original report format. If not set or empty, then the STDIN is used.\n  -T, --output-format=OUTPUT-FORMAT    Target format. Available options: gitlab-json, github-cli, junit, plain, tc-inspections, tc-tests [default: \"tc-tests\"]\n  -O, --output-file[=OUTPUT-FILE]      File path with the result report format. If not set or empty, then the STDOUT is used.\n  -R, --root-path[=ROOT-PATH]          If option is set, all absolute file paths will be converted to relative once. [default: \".\"]\n  -N, --suite-name=SUITE-NAME          Set custom name of root group/suite (if it's possible).\n  -F, --tc-flow-id[=TC-FLOW-ID]        Custom flowId in TeamCity output. Default value is PID of the tool.\n  -Q, --non-zero-code[=NON-ZERO-CODE]  Will exit with the code=1, if any violations are found. [default: \"no\"]\n      --no-progress                    Disable progress bar animation for logs. It will be used only for text output format.\n      --mute-errors                    Mute any sort of errors. So exit code will be always \"0\" (if it's possible).\n                                       It has major priority then --non-zero-on-error. It's on your own risk!\n      --stdout-only                    For any errors messages application will use StdOut instead of StdErr. It's on your own risk!\n      --non-zero-on-error              None-zero exit code on any StdErr message.\n      --timestamp                      Show timestamp at the beginning of each message.It will be used only for text output format.\n      --profile                        Display timing and memory usage information.\n      --output-mode=OUTPUT-MODE        Output format. Available options:\n                                       text - Default text output format, userfriendly and easy to read.\n                                       cron - Shortcut for crontab. It's basically focused on human-readable logs output.\n                                       It's combination of --timestamp --profile --stdout-only --no-progress -vv.\n                                       logstash - Logstash output format, for integration with ELK stack.\n                                        [default: \"text\"]\n      --cron                           Alias for --output-mode=cron. Deprecated!\n  -h, --help                           Display help for the given command. When no command is given display help for the list command\n  -q, --quiet                          Do not output any message\n  -V, --version                        Display this application version\n      --ansi|--no-ansi                 Force (or disable --no-ansi) ANSI output\n  -n, --no-interaction                 Do not ask any interactive question\n  -v|vv|vvv, --verbose                 Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug\n\n```\n\n\n\n### Custom Metrics in TeamCity\n\nTo clarify the use of the method, take a look at the [examples and screenshots](#teamcity---reported-statistic-values) below, please.\n\n```\n$ php ./vendor/bin/ci-report-converter teamcity:stats --help\nDescription:\n  Push code metrics to TeamCity Stats\n\nUsage:\n  teamcity:stats [options]\n\nOptions:\n  -S, --input-format=INPUT-FORMAT  Source format. Available options: junit-xml, pdepend-xml, phploc-json, phpmetrics-xml, phpunit-clover-xml\n  -I, --input-file[=INPUT-FILE]    File path with the original report format. If not set or empty, then the STDIN is used.\n  -O, --output-file[=OUTPUT-FILE]  File path with the result report format. If not set or empty, then the STDOUT is used.\n  -R, --root-path[=ROOT-PATH]      If option is set, all absolute file paths will be converted to relative once. [default: \".\"]\n  -F, --tc-flow-id[=TC-FLOW-ID]    Custom flowId in TeamCity output. Default value is PID of the tool.\n      --no-progress                Disable progress bar animation for logs. It will be used only for text output format.\n      --mute-errors                Mute any sort of errors. So exit code will be always \"0\" (if it's possible).\n                                   It has major priority then --non-zero-on-error. It's on your own risk!\n      --stdout-only                For any errors messages application will use StdOut instead of StdErr. It's on your own risk!\n      --non-zero-on-error          None-zero exit code on any StdErr message.\n      --timestamp                  Show timestamp at the beginning of each message.It will be used only for text output format.\n      --profile                    Display timing and memory usage information.\n      --output-mode=OUTPUT-MODE    Output format. Available options:\n                                   text - Default text output format, userfriendly and easy to read.\n                                   cron - Shortcut for crontab. It's basically focused on human-readable logs output.\n                                   It's combination of --timestamp --profile --stdout-only --no-progress -vv.\n                                   logstash - Logstash output format, for integration with ELK stack.\n                                    [default: \"text\"]\n      --cron                       Alias for --output-mode=cron. Deprecated!\n  -h, --help                       Display help for the given command. When no command is given display help for the list command\n  -q, --quiet                      Do not output any message\n  -V, --version                    Display this application version\n      --ansi|--no-ansi             Force (or disable --no-ansi) ANSI output\n  -n, --no-interaction             Do not ask any interactive question\n  -v|vv|vvv, --verbose             Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug\n\n```\n\n\n\n## Examples\n\n### JetBrains IDE (IntelliJ IDEA, PhpStorm, WebStorm, etc)\n\nOne of the unique features of the tool is converting reports to a unit test format compatible with JetBrains IDE and TeamCity.\nThe following examples show how to use JetBrains IDE UI to display any kind of style issues.\nYeah, I know that the integration is not the cleanest, and it's not super beautiful. However, this code/screenshots demonstrate the usability of the approach.\n\n![PHPcs in JetBrains PhpStorm](.github/assets/phpstorm-checkstyle.png)\n\n**NOTE:** I believe that coding style issues have the same level of severity as any other sort of errors.\nTherefore, I prefer to use the same workflow to check the quality of the code as I do with regular PHPUnit tests. It's like \"just one click!\"\nAlso, you will have the awesome bonus - navigating the project and gives the most detailed information about errors.\n\n**The general idea is pretty simple:**\n - We take almost any utility for testing.\n - It saves report in the file or outputs error to StdOut as xml/json.\n - CI-Report-Converter changes the report format. It saves result somewhere or just outputs it in StdOut.\n - ???\n - Profit.\n\nIn the next example we will see how to integrate JetBrains IDE UI with Code Sniffer deeply. I use PHPcs just as example. This is the most popular linter in PHP.\nHowever, the approach is independent of the programming language or unit testing framework.\n\n```php\n\u003c?php declare(strict_types=1);\n\nuse PHPUnit\\Framework\\Assert;\nuse PHPUnit\\Framework\\TestCase;\n\n/**\n * Here's an example based on PHPUnit and PhpStorm, but you are not limited to PHP language.\n * This is just an example to show the idea.\n * So you can use any sort language to integrate style tests with JetBrains IDE.\n */\nclass CheckStyleExamplesTest extends TestCase\n{\n    /**\n     * The short example which uses pipe as way to pass error report.\n     */\n    public function testPipelineWay(): void\n    {\n        echo shell_exec(                       # Execute command via shell and return the complete output as a string.\n            'php ./vendor/bin/phpcs' .         # Path to bin of third-party tool (PHP Code Sniffer is just example).\n            ' --report=checkstyle' .           # Output format of PHPcs. ci-report-converter expects it by default as `--input-format` option.\n            ' --standard=PSR12 -q ./src' .     # The custom tool options. For phpcs `-q` is important!\n            ' | ' .                            # The pipe operator, it passes the output of one command as input to another. See https://en.wikipedia.org/wiki/Pipeline_(Unix)\n            ' ./ci-report-converter.phar'      # The converter does all the magic. Look at help description ( --help) to lean more about options and default values.\n        );\n\n        # Usually PHPUnit expects at least one assert in a test.\n        # Otherwise, it may show useless warning messages. It depends on PHPUnit version and your configurations.\n        # So, just in case, we make a fake assertion.\n        Assert::assertTrue(true);\n    }\n\n    /**\n     * The super detailed example which uses files as way to pass error report.\n     */\n    public function testXmlFileWay(): void\n    {\n        shell_exec(                                     # Execute command via shell and return the complete output as a string.\n            'php ./vendor/bin/phpcs' .                  # Path to bin of third-party tool (PHP Code Sniffer is just example).\n            ' --report=checkstyle' .                    # Output format of PHPcs. CI-Report-Converter expects it by default as `--input-format` option.\n            ' --report-file=./build/phpcs-report.xml' . # Save result of phpcs work in XML file in \"checkstyle\" format.\n            ' --standard=PSR12 -q ./src' .              # The custom tool options. For phpcs `-q` is important!\n            ' || true \u003e /dev/null'                      # We don't expect any output of phpcs and ignore error exit codes.\n                                                        # Lol, we are very self-confident. Actually, we need only XML file, that's it.\n        );\n\n        // I've shown all the options explicitly just to add transparency.\n        // In fact, this example does the same thing as the code above in `testPipelineWay()`.\n        echo shell_exec(\n            './ci-report-converter.phar' .              # The path to bin file of CI-Report-Converter. It depends of your installation way. See above.\n            ' --input-format=checkstyle' .              # Source reporting format. Default value is \"checkstyle\".\n            ' --input-file=./build/phpcs-report.xml' .  # Using prepared file on previous step as source.\n            ' --output-format=tc-tests' .               # Target reporting format. Default value is \"tc-tests\".\n            ' --suite-name=PHPcs' .                     # Define the name of group. See screenshot below.\n            ' --root-path=`pwd`'                        # Specify the project path for pretty printing paths in UI. Default value is `.` (current dir).\n        );\n\n        # The same reason like in `testPipelineWay()`.\n        Assert::assertTrue(true);\n    }\n}\n\n```\n\nWhat happens under the hood. Also, see source file [as ready-to-use examples](tests/examples/CheckStyleExamples.php).\n\n```shell\ncd  ~/your/project/root/directory\nphp ./vendor/bin/phpunit ./tests/examples/CheckStyleExamples.php --teamcity\n\n# or\nphp ./vendor/bin/phpcs --report=checkstyle --standard=PSR12 -q ./src | ./ci-report-converter.phar\n```\n\n\n\n#### Mess Detector (phpmd-json)\n\n\u003cdetails\u003e\n  \u003csummary\u003eScreenshot\u003c/summary\u003e\n\n  ![PHPmd in JetBrains PhpStorm](.github/assets/phpstorm-phpmd.png)\n\n\u003c/details\u003e\n\n```shell\nphp ./vendor/bin/phpmd ./src json cleancode | ./ci-report-converter.phar -Sphpmd-json\n```\n\n\n\n#### Magic Number Detector (phpmnd)\n\n\u003cdetails\u003e\n  \u003csummary\u003eScreenshot\u003c/summary\u003e\n\n  ![PHPmd in JetBrains PhpStorm](.github/assets/phpstorm-phpmnd.png)\n\n\u003c/details\u003e\n\n```shell\nphp ./vendor/bin/phpmnd ./src --hint --quiet --xml-output=./build/phpmnd-report.xml\n./ci-report-converter.phar --root-path=./src --input-file=./build/phpmnd-report.xml --input-format=phpmnd\n```\n\n\n\n#### Copy/Paste Detector (pmd-cpd)\n\n\u003cdetails\u003e\n  \u003csummary\u003eScreenshot\u003c/summary\u003e\n\n  ![PHPcpd in JetBrains PhpStorm](.github/assets/phpstorm-phpcpd.png)\n\n\u003c/details\u003e\n\n```shell\nphp ./vendor/bin/phpcpd ./src --log-pmd=./build/phpcpd-report.xml\n./ci-report-converter.phar --input-file=./build/phpcpd-report.xml --input-format=pmd-cpd\n```\n\n\n\n#### PHPStan (checkstyle)\n\n\u003cdetails\u003e\n  \u003csummary\u003eScreenshot\u003c/summary\u003e\n\n  ![PHPstan in JetBrains PhpStorm](.github/assets/phpstorm-phpstan.png)\n\n\u003c/details\u003e\n\n```shell\nphp ./vendor/bin/phpstan analyse --error-format=checkstyle --no-progress ./src | ./ci-report-converter.phar\n```\n\n\n\n#### Psalm (psalm-json)\n\n\u003cdetails\u003e\n  \u003csummary\u003eScreenshot\u003c/summary\u003e\n\n  ![PHP Psalm in JetBrains PhpStorm](.github/assets/phpstorm-psalm.png)\n\n\u003c/details\u003e\n\n```shell\nphp ./vendor/bin/psalm --output-format=json | ./ci-report-converter.phar --input-format=\"psalm-json\"\n```\n\n\n#### Phan (checkstyle)\n\n\u003cdetails\u003e\n  \u003csummary\u003eScreenshot\u003c/summary\u003e\n\n  ![PHP Psalm in JetBrains PhpStorm](.github/assets/phpstorm-phan.png)\n\n\u003c/details\u003e\n\n```shell\nphp ./vendor/bin/phan.phar --directory=./src --output-mode=checkstyle |  ./ci-report-converter.phar\n```\n\n### TeamCity - Style Issue As Failed Unit test\n\nUse the option `--output-format=tc-tests` to convert any style report to unit test format in TeamCity\n\n![Style issues as failed tests in TeamCity](.github/assets/teamcity-as-failed-test.png)\n\n\n\n### TeamCity - Style Issue As Code Inspections\n\nUse the option `--output-format=tc-inspections` to convert any style report to unit test format in TeamCity\n\n![Style Issue As Code Inspections in TeamCity](.github/assets/teamcity-as-code-inspections.png)\n\n\n\n### TeamCity - Reported Statistic Values\n\n[PHPDepend.xml](tests/fixtures/origin/pdepend/pdepend-old.xml) =\u003e [Example in TeamCity](tests/fixtures/test-cases/ConverterTeamCityStatsTest/testPhpDependXml.txt)\n```shell\n./vendor/bin/pdepend.phar --summary-xml=\"./build/pdepend-summary.xml\" --quiet ./src\n./ci-report-converter.phar teamcity:stats --input-format=\"pdepend-xml\" --input-file=\"./build/pdepend-summary.xml\"\n```\n\n\n[PHPloc.json](tests/fixtures/origin/phploc/json.json) =\u003e [Example in TeamCity](tests/fixtures/test-cases/ConverterTeamCityStatsTest/testPhpLocJson.txt)\n\n```shell\n./vendor/bin/phploc ./src --log-json=\"./build/phploc.json\" --quiet\n./ci-report-converter.phar teamcity:stats --input-format=\"phploc-json\" --input-file=\"./build/phploc.json\"\n```\n\n\n[PHPUnitClover.xml](tests/fixtures/origin/phpunit/clover.xml) =\u003e [Example in TeamCity](tests/fixtures/test-cases/ConverterTeamCityStatsTest/testPhpUnitCloverXml.txt)\n\n```shell\n./vendor/bin/phpunit --coverage-clover ./build/phpunit-report.xml\n./ci-report-converter.phar teamcity:stats --input-format=\"phpunit-clover-xml\" --input-file=\"./build/phpunit-report.xml\"\n```\n\n\n[JUnit.xml](tests/fixtures/origin/phpunit/junit-nested.xml) =\u003e [Example in TeamCity](tests/fixtures/test-cases/ConverterTeamCityStatsTest/testJUnitXml.txt)\n\n```shell\n./vendor/bin/phpunit --coverage-xml ./build/phpunit-junit.xml\n./ci-report-converter.phar teamcity:stats --input-format=\"junit-xml\" --input-file=\"./build/phpunit-junit.xml\"\n``````\n\n\n[PHPMetrics.xml](tests/fixtures/origin/phpmetrics/phpmetrics.xml) =\u003e [Example in TeamCity](tests/fixtures/test-cases/ConverterTeamCityStatsTest/testPhpMetricsXml.txt)\n\n```shell\n./vendor/bin/phpmetrics  ./src --report-violations=\"./build/phpmetrics-report.xml\"\n./ci-report-converter.phar teamcity:stats --input-format=\"phpmetrics-xml\" --input-file=\"./build/phpmetrics-report.xml\"\n``````\n\n![Style issues as failed tests in TeamCity](.github/assets/teamcity-reported-statistic-values.png)\n\n\n\n### GitHub Actions\n\nYou can find a lot of [life examples here](https://github.com/JBZoo/CI-Report-Converter/actions/workflows/gh-action.yml?query=is%3Asuccess+branch%3Amaster) and see [real examples in YML file](.github/workflows/gh-action.yml)\n\n![GitHub Actions 1](.github/assets/github-actions-1.png)\n\n![GitHub Actions 1](.github/assets/github-actions-2.png)\n\n\n\n### GitLab CI\n\nUse the option `--output-format=gitlab-json` to convert the report to Gitlab JSON format.\n\nAls, see [how to implemente GitLab Custom Report](https://docs.gitlab.com/ee/user/project/merge_requests/code_quality.html#implementing-a-custom-tool)\n\n![GitLab Code Quality Report](.github/assets/gitlab-code-quality-report.png)\n\n\n\n### Use tool as SDK to generate reports\n\nAlso, you can use source of tool as SDK for reports in your tools/project.\n\nPS: More examples are coming soon.\n\n\n#### JUnit.xml (API)\n\n```php\nuse JBZoo\\CIReportConverter\\Converters\\JUnitConverter;\nuse JBZoo\\CIReportConverter\\Formats\\Source\\SourceCaseOutput;\nuse JBZoo\\CIReportConverter\\Formats\\Source\\SourceSuite;\n\n$class = \\JBZoo\\PHPUnit\\ExampleTest::class;\n$className = str_replace('\\\\', '.', $class);\n$filename = './tests/ExampleTest.php';\n$line = 28;\n\n$suite = new SourceSuite('Suite');\n$case = $suite-\u003eaddTestCase('Test Name');\n$case-\u003etime = 0.001824;\n$case-\u003efile = $filename;\n$case-\u003eline = $line;\n$case-\u003eclass = $class;\n$case-\u003eclassname = $className;\n$case-\u003eassertions = 5;\n$case-\u003estdOut = 'Some std output';\n$case-\u003eerrOut = 'Some err output';\n$case-\u003efailure = new SourceCaseOutput('Failure', 'Failure Message', 'Failure Details');\n$case-\u003eerror = new SourceCaseOutput('Error', 'Error Message', 'Error Details');\n$case-\u003ewarning = new SourceCaseOutput('Warning', 'Warning Message', 'Warning Details');\n$case-\u003eskipped = new SourceCaseOutput('Skipped', 'Skipped Message', 'Skipped Details');\n\necho (new JUnitConverter())-\u003efromInternal($suite);\n```\n\n```xml\n\u003c?xml version=\"1.0\" encoding=\"UTF-8\"?\u003e\n\u003ctestsuites\u003e\n  \u003ctestsuite name=\"Suite\" tests=\"1\" assertions=\"5\" errors=\"1\" warnings=\"1\" failures=\"1\" skipped=\"1\" time=\"0.001824\"\u003e\n    \u003ctestcase name=\"Test Name\" class=\"JBZoo\\PHPUnit\\ExampleTest\" classname=\"JBZoo.PHPUnit.ExampleTest\" file=\"./tests/ExampleTest.php\" line=\"28\" assertions=\"5\" time=\"0.001824\"\u003e\n      \u003cfailure type=\"Failure\" message=\"Failure Message\"\u003eFailure Details\u003c/failure\u003e\n      \u003cwarning type=\"Warning\" message=\"Warning Message\"\u003eWarning Details\u003c/warning\u003e\n      \u003cerror type=\"Error\" message=\"Error Message\"\u003eError Details\u003c/error\u003e\n      \u003csystem-out\u003eSome std output\nSome err output\u003c/system-out\u003e\n      \u003cskipped/\u003e\n    \u003c/testcase\u003e\n  \u003c/testsuite\u003e\n\u003c/testsuites\u003e\n```\n\n\n\n#### GitHub Actions (API)\n\n```php\nuse JBZoo\\CIReportConverter\\Formats\\GithubActions\\GithubActions;\n\n$ghActions = new GithubActions();\n$case0 = $ghActions-\u003eaddCase('src/Root.php');\n$case0-\u003eline = 789;\n$case0-\u003ecolumn = null;\n$case0-\u003emessage = 'Something went wrong #0';\n\n$suite1 = $ghActions-\u003eaddSuite('src/File.php');\n$case1 = $suite1-\u003eaddCase('src/Class.php');\n$case1-\u003eline = 123;\n$case1-\u003ecolumn = 4;\n$case1-\u003emessage = 'Something went wrong #1';\n\necho $ghActions-\u003e__toString();\n```\n\n```\n::error file=src/Root.php,line=789::Something went wrong #0\n\n::group::src/File.php\n::error file=src/Class.php,line=123,col=4::Something went wrong #1\n::endgroup::\n```\n\n\n\n## Contributing\n\n```shell\n# Fork the repo and build project\nmake build\n\n# Make your local changes\n\n# Run all tests and check code style\nmake test\nmake codestyle\n\n# Create your pull request and check all tests in CI\n```\n\n\n\n## License\n\nMIT\n\n\n\n## See Also\n\n- [Composer-Diff](https://github.com/JBZoo/Composer-Diff) - See what packages have changed after `composer update`.\n- [Composer-Graph](https://github.com/JBZoo/Composer-Graph) - Dependency graph visualization of composer.json based on mermaid-js.\n- [Mermaid-PHP](https://github.com/JBZoo/Mermaid-PHP) - Generate diagrams and flowcharts with the help of the mermaid script language.\n- [Utils](https://github.com/JBZoo/Utils) - Collection of useful PHP functions, mini-classes, and snippets for every day.\n- [Image](https://github.com/JBZoo/Image) - Package provides object-oriented way to manipulate with images as simple as possible.\n- [Data](https://github.com/JBZoo/Data) - Extended implementation of ArrayObject. Use files as config/array.\n- [Retry](https://github.com/JBZoo/Retry) - Tiny PHP library providing retry/backoff functionality with multiple backoff strategies and jitter support.\n- [SimpleTypes](https://github.com/JBZoo/SimpleTypes) - Converting any values and measures - money, weight, exchange rates, length, ...\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjbzoo%2Fci-report-converter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjbzoo%2Fci-report-converter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjbzoo%2Fci-report-converter/lists"}