Skip to content

Commit 924ee80

Browse files
authored
Added github actions to run phpunit tests (#378)
The ci.yml is configured to run the phpunit tests on any push to the repository. This will run the tests for a matrix of PHP versions to ensure all major versions supported are properly tests. In addition, if the tests all pass, code coverage for the tests will be generated and uploaded as an artifact of the run so they can be downloaded and examined. To support this I needed to specify which directories to be included in the code coverage in the phpunit.xml file.
1 parent c6cf851 commit 924ee80

2 files changed

Lines changed: 46 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: CI
2+
3+
on: [push]
4+
5+
jobs:
6+
build-test:
7+
runs-on: ubuntu-latest
8+
strategy:
9+
matrix:
10+
php-versions:
11+
- 5.4
12+
- 5.5
13+
- 5.6
14+
- 7.2
15+
- 7.3
16+
- 7.4
17+
- 8.2
18+
- 8.3
19+
- nightly
20+
21+
steps:
22+
- uses: actions/checkout@v3
23+
24+
- uses: php-actions/composer@v6
25+
26+
- name: PHPUnit Tests
27+
uses: php-actions/phpunit@master
28+
env:
29+
XDEBUG_MODE: coverage
30+
with:
31+
php_extensions: "xdebug"
32+
coverage_html: "coverage/html/"
33+
version: 9.5
34+
bootstrap: tests/bootstrap.php
35+
configuration: phpunit.xml
36+
37+
- name: Archive code coverage results
38+
uses: actions/upload-artifact@v3
39+
with:
40+
name: code-coverage-report
41+
path: coverage/html

phpunit.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,9 @@
88
<directory suffix="Test.php">tests</directory>
99
</testsuite>
1010
</testsuites>
11+
<coverage includeUncoveredFiles="true">
12+
<include>
13+
<directory suffix=".php">./src</directory>
14+
</include>
15+
</coverage>
1116
</phpunit>

0 commit comments

Comments
 (0)