Repository navigation
157 lines (133 loc) · 3.83 KB
/
Copy pathtests-php.yml
File metadata and controls
157 lines (133 loc) · 3.83 KB
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
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow
name: PHP Tests
on: # yamllint disable-line rule:truthy
workflow_dispatch:
pull_request:
paths:
- '**/*.php'
- 'tests/php/**'
- 'tests/bootstrap.php'
- 'tests/wp-tests-config.php'
- 'tests/bin/initialize.sh'
- 'build/**'
- 'src/**'
- 'composer.json'
- 'composer.lock'
- 'package.json'
- 'package-lock.json'
- 'webpack.config.js'
- 'phpunit.xml.dist'
- '.wp-env.test.json'
- '.github/workflows/tests-php.yml'
push:
branches:
- main
paths:
- '**/*.php'
- 'tests/php/**'
- 'tests/bootstrap.php'
- 'tests/wp-tests-config.php'
- 'tests/bin/initialize.sh'
- 'src/**'
- 'composer.json'
- 'composer.lock'
- 'package.json'
- 'package-lock.json'
- 'webpack.config.js'
- 'build/**'
- 'phpunit.xml.dist'
- '.wp-env.test.json'
- '.github/workflows/tests-php.yml'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
test-php:
name: PHPUnit - WP ${{ matrix.core || 'latest' }} / PHP ${{ matrix.php }}
runs-on: ubuntu-22.04
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
php: ['8.1', '8.3']
# null = latest official WordPress release (wp-env default).
core: [null]
include:
- php: '8.1'
core: 'WordPress/WordPress#6.4'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v7
with:
node-version-file: 'package.json'
cache: 'npm'
- name: Install npm dependencies
run: npm ci
- name: Build plugin assets
run: npm run build
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: none
- name: Install Composer dependencies
run: composer install --no-interaction --prefer-dist --optimize-autoloader
- name: Check platform requirements
run: |
composer check-platform-reqs --lock --no-dev
composer check-platform-reqs --lock
- name: Launch test environment
env:
WP_ENV_PHP_VERSION: ${{ matrix.php }}
WP_ENV_CORE: ${{ matrix.core }}
run: npm run env:start-ci
- name: Run PHPUnit
run: npm run test:php
- name: Stop test environment
if: always()
continue-on-error: true
run: npm run env:stop-tests
coverage:
name: PHPUnit coverage
runs-on: ubuntu-22.04
timeout-minutes: 20
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v7
with:
node-version-file: 'package.json'
cache: 'npm'
- name: Install npm dependencies
run: npm ci
- name: Build plugin assets
run: npm run build
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
coverage: none
- name: Install Composer dependencies
run: composer install --no-interaction --prefer-dist --optimize-autoloader
- name: Launch coverage environment
env:
WP_ENV_PHP_VERSION: '8.1'
run: npm run env:start-tests
- name: Run PHPUnit with coverage
run: npm run test:php:coverage
- name: Upload coverage report
if: always()
uses: actions/upload-artifact@v4
with:
name: phpunit-coverage
path: coverage
if-no-files-found: warn
- name: Stop coverage environment
if: always()
continue-on-error: true
run: npm run env:stop-tests