Skip to content

Commit 712d04d

Browse files
committed
Add code coverage to testing
Signed-off-by: Matt Friedman <maf675@gmail.com>
1 parent b19a2cb commit 712d04d

2 files changed

Lines changed: 37 additions & 2 deletions

File tree

.github/codecov.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
fixes:
2+
- "/phpBB3/phpBB/ext/phpbb/ideas/::"

.github/workflows/tests.yml

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ jobs:
113113
db: "mysql:5.7"
114114
- php: '7.2'
115115
db: "mysql:5.7"
116+
COVERAGE: 1
117+
db_alias: "mysql:5.7 with Coverage"
116118
- php: '7.3'
117119
db: "mysql:5.7"
118120
- php: '7.4'
@@ -173,12 +175,21 @@ jobs:
173175
echo "db=$db" >> $GITHUB_OUTPUT
174176
175177
- name: Setup PHP
178+
if: ${{ matrix.COVERAGE != 1 }}
176179
uses: shivammathur/setup-php@v2
177180
with:
178181
php-version: ${{ matrix.php }}
179182
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, mysqli, sqlite, pdo_sqlite, intl, gd, exif, iconv, sqlsrv, pdo_sqlsrv, ldap
180183
coverage: none
181184

185+
- name: Setup PHP with Coverage
186+
if: ${{ matrix.COVERAGE == 1 }}
187+
uses: shivammathur/setup-php@v2
188+
with:
189+
php-version: ${{ matrix.php }}
190+
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, mysqli, sqlite, pdo_sqlite, intl, gd, exif, iconv, sqlsrv, pdo_sqlsrv, ldap
191+
coverage: xdebug
192+
182193
- name: Setup environment for phpBB
183194
env:
184195
DB: ${{steps.database-type.outputs.db}}
@@ -195,14 +206,36 @@ jobs:
195206
working-directory: ./phpBB3
196207

197208
- name: Setup PHPUnit files
198-
run: mkdir -p phpBB/ext/$EXTNAME/.github && cp .github/phpunit* $_
209+
env:
210+
DB: ${{steps.database-type.outputs.db}}
211+
COVERAGE: ${{ matrix.COVERAGE != 1 && '0' || '1' }}
212+
run: |
213+
if [ $COVERAGE == '1' ]
214+
then
215+
sed -n '1h;1!H;${;g;s/<\/php>/<\/php>\n\t<filter>\n\t\t<whitelist>\n\t\t\t<directory>..\/<\/directory>\n\t\t\t<exclude>\n\t\t\t\t<directory>..\/tests\/<\/directory>\n\t\t\t\t<directory>..\/language\/<\/directory>\n\t\t\t\t<directory>..\/migrations\/<\/directory>\n\t\t\t<\/exclude>\n\t\t<\/whitelist>\n\t<\/filter>/g;p;}' .github/phpunit-$DB-github.xml &> phpBB/ext/$EXTNAME/.github/phpunit-$DB-github.xml
216+
else
217+
mkdir -p phpBB/ext/$EXTNAME/.github && cp .github/phpunit* $_
218+
fi
199219
working-directory: ./phpBB3
200220

201221
- name: Run unit tests
202222
env:
203223
DB: ${{steps.database-type.outputs.db}}
204-
run: phpBB/vendor/bin/phpunit --configuration phpBB/ext/$EXTNAME/.github/phpunit-$DB-github.xml --bootstrap ./tests/bootstrap.php
224+
COVERAGE: ${{ matrix.COVERAGE != 1 && '0' || '1' }}
225+
run: |
226+
if [ $COVERAGE == '1' ]
227+
then
228+
phpBB/vendor/bin/phpunit --configuration phpBB/ext/$EXTNAME/.github/phpunit-$DB-github.xml --bootstrap ./tests/bootstrap.php --coverage-clover build/logs/clover.xml
229+
else
230+
phpBB/vendor/bin/phpunit --configuration phpBB/ext/$EXTNAME/.github/phpunit-$DB-github.xml --bootstrap ./tests/bootstrap.php
231+
fi
205232
working-directory: ./phpBB3
233+
234+
- name: Send code coverage
235+
if: ${{ matrix.COVERAGE == 1 }}
236+
uses: codecov/codecov-action@v3
237+
with:
238+
files: ./phpBB3/build/logs/clover.xml
206239
# END MySQL and MariaDB Job
207240

208241
# START PostgreSQL Job

0 commit comments

Comments
 (0)