Skip to content

Commit a7b2b95

Browse files
committed
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 cc678d1 commit a7b2b95

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

.github/workflows/test.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ jobs:
6666
php-version: ${{ matrix.php }}
6767
ini-values: ${{ steps.set_ini.outputs.PHP_INI }}
6868
coverage: none
69+
tools: cs2pr
6970

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

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

104+
- name: 'PHPCS: check code style to show results in PR'
105+
if: ${{ matrix.custom_ini == false && matrix.php == 7.4 }}
106+
continue-on-error: true
107+
run: php bin/phpcs --no-cache --parallel=1 --report-full --report-checkstyle=./phpcs-report.xml
108+
109+
- name: Show PHPCS results in PR
110+
if: ${{ matrix.custom_ini == false && matrix.php == 7.4 }}
111+
run: cs2pr ./phpcs-report.xml
112+
103113
- name: 'Composer: validate config'
104114
if: ${{ matrix.custom_ini == false }}
105115
run: composer validate --no-check-all --strict

0 commit comments

Comments
 (0)