-
Notifications
You must be signed in to change notification settings - Fork 1
144 lines (114 loc) · 3.4 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
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
name: Unit Tests
# Only run the workflow for pull requests
on: pull_request
# Cancels all previous workflow runs for pull requests that have not completed.
concurrency:
# The concurrency group contains the workflow name and the branch name for pull requests
# or the commit hash for any other events.
group: ${{ github.workflow }}-${{ github.ref}}
cancel-in-progress: true
jobs:
lint-js:
name: JavaScript linting
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up NodeJS
uses: actions/setup-node@v4
with:
node-version: 'lts/*'
cache: npm
- name: Build the plugin
run: |
npm ci
- name: Lint JS files
run: npm run lint:js
unit-js:
name: JavaScript Unit Tests
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up NodeJS
uses: actions/setup-node@v4
with:
node-version: 'lts/*'
cache: npm
- name: Build the plugin
run: |
npm ci
- name: Running the tests
run: npm run test:js
phpcs:
name: PHP coding standards
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php-versions:
- 8.0
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
tools: composer
php-version: ${{ matrix.php-versions }}
- name: Validate composer.json and composer.lock
run: composer validate --strict
- name: Install Composer dependencies
uses: ramsey/composer-install@v3
with:
composer-options: --prefer-dist --no-progress
- name: PHPCS
run: composer run-script phpcs
unit-php:
# Alias 'master' to 'latest'
name: WP ${{ matrix.wp }} and PHP ${{ matrix.php }}
runs-on: ubuntu-latest
continue-on-error: ${{ matrix.allowed_failure }}
strategy:
fail-fast: false
matrix:
include:
# Check lowest supported WP version, with the lowest supported PHP.
- php: '8.0'
wp: '6.0'
allowed_failure: false
# Check latest WP with the lowest supported PHP.
- php: '8.0'
wp: 'master'
allowed_failure: false
# Check latest WP with the highest supported PHP.
- php: '8.3'
wp: 'master'
allowed_failure: false
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install wordpress environment
run: npm -g install @wordpress/env
- name: Setup PHP ${{ matrix.php }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: composer
- name: Install Composer dependencies
uses: ramsey/composer-install@v3
with:
composer-options: --prefer-dist --no-progress
- name: Setup wp-env
run: wp-env start
env:
WP_ENV_CORE: WordPress/WordPress#${{ matrix.wp }}
WP_ENV_PHP_VERSION: ${{ matrix.php }}
- name: PHPUnit
run: composer test --no-interaction
- name: PHPUnit multisite
run: composer run-script test-multisite --no-interaction