Skip to content

Commit f6f44e1

Browse files
committed
Merge branch 'feature/ghactions-tweaks' of https://github.com/jrfnl/PHP_CodeSniffer
2 parents dcc1fe5 + 5ee08ea commit f6f44e1

File tree

3 files changed

+29
-19
lines changed

3 files changed

+29
-19
lines changed

.github/workflows/phpstan.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ on:
99
pull_request:
1010
paths-ignore:
1111
- '**.md'
12+
# Allow manually triggering the workflow.
13+
workflow_dispatch:
1214

1315
jobs:
1416
phpstan:
@@ -25,14 +27,13 @@ jobs:
2527
with:
2628
php-version: '7.4'
2729
coverage: none
28-
29-
- name: 'Composer: require PHPStan'
30-
run: composer require --no-update --dev phpstan/phpstan
30+
tools: phpstan
3131

3232
# Install dependencies and handle caching in one go.
33+
# Dependencies need to be installed to make sure the PHPUnit classes are recognized.
3334
# @link https://github.com/marketplace/actions/install-composer-dependencies
3435
- name: Install Composer dependencies
3536
uses: "ramsey/composer-install@v1"
3637

3738
- name: Run PHPStan
38-
run: vendor/bin/phpstan analyse --configuration=phpstan.neon
39+
run: phpstan analyse --configuration=phpstan.neon

.github/workflows/test.yml

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ on:
99
pull_request:
1010
paths-ignore:
1111
- '**.md'
12+
# Allow manually triggering the workflow.
13+
workflow_dispatch:
1214

1315
jobs:
1416
test:
@@ -66,6 +68,7 @@ jobs:
6668
php-version: ${{ matrix.php }}
6769
ini-values: ${{ steps.set_ini.outputs.PHP_INI }}
6870
coverage: none
71+
tools: cs2pr
6972

7073
# Install dependencies and handle caching in one go.
7174
# @link https://github.com/marketplace/actions/install-composer-dependencies
@@ -75,7 +78,7 @@ jobs:
7578

7679
# For PHP 8.0+, we need to install with ignore platform reqs as PHPUnit 7 is still used.
7780
- name: Install Composer dependencies - with ignore platform
78-
if: ${{ matrix.custom_ini == false }}
81+
if: ${{ matrix.php >= 8.0 }}
7982
uses: "ramsey/composer-install@v1"
8083
with:
8184
composer-options: --ignore-platform-reqs
@@ -85,26 +88,30 @@ jobs:
8588
- name: 'PHPCS: set the path to PHP'
8689
run: php bin/phpcs --config-set php_path php
8790

88-
# We need to remove the config file so that PHPUnit doesn't try to read it.
89-
# This causes an error on PHP 8.1+ with PHPunit 7, but it's not needed here anyway as the
90-
# phpunit command (below) specifies all required settings.
91-
- name: 'PHPUnit: remove config file'
92-
run: rm phpunit.xml.dist
93-
94-
# Useless tests were not reported for before PHPUnit 6, so it doesn't
95-
# understand the CLI argument.
9691
- name: 'PHPUnit: run the tests'
97-
if: ${{ matrix.php < 7.0 }}
98-
run: vendor/bin/phpunit tests/AllTests.php --bootstrap=tests/bootstrap.php
92+
if: ${{ matrix.php != 8.1 }}
93+
run: vendor/bin/phpunit tests/AllTests.php
9994

100-
- name: 'PHPUnit: run the tests, dont report useless'
101-
if: ${{ matrix.php >= 7.0 }}
102-
run: vendor/bin/phpunit tests/AllTests.php --bootstrap=tests/bootstrap.php --dont-report-useless-tests
95+
# We need to ignore the config file so that PHPUnit doesn't try to read it.
96+
# The config file causes an error on PHP 8.1+ with PHPunit 7, but it's not needed here anyway
97+
# as we can pass all required settings in the phpunit command.
98+
- name: 'PHPUnit: run the tests on PHP nightly'
99+
if: ${{ matrix.php == 8.1 }}
100+
run: vendor/bin/phpunit tests/AllTests.php --no-configuration --bootstrap=tests/bootstrap.php --dont-report-useless-tests
103101

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

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

.github/workflows/validate.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ on:
99
pull_request:
1010
paths-ignore:
1111
- '**.md'
12+
# Allow manually triggering the workflow.
13+
workflow_dispatch:
1214

1315
jobs:
1416
checkxml:

0 commit comments

Comments
 (0)