-
Notifications
You must be signed in to change notification settings - Fork 21
90 lines (78 loc) · 2.64 KB
/
php-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
name: PHP Unit Tests
on:
push:
branches:
- trunk
- develop
paths:
- "**.php"
- composer.json
- composer.lock
- .github/workflows/php-unit-tests.yml
pull_request:
paths:
- "**.php"
- composer.json
- composer.lock
- .github/workflows/php-unit-tests.yml
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
GetMatrix:
name: Get WP version Matrix
runs-on: ubuntu-latest
outputs:
wp-versions: ${{ steps.wp.outputs.versions }}
latest-wp-version: ${{ fromJson(steps.wp.outputs.versions)[0] }}
steps:
- name: Get Release versions from Wordpress
id: wp
uses: woocommerce/grow/get-plugin-releases@actions-v1
with:
slug: wordpress
UnitTests:
name: PHP unit tests - PHP ${{ matrix.php }}, WP ${{ matrix.wp-version }}
needs: GetMatrix
runs-on: ubuntu-latest
env:
WP_CORE_DIR: "/tmp/wordpress/src"
WP_TESTS_DIR: "/tmp/wordpress/tests/phpunit"
strategy:
matrix:
php: [8.0]
wp-version: ${{ fromJson(needs.GetMatrix.outputs.wp-versions) }}
include:
- php: 7.4
wp-version: ${{ needs.GetMatrix.outputs.latest-wp-version }}
- php: 8.1
wp-version: ${{ needs.GetMatrix.outputs.latest-wp-version }}
- php: 8.2
wp-version: ${{ needs.GetMatrix.outputs.latest-wp-version }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Prepare PHP
uses: woocommerce/grow/prepare-php@actions-v1
with:
php-version: "${{ matrix.php }}"
- name: Prepare MySQL
uses: woocommerce/grow/prepare-mysql@actions-v1
- name: Install WP tests
run: ./bin/install-wp-tests.sh wordpress_test root root localhost ${{ matrix.wp-version }}
- if: matrix.wp-version == needs.GetMatrix.outputs.latest-wp-version && matrix.php == 8.0
name: Set condition to generate coverage report (only on latest versions)
run: echo "generate_coverage=true" >> $GITHUB_ENV
- if: env.generate_coverage != 'true'
name: Run PHP unit tests
run: composer test-unit
- if: env.generate_coverage == 'true'
name: Run PHP unit tests (with code coverage)
run: phpdbg -qrr vendor/bin/phpunit --coverage-clover=tests/php-coverage/report.xml
- if: env.generate_coverage == 'true'
name: PHP unit coverage report
uses: codecov/codecov-action@v3
with:
files: tests/php-coverage/report.xml
flags: php-unit-tests
name: php-coverage-report