Skip to content

Commit 6151cf2

Browse files
committed
GH Actions: only run PHPCS once
All sniffs from PHPCS are set up to give the same results independently of the PHP version on which PHPCS is run, so there is no need to run it against multiple PHP versions in the matrix. With this in mind, I'm suggesting to split off the PHPCS check into its own job. Within that job, I've also set things up in a way that any CS errors will be shown inline in the code view if the build was run for a PR.
1 parent 866a915 commit 6151cf2

File tree

1 file changed

+32
-5
lines changed

1 file changed

+32
-5
lines changed

.github/workflows/main.yml

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,38 @@ on:
1010
workflow_dispatch:
1111

1212
jobs:
13+
phpcs:
14+
name: 'PHPCS'
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v4
20+
21+
- name: Set up PHP environment
22+
uses: shivammathur/setup-php@v2
23+
with:
24+
php-version: 'latest'
25+
coverage: none
26+
tools: cs2pr
27+
28+
- name: Install Composer dependencies & cache dependencies
29+
uses: "ramsey/composer-install@v3"
30+
with:
31+
composer-options: "--prefer-dist"
32+
env:
33+
COMPOSER_ROOT_VERSION: dev-${{ github.event.repository.default_branch }}
34+
35+
- name: Run Code Sniffer
36+
id: phpcs
37+
run: ./vendor/bin/phpcs -ps --report-full --report-checkstyle=./phpcs-report.xml
38+
39+
- name: Show PHPCS results in PR
40+
if: ${{ always() && steps.phpcs.outcome == 'failure' }}
41+
run: cs2pr ./phpcs-report.xml
42+
1343
build:
14-
44+
1545
strategy:
1646
matrix:
1747
php: ['5.6', '7.3', '7.4', '8.0', '8.1']
@@ -41,9 +71,6 @@ jobs:
4171

4272
- name: Run Test Suite
4373
run: XDEBUG_MODE=coverage ./vendor/bin/phpunit tests --coverage-text
44-
45-
- name: Run Code Sniffer
46-
run: ./vendor/bin/phpcs
47-
74+
4875
#- name: Run Static Analysis
4976
# run: ./vendor/bin/psalm

0 commit comments

Comments
 (0)