Skip to content

Commit 849b903

Browse files
committed
GitHub Actions: Add test workflow
1 parent 0388a6b commit 849b903

File tree

3 files changed

+101
-17
lines changed

3 files changed

+101
-17
lines changed

.github/workflows/test.yml

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: Test
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
branches:
7+
- master
8+
- v2 # Temporary until v2 is merged into master
9+
push:
10+
branches:
11+
- master
12+
- v2 # Temporary until v2 is merged into master
13+
14+
concurrency:
15+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref_name }}-${{ github.event.pull_request.number || github.sha }}
16+
cancel-in-progress: true
17+
18+
permissions: {}
19+
20+
jobs:
21+
phpunit:
22+
runs-on: ubuntu-latest
23+
permissions:
24+
contents: read
25+
strategy:
26+
matrix:
27+
php: ['8.1', '8.2', '8.3', '8.4']
28+
dependency-versions: [lowest, highest]
29+
coverage: [none]
30+
exclude:
31+
- php: '8.4'
32+
dependency-versions: highest
33+
coverage: none
34+
include:
35+
- php: '8.4'
36+
dependency-versions: highest
37+
coverage: xdebug
38+
steps:
39+
- uses: actions/checkout@v4
40+
41+
- uses: shivammathur/setup-php@v2
42+
with:
43+
php-version: ${{ matrix.php }}
44+
coverage: ${{ matrix.coverage }}
45+
env:
46+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
47+
48+
- uses: ramsey/composer-install@v3
49+
with:
50+
dependency-versions: ${{ matrix.dependency-versions }}
51+
composer-options: --no-audit --optimize-autoloader
52+
53+
- run: composer test -- --coverage-clover coverage.xml
54+
if: ${{ matrix.coverage == 'xdebug' }}
55+
56+
- run: composer test -- --no-coverage
57+
if: ${{ matrix.coverage != 'xdebug' }}
58+
59+
- uses: actions/upload-artifact@v4
60+
if: ${{ matrix.coverage == 'xdebug' }}
61+
with:
62+
name: coverage
63+
path: coverage.xml
64+
65+
coveralls:
66+
needs: phpunit
67+
runs-on: ubuntu-latest
68+
permissions:
69+
contents: read
70+
steps:
71+
- uses: actions/download-artifact@v4
72+
with:
73+
name: coverage
74+
- uses: coverallsapp/github-action@v2
75+
with:
76+
file: coverage.xml

.gitignore

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
/vendor/
22
/coverage/
3-
/composer.lock
3+
/composer.lock
4+
5+
# PHPUnit
6+
/.phpunit.cache
7+
/coverage.xml

phpunit.xml

+20-16
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,25 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit backupGlobals="false"
3-
backupStaticAttributes="false"
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
44
bootstrap="vendor/autoload.php"
5-
colors="true"
6-
convertErrorsToExceptions="true"
7-
convertNoticesToExceptions="true"
8-
convertWarningsToExceptions="true"
9-
processIsolation="false"
10-
stopOnFailure="false">
5+
cacheDirectory=".phpunit.cache"
6+
executionOrder="depends,defects"
7+
requireCoverageMetadata="false"
8+
beStrictAboutCoverageMetadata="true"
9+
beStrictAboutOutputDuringTests="true"
10+
displayDetailsOnPhpunitDeprecations="true"
11+
failOnPhpunitDeprecation="true"
12+
failOnRisky="true"
13+
failOnWarning="true">
1114
<testsuites>
12-
<testsuite name="Config">
13-
<directory suffix="Test.php">tests</directory>
15+
<testsuite name="default">
16+
<directory>tests</directory>
1417
</testsuite>
1518
</testsuites>
16-
<filter>
17-
<whitelist processUncoveredFilesFromWhitelist="true">
18-
<directory suffix=".php">src</directory>
19-
</whitelist>
20-
</filter>
21-
</phpunit>
19+
20+
<source restrictDeprecations="true" restrictNotices="true" restrictWarnings="true">
21+
<include>
22+
<directory>src</directory>
23+
</include>
24+
</source>
25+
</phpunit>

0 commit comments

Comments
 (0)