Skip to content

Commit fd9b2fe

Browse files
authored
Render PHPUnit Coverage badge for Readme (#35)
This is just a local placeholder branch of forked pull request #34 - Have refactored badge creation as continuous deployment on push to master rather than being part of continuous integration tests and pull request flows.
2 parents 7860d05 + 676fe58 commit fd9b2fe

File tree

5 files changed

+75
-4
lines changed

5 files changed

+75
-4
lines changed

.github/workflows/cd.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Continuous Deployment
2+
3+
on:
4+
push:
5+
branches:
6+
- "master"
7+
8+
concurrency:
9+
group: ${{ github.head_ref || github.run_id }}
10+
cancel-in-progress: true
11+
12+
jobs:
13+
phpunit-render-badge:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: "Checkout"
18+
uses: actions/checkout@v3
19+
with:
20+
fetch-depth: 0
21+
22+
- name: "Setup PHP"
23+
uses: shivammathur/setup-php@v2
24+
with:
25+
php-version: "8.2"
26+
extensions: mbstring, intl
27+
ini-values: post_max_size=256M, max_execution_time=180
28+
coverage: xdebug
29+
30+
- name: "Composer State"
31+
run: composer update --no-install --with-all-dependencies
32+
33+
- name: "Composer Name Hash"
34+
id: composer-hash
35+
uses: KEINOS/gh-action-hash-for-cache@main
36+
with:
37+
path: ./composer.lock
38+
39+
- name: "Caching"
40+
id: cache-composer
41+
uses: actions/cache@v3
42+
with:
43+
path: vendor
44+
key: composer-default-${{ steps.composer-hash.outputs.hash }}
45+
restore-keys: composer-default-${{ steps.composer-hash.outputs.hash }}
46+
47+
- name: "Install Dependencies"
48+
if: ${{ steps.cache-composer.outputs.cache-hit != 'true' }}
49+
run: composer install
50+
51+
- name: "Linux: Restore Vendor Executable"
52+
run: chmod -R 0755 vendor
53+
54+
- name: "PHPUnit"
55+
run: ./vendor/bin/phpunit
56+
57+
- name: "Make code coverage badge"
58+
uses: timkrase/[email protected]
59+
with:
60+
coverage_badge_path: .github/coverage.svg
61+
# push badge later on
62+
push_badge: false
63+
64+
- name: "Git push badges to origin/image-data"
65+
uses: peaceiris/actions-gh-pages@v3
66+
with:
67+
publish_dir: .github
68+
publish_branch: image-data
69+
github_token: ${{ secrets.GITHUB_TOKEN }}
70+
user_name: "github-actions[bot]"
71+
user_email: "github-actions[bot]@users.noreply.github.com"

.github/workflows/ci.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: PHP CI
1+
name: Continuous Integration
22

33
on:
44
pull_request:
@@ -68,7 +68,6 @@ jobs:
6868
run: composer install
6969

7070
- name: "Linux: Restore Vendor Executable"
71-
if: matrix.operating-system == 'ubuntu-latest'
7271
run: chmod -R 0755 vendor
7372

7473
- name: "PHPUnit"

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ _Package_
44
[![License](https://img.shields.io/packagist/l/alexwestergaard/php-ga4?color=blue)](https://github.com/aawnu/php-ga4/blob/master/LICENSE)
55
[![PHPVersion](https://img.shields.io/packagist/php-v/alexwestergaard/php-ga4?color=blue)](https://www.php.net/releases)
66
[![Size](https://img.shields.io/github/languages/code-size/aawnu/php-ga4?color=blue)](https://github.com/aawnu/php-ga4/releases/latest)
7+
![Code Coverage Badge](https://raw.githubusercontent.com/AlexWestergaard/php-ga4/image-data/coverage.svg)
78

89
_Development_
910

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,4 @@
5050
},
5151
"minimum-stability": "stable",
5252
"prefer-stable": true
53-
}
53+
}

phpunit.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<file>./src/GA4Exception.php</file>
2121
</exclude>
2222
<report>
23-
<text outputFile="./.phpunit/coverage.txt" showUncoveredFiles="true" showOnlySummary="false" />
23+
<clover outputFile="clover.xml"/>
2424
</report>
2525
</coverage>
2626
<php>

0 commit comments

Comments
 (0)