Skip to content

Commit

Permalink
GH Actions: report CS violations in the PR
Browse files Browse the repository at this point in the history
The cs2pr tool will allow to display the results from an action run in checkstyle format in-line in the PR code view, which should improve usability of the workflow results.

As the CS run is run in every test run in the matrix, passing the results on to CS2PR would result in violations being displayed multiple times, so using conditions to only pass the CS violations on to the PR for one of the runs.

Ref: https://github.com/staabm/annotate-pull-request-from-checkstyle
  • Loading branch information
jrfnl committed Feb 28, 2021
1 parent cc678d1 commit a7b2b95
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ jobs:
php-version: ${{ matrix.php }}
ini-values: ${{ steps.set_ini.outputs.PHP_INI }}
coverage: none
tools: cs2pr

# Install dependencies and handle caching in one go.
# @link https://github.com/marketplace/actions/install-composer-dependencies
Expand Down Expand Up @@ -97,9 +98,18 @@ jobs:
run: vendor/bin/phpunit tests/AllTests.php --no-configuration --bootstrap=tests/bootstrap.php --dont-report-useless-tests

- name: 'PHPCS: check code style without cache, no parallel'
if: ${{ matrix.custom_ini == false }}
if: ${{ matrix.custom_ini == false && matrix.php != 7.4 }}
run: php bin/phpcs --no-cache --parallel=1

- name: 'PHPCS: check code style to show results in PR'
if: ${{ matrix.custom_ini == false && matrix.php == 7.4 }}
continue-on-error: true
run: php bin/phpcs --no-cache --parallel=1 --report-full --report-checkstyle=./phpcs-report.xml

- name: Show PHPCS results in PR
if: ${{ matrix.custom_ini == false && matrix.php == 7.4 }}
run: cs2pr ./phpcs-report.xml

- name: 'Composer: validate config'
if: ${{ matrix.custom_ini == false }}
run: composer validate --no-check-all --strict
Expand Down

0 comments on commit a7b2b95

Please sign in to comment.