-
Notifications
You must be signed in to change notification settings - Fork 57
159 lines (143 loc) · 4.19 KB
/
php-test.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
150
151
152
153
154
155
156
157
158
159
name: PHP Unit Testing
on:
push:
branches:
- trunk
- 'release/**'
# Only run if PHP-related files changed.
paths:
- '.github/workflows/php-test.yml'
- '**.php'
- '.wp-env.json'
- '**/package.json'
- 'package-lock.json'
- 'phpunit.xml.dist'
- 'composer.json'
- 'composer.lock'
pull_request:
branches:
- trunk
- 'release/**'
- 'feature/**'
# Only run if PHP-related files changed.
paths:
- '.github/workflows/php-test.yml'
- '**.php'
- '.wp-env.json'
- '**/package.json'
- 'package-lock.json'
- 'phpunit.xml.dist'
- 'composer.json'
- 'composer.lock'
types:
- opened
- reopened
- synchronize
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
jobs:
php-test:
name: PHP ${{ matrix.php }} - WP ${{ matrix.wordpress }}${{ matrix.experimental && ' (experimental)' || '' }}${{ matrix.coverage && ' (with coverage)' || '' }}
runs-on: ubuntu-latest
timeout-minutes: 20
strategy:
fail-fast: true
matrix:
php:
- '7.4'
- '8.0'
- '8.1'
- '8.2'
wordpress: [ 'latest' ]
include:
- php: '7.4'
wordpress: '6.3'
- php: '8.3'
wordpress: 'latest'
coverage: true
- php: '8.3'
wordpress: 'trunk'
experimental: true
env:
WP_ENV_PHP_VERSION: ${{ matrix.php }}
WP_ENV_CORE: ${{ matrix.wordpress == 'trunk' && 'WordPress/WordPress' || format( 'https://wordpress.org/wordpress-{0}.zip', matrix.wordpress ) }}
steps:
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
- name: Install PHP dependencies
uses: ramsey/composer-install@57532f8be5bda426838819c5ee9afb8af389d51a
with:
composer-options: '--prefer-dist'
- name: Setup Node.js (.nvmrc)
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: npm
- name: npm install
run: npm ci
- name: Start WordPress
run: |
if [[ ${{ matrix.coverage == true }} == true ]]; then
npm run wp-env start -- --xdebug=coverage
else
npm run wp-env start
fi
- name: Run tests
run: |
if [[ ${{ matrix.coverage == true }} == true ]]; then
npm run test-php-coverage
npm run test-php-multisite-coverage
else
npm run test-php
npm run test-php-multisite
fi
- name: Upload code coverage report
if: ${{ matrix.coverage }}
uses: codecov/codecov-action@7f8b4b4bde536c465e797be725718b88c5d95e0e
with:
file: build/logs/*.xml
flags: unit
token: ${{ secrets.CODECOV_TOKEN }}
phpcs-sniffs:
name: PHP (Sniffs) ${{ matrix.php }} ${{ matrix.coverage && ' (with coverage)' || '' }}
runs-on: ubuntu-latest
timeout-minutes: 20
strategy:
fail-fast: true
matrix:
php:
- '7.4'
- '8.0'
- '8.1'
- '8.2'
wordpress: [ 'latest' ]
include:
- php: '8.3'
coverage: true
steps:
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
- name: Install PHP dependencies
uses: ramsey/composer-install@57532f8be5bda426838819c5ee9afb8af389d51a
with:
working-directory: "phpcs-sniffs"
- name: Run tests
working-directory: "phpcs-sniffs"
run: |
if [[ ${{ matrix.coverage == true }} == true ]]; then
composer run-tests -- --coverage-clover ../build/logs/phpcs-coverage.xml
else
composer run-tests
fi
- name: Upload code coverage report
if: ${{ matrix.coverage }}
uses: codecov/codecov-action@7f8b4b4bde536c465e797be725718b88c5d95e0e
with:
file: build/logs/*.xml
flags: phpcs-sniffs
token: ${{ secrets.CODECOV_TOKEN }}