Skip to content

Commit

Permalink
Improve problem matchers section in README
Browse files Browse the repository at this point in the history
  • Loading branch information
shivammathur committed Sep 28, 2020
1 parent d582147 commit 9bb2e59
Showing 1 changed file with 40 additions and 8 deletions.
48 changes: 40 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -564,9 +564,11 @@ If you have a number of workflows which setup multiple tools or have many compos

### 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

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
- name: Setup problem matchers for PHP
Expand All @@ -575,19 +577,16 @@ Setup problem matchers for your `PHP` output by adding this step after the `setu

#### 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
- name: Setup problem matchers for PHPUnit
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
```

#### Other Tools

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).
#### PHPStan

> Here is an example with `phpstan`.
PHPStan supports error reporting in GitHub Actions, so no problem matchers are required.

```yaml
- name: Setup PHP
Expand All @@ -596,10 +595,43 @@ For examples refer to [cs2pr documentation](https://github.com/staabm/annotate-p
php-version: '7.4'
tools: phpstan
- name: PHPStan
- name: Run PHPStan
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 of using `setup-php` with various PHP Frameworks and Packages.
Expand Down

0 comments on commit 9bb2e59

Please sign in to comment.