Skip to content

Commit 3cfb7cb

Browse files
committed
feat: add Codecov integration and update badges
- Update GitHub Actions workflow to generate coverage reports - Add Xdebug coverage for all three database jobs (MySQL, PostgreSQL, SQLite) - Add Codecov upload steps for each job - Create .codecov.yml configuration with 75% coverage target - Update README badges: rename CI to Tests, add Coverage badge - Add coverage files to .gitignore
1 parent 63c4579 commit 3cfb7cb

4 files changed

Lines changed: 78 additions & 5 deletions

File tree

.codecov.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
codecov:
2+
require_ci_to_pass: yes
3+
4+
coverage:
5+
precision: 2
6+
round: down
7+
range: "70...100"
8+
9+
status:
10+
project:
11+
default:
12+
target: 75%
13+
threshold: 2%
14+
if_ci_failed: error
15+
patch:
16+
default:
17+
target: 75%
18+
threshold: 2%
19+
20+
comment:
21+
layout: "reach,diff,flags,files,footer"
22+
behavior: default
23+
require_changes: false
24+
25+
flags:
26+
mysql:
27+
paths:
28+
- src/
29+
carryforward: true
30+
postgres:
31+
paths:
32+
- src/
33+
carryforward: true
34+
sqlite:
35+
paths:
36+
- src/
37+
carryforward: true
38+
39+
ignore:
40+
- "tests/"
41+
- "examples/"
42+
- "vendor/"
43+

.github/workflows/tests.yml

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: CI
1+
name: Tests
22

33
on:
44
push:
@@ -28,12 +28,20 @@ jobs:
2828
with:
2929
php-version: '8.4'
3030
extensions: pdo_mysql
31+
coverage: xdebug
3132
- run: composer install --no-interaction --prefer-dist
3233
- run: |
3334
DB_DSN="mysql:host=127.0.0.1;port=3306;dbname=testdb;charset=utf8mb4" \
3435
DB_USER="testuser" \
3536
DB_PASS="testpass" \
36-
vendor/bin/phpunit tests/PdoDbMySQLTest.php
37+
vendor/bin/phpunit tests/PdoDbMySQLTest.php --coverage-clover coverage-mysql.xml
38+
- name: Upload MySQL coverage to Codecov
39+
uses: codecov/codecov-action@v4
40+
with:
41+
token: ${{ secrets.CODECOV_TOKEN }}
42+
files: ./coverage-mysql.xml
43+
flags: mysql
44+
name: mysql-coverage
3745

3846
postgres:
3947
runs-on: ubuntu-latest
@@ -57,12 +65,20 @@ jobs:
5765
with:
5866
php-version: '8.4'
5967
extensions: pdo_pgsql
68+
coverage: xdebug
6069
- run: composer install --no-interaction --prefer-dist
6170
- run: |
6271
DB_DSN="pgsql:host=localhost;port=5433;dbname=testdb" \
6372
DB_USER="testuser" \
6473
DB_PASS="testpass" \
65-
vendor/bin/phpunit tests/PdoDbPostgreSQLTest.php
74+
vendor/bin/phpunit tests/PdoDbPostgreSQLTest.php --coverage-clover coverage-postgres.xml
75+
- name: Upload PostgreSQL coverage to Codecov
76+
uses: codecov/codecov-action@v4
77+
with:
78+
token: ${{ secrets.CODECOV_TOKEN }}
79+
files: ./coverage-postgres.xml
80+
flags: postgres
81+
name: postgres-coverage
6682

6783
sqlite:
6884
runs-on: ubuntu-latest
@@ -72,7 +88,15 @@ jobs:
7288
with:
7389
php-version: '8.4'
7490
extensions: pdo_sqlite
91+
coverage: xdebug
7592
- run: composer install --no-interaction --prefer-dist
7693
- run: |
7794
DB_DSN="sqlite::memory:" \
78-
vendor/bin/phpunit tests/PdoDbSqliteTest.php
95+
vendor/bin/phpunit tests/PdoDbSqliteTest.php --coverage-clover coverage-sqlite.xml
96+
- name: Upload SQLite coverage to Codecov
97+
uses: codecov/codecov-action@v4
98+
with:
99+
token: ${{ secrets.CODECOV_TOKEN }}
100+
files: ./coverage-sqlite.xml
101+
flags: sqlite
102+
name: sqlite-coverage

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ composer.lock
55
.phpunit.cache
66
.phpunit.result.cache
77

8+
# Coverage reports
9+
coverage-*.xml
10+
coverage/
11+
.coverage
12+
813
# Examples
914
examples/config.php
1015
examples/**/*.db

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
[![PHP Version](https://img.shields.io/badge/php-%3E%3D8.4-blue.svg)](https://php.net)
44
[![Latest Version](https://img.shields.io/packagist/v/tommyknocker/pdo-database-class.svg)](https://packagist.org/packages/tommyknocker/pdo-database-class)
5-
[![CI](https://github.com/tommyknocker/pdo-database-class/workflows/CI/badge.svg)](https://github.com/tommyknocker/pdo-database-class/actions)
5+
[![Tests](https://github.com/tommyknocker/pdo-database-class/workflows/Tests/badge.svg)](https://github.com/tommyknocker/pdo-database-class/actions)
6+
[![Coverage](https://codecov.io/gh/tommyknocker/pdo-database-class/branch/master/graph/badge.svg)](https://codecov.io/gh/tommyknocker/pdo-database-class)
67
[![License](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
78
[![Downloads](https://img.shields.io/packagist/dt/tommyknocker/pdo-database-class.svg)](https://packagist.org/packages/tommyknocker/pdo-database-class)
89
[![GitHub Stars](https://img.shields.io/github/stars/tommyknocker/pdo-database-class?style=social)](https://github.com/tommyknocker/pdo-database-class)

0 commit comments

Comments
 (0)