Skip to content

Commit 11cacba

Browse files
authored
Merge pull request #167 from Brain-WP/feature/ghactions-make-workflow-more-modular
GH Actions: make workflow more modular
2 parents 8a88c99 + fd6b2ee commit 11cacba

File tree

2 files changed

+68
-11
lines changed

2 files changed

+68
-11
lines changed

.github/workflows/php-qa.yml

Lines changed: 67 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,73 @@ concurrency:
1212
cancel-in-progress: true
1313

1414
jobs:
15-
qa:
15+
phpcompatibility:
16+
runs-on: ubuntu-latest
17+
18+
name: "PHPCompatibility"
19+
20+
steps:
21+
- name: Checkout code
22+
uses: actions/checkout@v6
23+
24+
- name: Setup PHP
25+
uses: shivammathur/setup-php@v2
26+
with:
27+
php-version: 'latest'
28+
coverage: 'none'
29+
tools: cs2pr
30+
env:
31+
fail-fast: true
32+
33+
- name: Install dependencies
34+
uses: "ramsey/composer-install@v3"
35+
with:
36+
# Bust the cache at least once a month - output format: YYYY-MM.
37+
custom-cache-suffix: $(date -u "+%Y-%m")
38+
39+
- name: Check cross-version PHP compatibility
40+
id: phpcs
41+
run: composer phpcompat -- --report-full --report-checkstyle=./phpcs-report.xml
42+
43+
- name: Show PHPCS results in PR
44+
if: ${{ always() && steps.phpcs.outcome == 'failure' }}
45+
run: cs2pr ./phpcs-report.xml
46+
47+
lint:
48+
runs-on: ubuntu-latest
49+
50+
strategy:
51+
matrix:
52+
php: ['5.6', '7.0', '7.4', '8.0', '8.5', 'nightly']
53+
54+
name: "Lint: PHP ${{ matrix.php }}"
55+
56+
continue-on-error: ${{ matrix.php == 'nightly' }}
57+
58+
steps:
59+
- name: Checkout code
60+
uses: actions/checkout@v6
61+
62+
- name: Setup PHP
63+
uses: shivammathur/setup-php@v2
64+
with:
65+
php-version: ${{ matrix.php }}
66+
ini-values: zend.assertions=1, error_reporting=-1, display_errors=On, display_startup_errors=On
67+
coverage: 'none'
68+
tools: parallel-lint, cs2pr
69+
env:
70+
fail-fast: true
71+
72+
- name: "Lint against parse and compile errors (push)"
73+
if: ${{ github.event_name != 'pull_request' }}
74+
run: parallel-lint ./src/ ./inc/ ./tests/ -e php --show-deprecated
75+
76+
- name: "Lint against parse and compile errors (PR)"
77+
if: ${{ github.event_name == 'pull_request' }}
78+
run: parallel-lint ./src/ ./inc/ ./tests/ -e php --show-deprecated --checkstyle | cs2pr
79+
80+
test:
81+
needs: lint
1682
runs-on: ubuntu-latest
1783

1884
strategy:
@@ -40,14 +106,9 @@ jobs:
40106
php-version: ${{ matrix.php-versions }}
41107
ini-values: zend.assertions=1, error_reporting=-1, display_errors=On, display_startup_errors=On
42108
coverage: ${{ ( matrix.php-versions == '7.4' && 'xdebug' ) || 'none' }}
43-
tools: parallel-lint
44109
env:
45110
fail-fast: true
46111

47-
- name: Check syntax error in sources
48-
if: ${{ matrix.dependency-versions == 'highest' }}
49-
run: parallel-lint ./src/ ./tests/
50-
51112
- name: Install dependencies
52113
uses: "ramsey/composer-install@v3"
53114
with:
@@ -57,10 +118,6 @@ jobs:
57118
# Bust the cache at least once a month - output format: YYYY-MM.
58119
custom-cache-suffix: $(date -u "+%Y-%m")
59120

60-
- name: Check cross-version PHP compatibility
61-
if: ${{ matrix.php-versions == '7.4' && matrix.dependency-versions == 'highest' }} # results is same across versions, do it once
62-
run: composer phpcompat
63-
64121
- name: Migrate test configuration (>= 7.3)
65122
if: ${{ matrix.php-versions >= 7.3 && matrix.dependency-versions == 'highest' }}
66123
run: ./vendor/bin/phpunit --migrate-configuration

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
},
7272
"scripts" : {
7373
"phpcompat": [
74-
"@php ./vendor/squizlabs/php_codesniffer/bin/phpcs -ps . --standard=PHPCompatibility --ignore=*/vendor/* --extensions=php --basepath=./ --runtime-set testVersion 5.6-"
74+
"@php ./vendor/squizlabs/php_codesniffer/bin/phpcs -ps . --standard=PHPCompatibility --ignore=*/vendor/* --parallel=10 --extensions=php --basepath=./ --runtime-set testVersion 5.6-"
7575
]
7676
}
7777
}

0 commit comments

Comments
 (0)