-
Notifications
You must be signed in to change notification settings - Fork 0
81 lines (68 loc) · 2.38 KB
/
tests.yml
File metadata and controls
81 lines (68 loc) · 2.38 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
name: Tests
on:
push:
branches:
- trunk
- 'copilot/**'
pull_request:
branches:
- trunk
- 'copilot/**'
jobs:
# ---------------------------------------------------------------------------
# JavaScript unit tests (Jest, no Docker needed)
# ---------------------------------------------------------------------------
js-tests:
name: JS Unit Tests
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
# No cache — lock file is not committed.
- name: Install dependencies
run: npm install --legacy-peer-deps
- name: Run JS unit tests
run: npm run test:unit
# ---------------------------------------------------------------------------
# PHP unit tests — run inside wp-env (Docker)
# ---------------------------------------------------------------------------
php-tests:
name: "PHP ${{ matrix.php }} Tests (wp-env)"
runs-on: ubuntu-latest
permissions:
contents: read
strategy:
fail-fast: false
matrix:
# PRs test only the oldest and newest supported versions.
# Pushes to trunk/copilot branches test the full range.
php: ${{ github.event_name == 'push' && fromJSON('["7.4","8.0","8.1","8.2","8.3","8.4","8.5"]') || fromJSON('["7.4","8.5"]') }}
steps:
- uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
# No cache — lock file is not committed.
- name: Install dependencies
run: npm install --legacy-peer-deps
- name: Override PHP version
run: |
echo '{ "phpVersion": "${{ matrix.php }}" }' > .wp-env.override.json
- name: Start wp-env
run: npx wp-env start
env:
# wp-env pulls Docker images; increase timeout for CI.
WP_ENV_LIFECYCLE_TIMEOUT: 300
- name: Install Composer dependencies
run: npx wp-env run cli --env-cwd=wp-content/plugins/multi-author-posts -- composer install --no-interaction
- name: Run PHP tests via wp-env
run: npx wp-env run cli --env-cwd=wp-content/plugins/multi-author-posts -- vendor/bin/phpunit
- name: Stop wp-env
if: always()
run: npx wp-env stop