Skip to content

Commit d74a1fa

Browse files
committed
feat(CodeCov) add Codecov phpunit code coverage.
1 parent 7f1a8b5 commit d74a1fa

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

.github/workflows/phpunit.yml

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ jobs:
99
fail-fast: false
1010
max-parallel: 4
1111
matrix:
12+
coverage: ['none']
1213
include:
1314
- php: '7.0'
1415
phpseclib: '^2.0'
@@ -20,6 +21,7 @@ jobs:
2021
phpseclib: '^3.0'
2122
- php: '7.4'
2223
phpseclib: '^3.0'
24+
coverage: 'xdebug'
2325
services:
2426
rabbitmq:
2527
image: rabbitmq:3-management
@@ -40,21 +42,39 @@ jobs:
4042
steps:
4143
- name: Checkout
4244
uses: actions/checkout@v2
45+
4346
- name: Install PHP
4447
uses: shivammathur/setup-php@v2
4548
with:
4649
php-version: ${{ matrix.php }}
4750
tools: composer:v1
4851
extensions: bcmath, curl, dom, mbstring, pcntl, sockets, xml
49-
coverage: none
52+
coverage: ${{ matrix.coverage }}
53+
5054
- name: Check PHP info
5155
run: php tests/phpinfo.php
56+
5257
- name: Start broker service
5358
run: docker start ${{ job.services.rabbitmq.id }}
59+
5460
- name: Composer install
5561
run: composer require --prefer-dist --no-progress --no-suggest phpseclib/phpseclib ${{ matrix.phpseclib }}
62+
5663
- name: Wait for broker service
5764
run: php ./tests/wait_broker.php
65+
5866
- name: PHPUnit tests
5967
run: ./vendor/bin/phpunit --exclude-group proxy
68+
if: matrix.coverage == 'none'
69+
70+
- name: PHPUnit tests and Log Code coverage
71+
run: ./vendor/bin/phpunit --exclude-group proxy --coverage-clover=coverage.xml
72+
if: matrix.coverage == 'xdebug'
73+
74+
- name: Run codecov
75+
uses: codecov/codecov-action@v1
76+
if: matrix.coverage == 'xdebug'
77+
with:
78+
file: './coverage.xml'
79+
fail_ci_if_error: true
6080

phpunit.xml.dist

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
<directory suffix="Test.php" phpVersionOperator=">=">tests/Functional</directory>
1818
</testsuite>
1919
</testsuites>
20+
<logging>
21+
<log type="coverage-clover" target="clover.xml"/>
22+
</logging>
2023
<filter>
2124
<whitelist>
2225
<directory suffix=".php">PhpAmqpLib/</directory>

0 commit comments

Comments
 (0)