Skip to content

Commit cb18c7b

Browse files
authored
Add root path to github action (#35)
1 parent e084e9b commit cb18c7b

3 files changed

Lines changed: 26 additions & 17 deletions

File tree

README.md

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# JBZoo / CI-Report-Converter
22

3-
[![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)
3+
[![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)
44
[![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) [![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)
55

66

@@ -37,7 +37,7 @@
3737

3838
## Why?
3939

40-
I believe you are familiar with the huge zoo of various utilities for testing, checking code standards, linters etc.
40+
I believe you are familiar with the huge zoo of various utilities for testing, checking code standards, linters etc.
4141
It's really often the output of utilities is not supported in popular CI systems (TeamCity, GitHub, etc...).
4242
I 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.
4343

@@ -63,7 +63,7 @@ chmod +x ./ci-report-converter.phar
6363
./ci-report-converter.phar --help
6464

6565
# OR just pull the Docker Image
66-
docker run --rm jbzoo/ci-report-converter --help
66+
docker run --rm jbzoo/ci-report-converter --help
6767
```
6868

6969

@@ -98,6 +98,10 @@ Action allows you to convert error reports to the [GitHub Annotations format](ht
9898
# Required: true
9999
output-format: junit
100100

101+
# Set a root path and convert absolute file paths to relative.
102+
# Default value: '.'
103+
root-path: '/my/project/root/directory'
104+
101105
# Set custom name of root group/suite (if it's possible).
102106
# Required: true
103107
suite-name: My Tests
@@ -120,10 +124,10 @@ jobs:
120124
steps:
121125
- name: Checkout Code
122126
uses: actions/checkout@v2
123-
127+
124128
- name: PHP Code Sniffer
125129
run: ./vendor/bin/phpcs --report=checkstyle --standard=PSR12 -q ./src > ./build/phpcs-checkstyle.xml
126-
130+
127131
- name: Converting checkstyle.xml to Github Annotations
128132
uses: jbzoo/ci-report-converter@master
129133
with:
@@ -293,8 +297,8 @@ Yeah, I know that the integration is not the cleanest, and it's not super beauti
293297
Therefore, 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!"
294298
Also, you will have the awesome bonus - navigating the project and gives the most detailed information about errors.
295299

296-
**The general idea is pretty simple:**
297-
- We take almost any utility for testing.
300+
**The general idea is pretty simple:**
301+
- We take almost any utility for testing.
298302
- It saves report in the file or outputs error to StdOut as xml/json.
299303
- CI-Report-Converter changes the report format. It saves result somewhere or just outputs it in StdOut.
300304
- ???
@@ -357,7 +361,7 @@ class CheckStyleExamplesTest extends TestCase
357361
' --input-file=./build/phpcs-report.xml' . # Using prepared file on previous step as source.
358362
' --output-format=tc-tests' . # Target reporting format. Default value is "tc-tests".
359363
' --suite-name=PHPcs' . # Define the name of group. See screenshot below.
360-
' --root-path=`pwd`' # Specify the project path for pretty printing paths in UI. Default value is `.` (current dir).
364+
' --root-path=`pwd`' # Specify the project path for pretty printing paths in UI. Default value is `.` (current dir).
361365
);
362366

363367
# The same reason like in `testPipelineWay()`.
@@ -385,7 +389,7 @@ php ./vendor/bin/phpcs --report=checkstyle --standard=PSR12 -q ./src | ./ci-repo
385389
<summary>Screenshot</summary>
386390

387391
![PHPmd in JetBrains PhpStorm](.github/assets/phpstorm-phpmd.png)
388-
392+
389393
</details>
390394

391395
```shell
@@ -400,12 +404,12 @@ php ./vendor/bin/phpmd ./src json cleancode | ./ci-report-converter.phar -Sphpmd
400404
<summary>Screenshot</summary>
401405

402406
![PHPmd in JetBrains PhpStorm](.github/assets/phpstorm-phpmnd.png)
403-
407+
404408
</details>
405409

406410
```shell
407411
php ./vendor/bin/phpmnd ./src --hint --quiet --xml-output=./build/phpmnd-report.xml
408-
./ci-report-converter.phar --root-path=./src --input-file=./build/phpmnd-report.xml --input-format=phpmnd
412+
./ci-report-converter.phar --root-path=./src --input-file=./build/phpmnd-report.xml --input-format=phpmnd
409413
```
410414

411415

@@ -416,7 +420,7 @@ php ./vendor/bin/phpmnd ./src --hint --quiet --xml-output=./build/phpmnd-report.
416420
<summary>Screenshot</summary>
417421

418422
![PHPcpd in JetBrains PhpStorm](.github/assets/phpstorm-phpcpd.png)
419-
423+
420424
</details>
421425

422426
```shell
@@ -432,7 +436,7 @@ php ./vendor/bin/phpcpd ./src --log-pmd=./build/phpcpd-report.xml
432436
<summary>Screenshot</summary>
433437

434438
![PHPstan in JetBrains PhpStorm](.github/assets/phpstorm-phpstan.png)
435-
439+
436440
</details>
437441

438442
```shell
@@ -445,7 +449,7 @@ php ./vendor/bin/phpstan analyse --error-format=checkstyle --no-progress ./src |
445449

446450
<details>
447451
<summary>Screenshot</summary>
448-
452+
449453
![PHP Psalm in JetBrains PhpStorm](.github/assets/phpstorm-psalm.png)
450454

451455
</details>
@@ -530,7 +534,7 @@ Use the option `--output-format=tc-inspections` to convert any style report to u
530534
531535
### GitHub Actions
532536
533-
You 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)
537+
You 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)
534538
535539
![GitHub Actions 1](.github/assets/github-actions-1.png)
536540
@@ -663,6 +667,6 @@ MIT
663667
- [Mermaid-PHP](https://github.com/JBZoo/Mermaid-PHP) - Generate diagrams and flowcharts with the help of the mermaid script language.
664668
- [Utils](https://github.com/JBZoo/Utils) - Collection of useful PHP functions, mini-classes, and snippets for every day.
665669
- [Image](https://github.com/JBZoo/Image) - Package provides object-oriented way to manipulate with images as simple as possible.
666-
- [Data](https://github.com/JBZoo/Data) - Extended implementation of ArrayObject. Use files as config/array.
670+
- [Data](https://github.com/JBZoo/Data) - Extended implementation of ArrayObject. Use files as config/array.
667671
- [Retry](https://github.com/JBZoo/Retry) - Tiny PHP library providing retry/backoff functionality with multiple backoff strategies and jitter support.
668672
- [SimpleTypes](https://github.com/JBZoo/SimpleTypes) - Converting any values and measures - money, weight, exchange rates, length, ...

action.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ inputs:
3535
description: 'Target format. Available options: gitlab-json, github-cli, junit, plain, tc-inspections, tc-tests'
3636
default: github-cli
3737
required: true
38+
root-path:
39+
description: If option is set, all absolute file paths will be converted to relative once.
40+
default: "."
3841
suite-name:
3942
description: 'Set custom name of root group/suite (if it''s possible).'
4043
required: true
@@ -52,6 +55,8 @@ runs:
5255
- ${{ inputs.output-format }}
5356
- '--output-file'
5457
- ${{ inputs.output-file }}
58+
- '--root-path'
59+
- ${{ inputs.root-path }}
5560
- '--suite-name'
5661
- ${{ inputs.suite-name }}
5762
- '--non-zero-code'

tests/CliCommandsTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ public function testGitHubActionsYml(): void
8282
'no-interaction',
8383

8484
'tc-flow-id',
85-
'root-path',
8685

8786
'mute-errors',
8887
'no-progress',
@@ -149,6 +148,7 @@ public function testGitHubActionsReadMe(): void
149148
'input-format' => 'checkstyle',
150149
'output-file' => './build/junit.xml',
151150
'output-format' => 'junit',
151+
'root-path' => './custom/project/path',
152152
'suite-name' => 'My Tests',
153153
'non-zero-code' => 'yes',
154154
];

0 commit comments

Comments
 (0)