-
Notifications
You must be signed in to change notification settings - Fork 0
32 lines (26 loc) · 1021 Bytes
/
coverage.yaml
File metadata and controls
32 lines (26 loc) · 1021 Bytes
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
name: coverage
on: [push, pull_request]
permissions: {}
jobs:
coverage:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
with:
persist-credentials: false
- name: Setup PHP
uses: shivammathur/setup-php@9e72090525849c5e82e596468b86eb55e9cc5401 # v2.32.0
with:
php-version: '8.4'
coverage: pcov
- name: Install dependencies
run: composer install --no-interaction --prefer-dist
- name: Run tests with coverage
run: |
vendor/bin/phpunit --coverage-clover coverage.xml
LINE_RATE=$(php -r '$x = simplexml_load_file("coverage.xml"); $m = $x->project->metrics; $pct = round((int)$m["coveredstatements"] / (int)$m["statements"] * 100, 2); echo $pct;')
echo "Line coverage: ${LINE_RATE}%"
if [ "$LINE_RATE" != "100" ]; then
echo "::error::Line coverage is ${LINE_RATE}%, required 100%"
exit 1
fi