-
Notifications
You must be signed in to change notification settings - Fork 38
95 lines (79 loc) · 2.7 KB
/
unit-tests.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
name: Unit Tests
on:
pull_request:
push:
branches: [ master ]
jobs:
tests:
name: "WP: ${{ matrix.wp_version }} - PHP: ${{ matrix.php }}"
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php: ['7.4', '8.0', '8.1', '8.2']
wp_version: ['master']
include:
- php: '8.0'
wp_version: '6.4'
- php: '7.4'
wp_version: '6.4'
- php: '7.4'
wp_version: '6.1'
env:
WP_ENV_PHP_VERSION: ${{ matrix.php }}
WP_VERSION: ${{ matrix.wp_version }}
steps:
- name: Cancel previous runs of this workflow (pull requests only)
if: ${{ github.event_name == 'pull_request' }}
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}
- name: Checkout repository
uses: actions/checkout@v4
- name: Check Gitignored files
run: if [[ ! -z $(git ls-files -i --exclude-standard) ]]; then exit 1; fi
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: composer:v2
coverage: none
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '>=20.10.0'
- name: Install Composer dependencies
uses: ramsey/composer-install@v3
with:
composer-options: "--ignore-platform-reqs --optimize-autoloader"
- name: Cache node modules
uses: actions/cache@v4
env:
cache-name: cache-node-modules
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Validate node modules
run: if [[ -f package.json ]]; then npm audit --audit-level=high --omit=dev --cache ~/.npm; fi
- name: Install node modules
run: npm ci --cache ~/.npm
- name: Setup WordPress
run: echo "{\"core\":\"WordPress/WordPress#${WP_VERSION}\"}" >> .wp-env.override.json
- name: Install WordPress
run: |
chmod -R 767 ./
npm run wp-env start -- --update
- name: Running single site unit tests
run: npm run test-php
if: ${{ success() || failure() }}
- name: Running multisite unit tests
run: npm run test-php-multisite
if: ${{ success() || failure() }}
- name: Stop Docker environment
run: npm run wp-env stop
if: ${{ success() || failure() }}