Repository navigation
104 lines (94 loc) · 4.03 KB
/
Copy pathphpunit.yml
File metadata and controls
104 lines (94 loc) · 4.03 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
on:
pull_request:
types: [ opened, labeled, synchronize ]
name: PHPUnit
# Cancel superseded runs for the same branch. The group is named explicitly
# rather than derived from github.workflow: several files share the workflow
# name `Inspections` and would otherwise cancel each other.
concurrency:
group: formidable-phpunit-${{ github.ref }}-${{ ((contains(github.event.pull_request.labels.*.name, 'run tests') || contains(github.event.pull_request.labels.*.name, 'full automated qa')) && (github.event.action != 'labeled' || github.event.label.name == 'run tests' || github.event.label.name == 'full automated qa')) && 'active' || github.run_id }}
cancel-in-progress: true
jobs:
build-test:
if: >-
(contains(github.event.pull_request.labels.*.name, 'run tests') || contains(github.event.pull_request.labels.*.name, 'full automated qa'))
&& (github.event.action != 'labeled' || github.event.label.name == 'run tests' || github.event.label.name == 'full automated qa')
runs-on: ubuntu-latest
env:
WP_DEVELOP_DIR: /tmp/wordpress/
WP_MULTISITE: ${{ matrix.multisite }}
strategy:
matrix:
include:
- php: '7.4'
phpunit: '9.6'
config: phpunit9.xml
wordpress: trunk
multisite: 0
- php: '8.0'
phpunit: '9.6'
config: phpunit9.xml
wordpress: trunk
multisite: 0
- php: '8.2'
phpunit: '11.5'
config: phpunit.xml
wordpress: trunk
multisite: 0
- php: '8.4'
phpunit: '12.5'
config: phpunit.xml
wordpress: trunk
multisite: 0
name: PHP ${{ matrix.php }} / PHPUnit ${{ matrix.phpunit }} tests in WP ${{ matrix.wordpress }}
steps:
- uses: actions/checkout@v3.5.0
# get the PHP version
- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: composer:v2
coverage: xdebug
- name: Installing test dependencies
run: |
jq -n --arg phpunit '${{ matrix.phpunit }}.*' '{"require-dev": {"phpunit/phpunit": $phpunit, "yoast/phpunit-polyfills": "^4.0"}}' > composer.tests.json
COMPOSER=composer.tests.json composer install --no-interaction --prefer-dist
- name: Installing WordPress
run: |
export WP_DEVELOP_DIR=/tmp/wordpress/
git clone --depth=1 --branch="${{ matrix.wordpress }}" https://github.com/WordPress/wordpress-develop.git /tmp/wordpress
cd ..
cp -r "${GITHUB_REPOSITORY#*/}" "/tmp/wordpress/src/wp-content/plugins/formidable"
cd /tmp/wordpress/
pwd
cp wp-tests-config-sample.php wp-tests-config.php
sed -i "s/youremptytestdbnamehere/wordpress_tests/" wp-tests-config.php
sed -i "s/yourusernamehere/root/" wp-tests-config.php
sed -i "s/yourpasswordhere/root/" wp-tests-config.php
- name: Read WP core's required Node version
id: wp-node
run: echo "version=$(cat /tmp/wordpress/.nvmrc)" >> "$GITHUB_OUTPUT"
- name: Set up Node.js for WP core assets
uses: actions/setup-node@v5
with:
node-version: ${{ steps.wp-node.outputs.version }}
- name: Building WP core assets
# Core's dist JS/CSS isn't checked into git; missing it fails wp_head()'s
# wp_maybe_inline_styles() check (test_front_head).
run: |
cd /tmp/wordpress
npm ci
npm run build:dev
- name: Creating database
run: |
sudo /etc/init.d/mysql start
mysql -u root -proot -e "CREATE DATABASE wordpress_tests;"
- name: PhpUnit tests
run: |
cd "/tmp/wordpress/src/wp-content/plugins/formidable"
pwd
./vendor/bin/phpunit -c "${{ matrix.config }}" --coverage-clover=coverage.xml
- name: Send code coverage report to Codecov.io
uses: codecov/codecov-action@v2
with:
files: /tmp/wordpress/src/wp-content/plugins/formidable/coverage.xml