-
Notifications
You must be signed in to change notification settings - Fork 1
149 lines (126 loc) · 5.73 KB
/
php-qa.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
name: PHP Quality Assurance
on:
push:
paths:
- '**workflows/php-qa.yml'
- '**.php'
- '**phpcs.xml.dist'
- '**phpunit.xml.dist'
- '**psalm.xml'
- '**composer.json'
pull_request:
paths:
- '**workflows/php-qa.yml'
- '**.php'
- '**phpcs.xml.dist'
- '**phpunit.xml.dist'
- '**psalm.xml'
- '**composer.json'
workflow_dispatch:
inputs:
jobs:
required: true
type: choice
default: 'Run all'
description: 'Choose jobs to run'
options:
- 'Run all'
- 'Run static QA only'
- 'Run tests only'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
static-qa:
runs-on: ubuntu-latest
if: ${{ ((github.event_name != 'workflow_dispatch') && !contains(github.event.head_commit.message, 'skip qa')) || ((github.event_name == 'workflow_dispatch') && (github.event.inputs.jobs != 'Run tests only')) }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 7.4
coverage: none
tools: cs2pr
- name: Install dependencies
uses: ramsey/composer-install@v2
- name: Check code styles
run: ./vendor/bin/phpcs -q ${{ ((github.event_name == 'pull_request') && '--report-checkstyle="phpcs-report.xml" ') || '' }}--report-full --runtime-set ignore_errors_on_exit 1 --runtime-set ignore_warnings_on_exit 1
- name: Annotate code styles for PRs
if: ${{ github.event_name == 'pull_request' }}
run: cs2pr --graceful-warnings phpcs-report.xml
- name: Check Psalm
run: ./vendor/bin/psalm ${{ ((github.event_name == 'pull_request') && '--output-format=github ') || '' }} --no-suggestions --find-unused-psalm-suppress --no-diff --no-cache --no-file-cache
unit-tests:
runs-on: ubuntu-latest
if: ${{ ((github.event_name != 'workflow_dispatch') && !contains(github.event.head_commit.message, 'skip tests')) || ((github.event_name == 'workflow_dispatch') && (github.event.inputs.jobs != 'Run static QA only')) }}
env:
USE_COVERAGE: no
strategy:
fail-fast: false
matrix:
php-ver: [ '7.2', '7.3', '7.4', '8.0', '8.1', '8.2' ]
wp-ver: [ '4.7.*', '5.*', '6.*' ]
dependency-versions: [ 'highest', 'lowest' ]
exclude:
- php-ver: '8.1'
wp-ver: '4.7.*'
- php-ver: '8.1'
wp-ver: '5.*'
dependency-versions: 'lowest'
- php-ver: '8.2'
wp-ver: '4.7.*'
- php-ver: '8.2'
wp-ver: '5.*'
dependency-versions: 'lowest'
steps:
- name: Update "USE_COVERAGE" env var based on matrix
if: ${{ matrix.php-ver == '7.4' && matrix.wp-ver == '6.*' && matrix.dependency-versions == 'highest' }}
run: echo "USE_COVERAGE=yes" >> $GITHUB_ENV
- name: Checkout
uses: actions/checkout@v3
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-ver }}
ini-values: zend.assertions=1, error_reporting=E_ALL, display_errors=On
coverage: ${{ ((env.USE_COVERAGE == 'yes') && 'xdebug') || 'none' }}
- name: Adjust WP version
run: |
composer remove --dev --no-update "roots/wordpress-no-content"
composer remove --dev --no-update "phpunit/phpunit"
composer require --no-update "roots/wordpress-no-content:${{ matrix.wp-ver }}"
composer require --no-update "phpunit/phpunit:^7.5.20 || ^9.6.4"
- name: Install dependencies
uses: ramsey/composer-install@v2
with:
dependency-versions: ${{ matrix.dependency-versions }}
- name: Run unit tests
run: |
./vendor/bin/phpunit --atleast-version 9 && ./vendor/bin/phpunit --migrate-configuration || echo 'Config does not need updates.'
./vendor/bin/phpunit ${{ ((env.USE_COVERAGE == 'yes') && '--coverage-html=coverage-report') || '--no-coverage' }}
- name: Upload coverage report
uses: actions/upload-artifact@v3
if: ${{ env.USE_COVERAGE == 'yes' }}
with:
name: coverage-report
path: coverage-report/
lint:
runs-on: ubuntu-latest
if: ${{ !contains(github.event.head_commit.message, 'skip lint') }}
strategy:
fail-fast: true
matrix:
php-ver: [ '7.2', '7.3', '7.4', '8.0', '8.1', '8.2' ]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-ver }}
ini-values: zend.assertions=1, error_reporting=E_ALL, display_errors=On
tools: parallel-lint
- name: Check syntax error in sources
run: parallel-lint ./