Repository navigation
131 lines (107 loc) · 3.36 KB
/
Copy pathtests-php.yml
File metadata and controls
131 lines (107 loc) · 3.36 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
# 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'
- 'src/**'
- 'tests/php/**'
- 'tests/bootstrap.php'
- 'tests/wp-tests-config.php'
- 'composer.json'
- 'package.json'
- 'package-lock.json'
- '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']
core: ['WordPress/WordPress#6.7', null]
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Set up Node.js
uses: actions/setup-node@v5
with:
node-version-file: 'package.json'
cache: 'npm'
- name: Install npm dependencies
run: npm ci
# The block is registered from build/, which is not versioned.
- 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
# Production requirements only: dev tools are resolved for the simulated
# platform (config.platform.php) and some need a newer PHP than the plugin.
- name: Check production platform requirements
run: composer check-platform-reqs --no-dev
- 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@v5
- name: Set up Node.js
uses: actions/setup-node@v5
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-html=coverage/ --coverage-text
- name: Upload coverage report
if: always()
uses: actions/upload-artifact@v5
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