-
Notifications
You must be signed in to change notification settings - Fork 154
114 lines (95 loc) · 4.55 KB
/
unit-testing.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
on:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# Triggers the workflow on push events only for the matching branches
push:
branches:
- 'release/**'
env:
COMPOSER_VERSION: '2.6'
ACTION_VERSION: 3
jobs:
matrix_unit_testing:
runs-on: ubuntu-latest
continue-on-error: ${{ matrix.bleeding-edge }}
strategy:
fail-fast: false
matrix:
job-name: ['Unit Test']
php-version: ['7.4','8.0']
wordpress-version: ['5.7.*','5.8.*','5.9.*']
wp-multisite-mode: [0]
bleeding-edge: [false]
include:
- job-name: 'Unit Test Bleeding Edge Requirements'
bleeding-edge: true
php-version: '8.1'
wordpress-version: 'dev-master'
wp-multisite-mode: 0
- job-name: 'Unit Test Multisite Compatibility Requirements'
bleeding-edge: false
php-version: '8.0'
wordpress-version: '5.9.*'
wp-multisite-mode: 1
name: '${{ matrix.job-name }} (PHP:${{ matrix.php-version }}/WP:${{ matrix.wordpress-version }})'
steps:
- name: Checkout Code
# https://github.com/marketplace/actions/checkout
uses: actions/checkout@v2
- name: Get Composer Cache Directory
id: composer-cache
if: ${{ !env.ACT }}
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache Composer dependencies
if: ${{ !env.ACT }}
uses: actions/cache@v2
env:
composer-cache-name: cache-composer
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-build-${{ env.composer-cache-name }}-wp-${{ matrix.wordpress-version }}-v${{ env.ACTION_VERSION }}-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-build-${{ env.composer-cache-name }}-wp-${{ matrix.wordpress-version }}-v${{ env.ACTION_VERSION }}-
- name: Setup Node Environment
# https://github.com/marketplace/actions/setup-node-js-environment
uses: actions/setup-node@v2
with:
node-version-file: '.nvmrc'
cache: ${{ !env.ACT && 'npm' || '' }}
- name: Setup PHP & Composer Environment
# https://github.com/marketplace/actions/setup-php-action
uses: shivammathur/setup-php@v2
with:
php-version: "${{ matrix.php-version }}"
tools: "composer:${{ env.COMPOSER_VERSION }}"
- name: Environment Check
run: php -v && composer --version
- name: Require Specified WordPress Version (PHP <7.4)
if: matrix.php-version == '7.3' || matrix.php-version == '7.2'
run: composer require johnpbloch/wordpress-core:${{ matrix.wordpress-version }} php-stubs/wordpress-stubs:${{ matrix.wordpress-version }} wp-phpunit/wp-phpunit:${{ matrix.wordpress-version }} --dev --prefer-source --update-with-all-dependencies --ignore-platform-req=php
- name: Require Specified WordPress Version (Bleeding Edge)
if: matrix.bleeding-edge
run: composer require johnpbloch/wordpress-core:${{ matrix.wordpress-version }} php-stubs/wordpress-stubs:${{ matrix.wordpress-version }} szepeviktor/phpstan-wordpress:* wp-phpunit/wp-phpunit:${{ matrix.wordpress-version }} --dev --prefer-source --update-with-all-dependencies
- name: Require Specified WordPress Version
if: matrix.php-version != '7.3' && matrix.php-version != '7.2' && ! matrix.bleeding-edge
run: composer require johnpbloch/wordpress-core:${{ matrix.wordpress-version }} php-stubs/wordpress-stubs:${{ matrix.wordpress-version }} wp-phpunit/wp-phpunit:${{ matrix.wordpress-version }} --dev --prefer-source --update-with-all-dependencies
- name: PHPUnit Bleeding Edge Support
if: matrix.bleeding-edge
run: |
composer require sebastian/code-unit:dev-main phpunit/phpunit:dev-master phpro/grumphp:dev-master --dev -W --ignore-platform-req=php --update-with-all-dependencies
- name: PHPUnit PHP 8.0 Support
if: matrix.php-version == '8.0'
run: |
composer require phpunit/phpunit:^8.0 phpro/grumphp:^1.10.0 --dev -W --ignore-platform-req=php
- name: Install Composer Dependencies (PHP 8.x)
if: matrix.php-version == '8.0' || matrix.php-version == '8.1'
run: composer install --prefer-dist --ignore-platform-req=php
- name: Install Composer Dependencies
if: matrix.php-version != '8.0' && matrix.php-version != '8.1'
run: composer install --prefer-dist
- name: NPM Setup
run: npm ci
- name: Unit Tests
env:
WP_MULTISITE: ${{ matrix.wp-multisite-mode }}
run: npm run test