Skip to content

Commit be154b8

Browse files
committed
ci: add code coverage workflow and switch release-please to GITHUB_TOKEN
1 parent 9b0813e commit be154b8

5 files changed

Lines changed: 63 additions & 3 deletions

File tree

.github/workflows/create-release.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,19 @@ on: # yamllint disable-line rule:truthy
1111

1212
name: 📦 Create release
1313

14+
permissions:
15+
contents: write
16+
pull-requests: write
17+
1418
jobs:
1519
release:
1620
runs-on: ubuntu-latest
1721
steps:
1822
- name: 🎉 Create release
19-
uses: googleapis/release-please-action@v4
23+
uses: googleapis/release-please-action@v4.1.1
2024
id: release
2125
with:
22-
token: ${{ secrets.RELEASE_TOKEN }}
26+
token: ${{ secrets.GITHUB_TOKEN }}
2327
config-file: .github/.release-please-config.json
2428
manifest-file: resources/version.json
2529
target-branch: 1.x

.github/workflows/testing.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,39 @@ jobs:
5555

5656
- name: 🧪 Run tests (excluding driver-bound groups)
5757
run: composer test:no-driver
58+
59+
code-coverage:
60+
name: Code coverage
61+
timeout-minutes: 4
62+
runs-on: ubuntu-latest
63+
concurrency:
64+
cancel-in-progress: true
65+
group: code-coverage-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
66+
steps:
67+
- name: 📦 Check out the codebase
68+
uses: actions/checkout@v6
69+
70+
- name: 🛠️ Setup PHP
71+
uses: shivammathur/setup-php@v2
72+
with:
73+
php-version: '8.4'
74+
extensions: pdo, pdo_sqlite
75+
ini-values: error_reporting=E_ALL
76+
coverage: xdebug
77+
78+
- name: 📥 Install dependencies with composer
79+
uses: ramsey/composer-install@v3
80+
env:
81+
COMPOSER_ROOT_VERSION: '1.x-dev'
82+
with:
83+
dependency-versions: highest
84+
85+
- name: 🧪 Collect code coverage with Testo
86+
run: composer test:cc
87+
88+
- name: 📤 Upload code coverage report to Codecov
89+
uses: codecov/codecov-action@v5
90+
with:
91+
files: runtime/clover.xml
92+
token: ${{ secrets.CODECOV_TOKEN }}
93+
verbose: true

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<div align="center">
1414

1515
[![Build Status](https://img.shields.io/github/actions/workflow/status/cycle/transaction/testing.yml?branch=1.x&style=flat-square&label=tests)](https://github.com/cycle/transaction/actions)
16-
[![Codecov Coverage](https://img.shields.io/codecov/c/github/cycle/transaction?style=flat-square&logo=codecov)](https://app.codecov.io/gh/cycle/transaction)
16+
[![Codecov Coverage](https://img.shields.io/codecov/c/github/cycle/transaction/1.x?style=flat-square&logo=codecov)](https://app.codecov.io/gh/cycle/transaction/tree/1.x)
1717
[![Mutation testing badge](https://img.shields.io/endpoint?style=flat-square&label=mutation%20score&url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2Fcycle%2Ftransaction%2F1.x)](https://dashboard.stryker-mutator.io/reports/github.com/cycle/transaction/1.x)
1818

1919
[![Discord](https://img.shields.io/discord/538114875570913290?style=flat-square&logo=discord&labelColor=7289d9&logoColor=white&color=39456d)](https://discord.gg/spiralphp)

composer.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@
4242
"test:mysql": "testo --suite=Acceptance --group=driver-mysql",
4343
"test:postgres": "testo --suite=Acceptance --group=driver-postgres",
4444
"test:sqlserver": "testo --suite=Acceptance --group=driver-sqlserver",
45+
"test:cc": [
46+
"@putenv XDEBUG_MODE=coverage",
47+
"testo --group=!driver-mysql --group=!driver-postgres --group=!driver-sqlserver --coverage"
48+
],
4549
"psalm": "psalm",
4650
"infection": "infection",
4751
"infect:ci": [

testo.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
use Testo\Application\Config\ApplicationConfig;
66
use Testo\Application\Config\FinderConfig;
77
use Testo\Application\Config\SuiteConfig;
8+
use Testo\Codecov\CodecovPlugin;
9+
use Testo\Codecov\Config\CoverageLevel;
10+
use Testo\Codecov\Config\CoverageMode;
11+
use Testo\Codecov\Report\CloverReport;
812

913
return new ApplicationConfig(
1014
src: ['src'],
@@ -18,4 +22,16 @@
1822
location: new FinderConfig(include: ['tests/Acceptance/Driver']),
1923
),
2024
],
25+
plugins: [
26+
// Coverage is collected only when `--coverage` (or a report flag) is passed and an
27+
// Xdebug/PCOV driver is available; the Clover report is uploaded to Codecov by CI
28+
// (see `composer test:cc`).
29+
new CodecovPlugin(
30+
level: CoverageLevel::Line,
31+
collect: CoverageMode::Never,
32+
reports: [
33+
new CloverReport(__DIR__ . '/runtime/clover.xml', 'cycle/transaction'),
34+
],
35+
),
36+
],
2137
);

0 commit comments

Comments
 (0)