-
Notifications
You must be signed in to change notification settings - Fork 4
72 lines (60 loc) · 2.65 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
name: PHP unit tests
on:
push:
paths:
- '**workflows/php-unit-tests.yml'
- '**.php'
- '**phpunit.xml.dist'
- '**composer.json'
pull_request:
paths:
- '**workflows/php-unit-tests.yml'
- '**.php'
- '**phpunit.xml.dist'
- '**composer.json'
workflow_dispatch:
concurrency:
group: "${{ github.workflow }}-${{ github.ref }}"
cancel-in-progress: true
jobs:
tests-unit-php:
runs-on: ubuntu-latest
if: ${{ (github.event_name == 'workflow_dispatch') || (!contains(github.event.head_commit.message, 'skip tests')) }}
env:
USE_COVERAGE: 'no'
strategy:
matrix:
php-versions: [ '7.4', '8.0', '8.1', '8.2', '8.3' ]
dependency-versions: [ 'lowest', 'highest' ]
container-versions: [ '^1.1.0', '^2' ]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Use coverage?
if: ${{ (matrix.php-versions == '8.2') && (matrix.dependency-versions == 'highest') && (matrix.container-versions == '^2') }}
run: echo "USE_COVERAGE=yes" >> $GITHUB_ENV
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
ini-values: zend.assertions=1, error_reporting=-1, display_errors=On
coverage: ${{ ((env.USE_COVERAGE == 'yes') && 'xdebug') || 'none' }}
- name: Setup dependencies for PSR-11 target version
run: |
composer remove inpsyde/php-coding-standards inpsyde/wp-stubs-versions vimeo/psalm --dev --no-update
composer require "psr/container:${{ matrix.container-versions }}" --no-update
composer config --no-plugins allow-plugins.roots/wordpress-core-installer false
- name: Install Composer dependencies
uses: ramsey/composer-install@v3
with:
dependency-versions: ${{ matrix.dependency-versions }}
- name: Run unit tests
run: ./vendor/bin/phpunit ${{ ((env.USE_COVERAGE == 'yes') && '--coverage-clover coverage.xml') || '--no-coverage' }}
- name: Update coverage
if: ${{ env.USE_COVERAGE == 'yes' }}
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.xml
flags: unittests
verbose: true