Мy name is Dzianis Kotau. I'm Solutions Architect and Zend Certified PHP Engineer. I'm PHP evangelist and loved in it.
Laravel Pint Format Option
Dzianis Kotau • July 30, 2022php cicd
I started to use it from version
0.x and at that moment it didn't have option that I need: the ability to generate
reports for CI/CD pipelines. For example in GitHub Actions, you can generate
in your workflows. Such functionality is called Annotations. Then Github will use it to highlight
errors directly in Pull Request UI. You don't need to open workflow logs and read them line by line.
So, I decided to contribute to Laravel Pint and added --format option that uses same option from
The changes were accepted in Adds --format option PR and included in version
1.1 of Laravel Pint.
How can you use such functionality in your pipelines? Let's go through examples for
Github Actions. Here I will use
additional cs2pr third-party action.
Simple workflow action can be look like this:
- name: Show Pint results in PR run: pint --test --format=checkstyle | cs2pr
If you want to have both logs and annotations you need to run
- name: Check PHP code style id: cs-check run: pint --test - name: Generate Annotations on CS errors if: failure() && steps.cs-check.outcome != 'success' run: pint --test --format=checkstyle | cs2pr
Bonus. If you look at my PR you can see that I suggested to use one more option
--report to save
format generated report to the file. In this case, you need to run
pint only once to generate both logs and
- name: Check PHP code style id: cs-check run: pint --test --format=checkstyle --report=./pint-report.xml - name: Show CS error results in PR if: failure() && steps.cs-check.outcome != 'success' run: cs2pr ./pint-report.xml
But this option was not accepted.