Skip to content

Commit d6faca7

Browse files
committed
Add code coverage using gist
Resolve #5
1 parent 4c44a6b commit d6faca7

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

.github/workflows/check.yml

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ jobs:
6161
- name: "Install PHP"
6262
uses: "shivammathur/setup-php@v2"
6363
with:
64-
coverage: "none"
64+
coverage: "xdebug"
6565
php-version: "${{ matrix.php-version }}"
6666

6767
- name: "Install lowest dependencies"
@@ -73,7 +73,25 @@ jobs:
7373
run: "composer update --no-interaction --no-progress"
7474

7575
- name: "Tests"
76-
run: "composer test"
76+
id: tests
77+
continue-on-error: false
78+
run: |
79+
vendor/bin/phpunit --coverage-text --coverage-text=coverage.txt
80+
echo "::set-output name=coverage::$(cat coverage.txt | grep -Po '^\s*Lines:\s*\d+.\d+\%' | grep -Po '\d+.\d+')"
81+
82+
# TODO on pull request add comment?
83+
84+
- name: "Create badge"
85+
if: ${{ github.ref == 'refs/heads/main' && matrix.dependencies == 'highest' && steps.tests.outputs.coverage != '' }}
86+
uses: schneegans/dynamic-badges-action@v1.4.0
87+
with:
88+
auth: ${{ secrets.GIST_SECRET }}
89+
gistID: 11b884c06da0bf9116ae763d23438ecb
90+
filename: coverage.json
91+
label: Coverage
92+
# TODO colors?
93+
message: ${{ steps.tests.outputs.coverage }}
94+
color: success
7795

7896
static-analysis:
7997
name: "PHPStan"

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
![img](https://img.shields.io/badge/PHPStan-8-blue)
44
![php](https://img.shields.io/badge/PHP-8.1-B0B3D6)
5+
![coverage](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/pionl/11b884c06da0bf9116ae763d23438ecb/raw/coverage.json)
56

67
Get typed (strict mode) values from an Array / XML with basic validation.
78

docs/content/en/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ position: 1
66

77
<img src="https://img.shields.io/badge/PHPStan-8-blue" class="inline-flex" style="margin: 0;" />
88
<img src="https://img.shields.io/badge/PHP-8.1-B0B3D6" class="inline-flex" style="margin: 0;" />
9+
<img src="https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/pionl/11b884c06da0bf9116ae763d23438ecb/raw/coverage.json" class="inline-flex" style="margin: 0;" />
910

1011
## Main features
1112

0 commit comments

Comments
 (0)