-
Notifications
You must be signed in to change notification settings - Fork 0
114 lines (98 loc) · 4.87 KB
/
Copy pathphpunit.yml
File metadata and controls
114 lines (98 loc) · 4.87 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
105
106
107
108
109
110
111
112
113
114
name: PHPunit
on: [ push ]
# Cancels all previous workflow runs for the same branch that have not yet completed.
concurrency:
# The concurrency group contains the workflow name and the branch name.
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
phpunit:
runs-on: ${{ matrix.os }}
env:
IS_MAIN_ENV: ${{ github.ref == 'refs/heads/master' && matrix.php == '8.2' && matrix.symfony == '~6.4' && matrix.dependency-versions == 'highest' }}
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest ]
# When you change a version here, change it also in the SonarCloud if condition
php: [ '8.2', '8.3', '8.4', '8.5' ]
symfony: [ '~6.4', '~7.4', '~8.0' ]
dependency-versions: [ lowest, highest ]
exclude:
- php: '8.2'
symfony: '~8.0'
- php: '8.3'
symfony: '~8.0'
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Setup PHP
uses: shivammathur/setup-php@2.37.2
with:
php-version: ${{ matrix.php }}
coverage: ${{ env.IS_MAIN_ENV == 'true' && 'pcov' || 'none' }}
extensions: ast
- name: Get Composer Cache Directory
id: composer-cache
run: |
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache Composer's dependencies
uses: actions/cache@v6
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: php-composer-dependencies-cache
- name: Fix Symfony version
run: |
composer req symfony/flex --no-update
composer config extra.symfony.require "${{ matrix.symfony }}"
composer config --no-plugins allow-plugins.symfony/flex true
- name: Install Composer deps
uses: ramsey/composer-install@v4
with:
composer-options: --no-scripts
- name: Update Composer deps (with Flex)
# The second update is to make Flex able to do its job
run: |
if [ "${{ matrix.dependency-versions }}" == "lowest" ]; then
# On PHP 8.4+ and Symfony 7.4/8.0, the "lowest" dependencies may install an incompatible version of phpstan/phpdoc-parser (2.x)
# that is not compatible with the installed version of symfony/property-info.
# We force phpstan/phpdoc-parser to ^1.33 to avoid the TypeError.
if [[ "${{ matrix.php }}" == "8.4" || "${{ matrix.php }}" == "8.5" ]] && [[ "${{ matrix.symfony }}" == "~7.4" || "${{ matrix.symfony }}" == "~8.0" ]]; then
composer update --no-interaction --no-scripts --prefer-lowest --with="phpstan/phpdoc-parser:^2"
else
composer update --no-interaction --no-scripts --prefer-lowest
fi
else
composer update --no-interaction --no-scripts
fi
- name: Install Composer bin PHPUnit
uses: ramsey/composer-install@v4
with:
working-directory: './vendor-bin/phpunit'
- name: Run PHPunit
run: |
if [ "${{ env.IS_MAIN_ENV }}" == "true" ]; then
./vendor-bin/phpunit/vendor/bin/phpunit --coverage-clover var/coverage/clover.xml --log-junit junit.xml
else
./vendor-bin/phpunit/vendor/bin/phpunit
fi
- name: Change paths in clover.xml
if: env.IS_MAIN_ENV == 'true'
run: |
sed -i 's+/home/runner/work/component-dc-verifier/component-dc-verifier+/github/workspace+g' var/coverage/clover.xml
- name: Upload test results to Codecov
if: ${{ !cancelled() && env.IS_MAIN_ENV == 'true' }}
uses: codecov/codecov-action@v7
with:
token: ${{ secrets.CODECOV_TOKEN }}
flags: ${{matrix.symfony}},${{matrix.php}}
report_type: test_results
files: junit.xml
- name: Upload coverage reports to Codecov
if: env.IS_MAIN_ENV == 'true'
uses: codecov/codecov-action@v7
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: false
verbose: true
files: ./var/coverage/clover.xml