Improve problem matchers section in README

This commit is contained in:
Shivam Mathur 2020-09-27 04:59:03 +05:30
parent 84b222366a
commit 7dcb43c768
No known key found for this signature in database
GPG Key ID: 3E13E4C8591ACC2A

View File

@ -564,9 +564,11 @@ If you have a number of workflows which setup multiple tools or have many compos
### Problem Matchers ### Problem Matchers
Problem matchers are `json` configurations which identify errors and warnings in your logs and surface that information prominently in the GitHub Actions UI by highlighting them and creating code annotations.
#### PHP #### PHP
Setup problem matchers for your `PHP` output by adding this step after the `setup-php` step. This will scan the logs for PHP errors and warnings, and surface them prominently in the GitHub Actions UI by creating annotations and log file decorations. Setup problem matchers for your `PHP` output by adding this step after the `setup-php` step.
```yaml ```yaml
- name: Setup problem matchers for PHP - name: Setup problem matchers for PHP
@ -575,19 +577,16 @@ Setup problem matchers for your `PHP` output by adding this step after the `setu
#### PHPUnit #### PHPUnit
Setup problem matchers for your `PHPUnit` output by adding this step after the `setup-php` step. This will scan the logs for failing tests and surface that information prominently in the GitHub Actions UI by creating annotations and log file decorations. Setup problem matchers for your `PHPUnit` output by adding this step after the `setup-php` step.
```yaml ```yaml
- name: Setup problem matchers for PHPUnit - name: Setup problem matchers for PHPUnit
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
``` ```
#### Other Tools #### PHPStan
For tools that support `checkstyle` reporting like `phpstan`, `psalm`, `php-cs-fixer` and `phpcs` you can use `cs2pr` to annotate your code. PHPStan supports error reporting in GitHub Actions, so no problem matchers are required.
For examples refer to [cs2pr documentation](https://github.com/staabm/annotate-pull-request-from-checkstyle).
> Here is an example with `phpstan`.
```yaml ```yaml
- name: Setup PHP - name: Setup PHP
@ -596,10 +595,43 @@ For examples refer to [cs2pr documentation](https://github.com/staabm/annotate-p
php-version: '7.4' php-version: '7.4'
tools: phpstan tools: phpstan
- name: PHPStan - name: Run PHPStan
run: phpstan analyse src run: phpstan analyse src
``` ```
#### Psalm
Psalm supports error reporting in GitHub Actions with an output format `github`.
```yaml
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
tools: psalm
- name: Run Psalm
run: psalm --output-format=github
```
#### Tools with checkstyle support
For tools that support `checkstyle` reporting like `phpstan`, `psalm`, `php-cs-fixer` and `phpcs` you can use `cs2pr` to annotate your code.
For examples refer to [cs2pr documentation](https://github.com/staabm/annotate-pull-request-from-checkstyle).
> Here is an example with `phpcs`.
```yaml
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
tools: cs2pr, phpcs
- name: Run phpcs
run: phpcs -q --report=checkstyle src | cs2pr
```
### Examples ### Examples
Examples of using `setup-php` with various PHP Frameworks and Packages. Examples of using `setup-php` with various PHP Frameworks and Packages.