Skip to content

Commit 80442d5

Browse files
jrfnlgsherwood
authored andcommitted
GH Actions: report CS violations in the PR
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
1 parent 55a9b92 commit 80442d5

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

.github/workflows/test.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ jobs:
6161
php-version: ${{ matrix.php }}
6262
ini-values: ${{ steps.set_ini.outputs.PHP_INI }}
6363
coverage: none
64+
tools: cs2pr
6465

6566
# Install dependencies and handle caching in one go.
6667
# @link https://github.com/marketplace/actions/install-composer-dependencies
@@ -76,9 +77,22 @@ jobs:
7677
run: vendor/bin/phpunit
7778

7879
- name: 'PHPCS: check code style without cache, no parallel'
80+
<<<<<<< HEAD
7981
if: ${{ matrix.custom_ini == false }}
82+
=======
83+
if: ${{ matrix.custom_ini == false && matrix.php != 7.4 }}
84+
>>>>>>> a7b2b955c... GH Actions: report CS violations in the PR
8085
run: php bin/phpcs --no-cache --parallel=1
8186

87+
- name: 'PHPCS: check code style to show results in PR'
88+
if: ${{ matrix.custom_ini == false && matrix.php == 7.4 }}
89+
continue-on-error: true
90+
run: php bin/phpcs --no-cache --parallel=1 --report-full --report-checkstyle=./phpcs-report.xml
91+
92+
- name: Show PHPCS results in PR
93+
if: ${{ matrix.custom_ini == false && matrix.php == 7.4 }}
94+
run: cs2pr ./phpcs-report.xml
95+
8296
- name: 'Composer: validate config'
8397
if: ${{ matrix.custom_ini == false }}
8498
run: composer validate --no-check-all --strict

0 commit comments

Comments
 (0)