Skip to content

Commit 5b0ae8e

Browse files
authored
ci: run mutation testing with Infection (#141)
build: install Infection with the Testo adapter ci: run mutation testing through the shared cycle/gh-actions workflow docs: add the mutation testing badge Assisted-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 2efb3cd commit 5b0ae8e

6 files changed

Lines changed: 71 additions & 13 deletions

File tree

‎.github/workflows/infection.yml‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
3+
on: # yamllint disable-line rule:truthy
4+
pull_request:
5+
push:
6+
branches:
7+
- 4.x
8+
9+
name: 🧬 Mutation Tests
10+
11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
13+
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
14+
15+
permissions:
16+
contents: read
17+
18+
jobs:
19+
infection:
20+
name: Infection
21+
uses: cycle/gh-actions/.github/workflows/infection.yml@master
22+
secrets: inherit
23+
24+
...

‎README.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
[![Psalm Level](https://shepherd.dev/github/cycle/annotated/level.svg)](https://shepherd.dev/github/cycle/annotated)
1919
[![Type Coverage](https://shepherd.dev/github/cycle/annotated/coverage.svg)](https://shepherd.dev/github/cycle/annotated)
2020
[![Codecov](https://codecov.io/gh/cycle/annotated/branch/4.x/graph/badge.svg)](https://codecov.io/gh/cycle/annotated)
21+
[![Mutation testing badge](https://img.shields.io/endpoint?style=flat-square&url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2Fcycle%2Fannotated%2F4.x)](https://dashboard.stryker-mutator.io/reports/github.com/cycle/annotated/4.x)
2122

2223
</div>
2324

‎composer.json‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,18 @@
7070
"scripts": {
7171
"cs:diff": "php-cs-fixer fix --dry-run -v --diff --config=vendor-bin/code-style/.php-cs-fixer.dist.php",
7272
"cs:fix": "php-cs-fixer fix -v --config=vendor-bin/code-style/.php-cs-fixer.dist.php",
73+
"infect": [
74+
"Composer\\Config::disableProcessTimeout",
75+
"@putenv XDEBUG_MODE=coverage",
76+
"@putenv DB_DRIVERS=sqlite",
77+
"infection --configuration=infection.json --threads=max"
78+
],
79+
"infect:ci": [
80+
"Composer\\Config::disableProcessTimeout",
81+
"@putenv XDEBUG_MODE=coverage",
82+
"@putenv DB_DRIVERS=sqlite",
83+
"infection --ansi --configuration=infection.json --logger-github --threads=max --show-mutations=0"
84+
],
7385
"psalm": "psalm -c vendor-bin/psalm/psalm.xml",
7486
"psalm:baseline": "psalm -c vendor-bin/psalm/psalm.xml --set-baseline=vendor-bin/psalm/psalm-baseline.xml",
7587
"psalm:ci": "psalm -c vendor-bin/psalm/psalm.xml --output-format=github --shepherd --show-info=false --stats --threads=4",
@@ -84,6 +96,8 @@
8496
"test:unit": "testo --suite=Unit"
8597
},
8698
"scripts-descriptions": {
99+
"infect": "Run mutation testing with Infection on the Unit and SQLite suites",
100+
"infect:ci": "Run mutation testing in CI, failing below the minimum MSI",
87101
"test:new-case": "Create a regression case for an issue: composer test:new-case -- <issue>"
88102
},
89103
"extra": {

‎infection.json‎

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
{
2-
"timeout": 10,
3-
"source": {
4-
"directories": [
5-
"src"
6-
]
7-
},
8-
"logs": {
9-
"text": "infection.log"
10-
},
11-
"mutators": {
12-
"@default": true
13-
}
14-
}
2+
"$schema": "vendor-bin/infection/vendor/infection/infection/resources/schema.json",
3+
"source": {
4+
"directories": [
5+
"src"
6+
]
7+
},
8+
"timeout": 10,
9+
"minMsi": 80,
10+
"minCoveredMsi": 80,
11+
"testFramework": "testo",
12+
"tmpDir": "runtime",
13+
"logs": {
14+
"stryker": {
15+
"report": "4.x"
16+
}
17+
}
18+
}

‎vendor-bin/infection/.gitignore‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/vendor/
2+
/composer.lock
3+
/.*/
4+
/skills.json

‎vendor-bin/infection/composer.json‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"require": {
3+
"infection/infection": "^0.35.12",
4+
"testo/bridge-infection": "^0.1.9"
5+
},
6+
"config": {
7+
"allow-plugins": {
8+
"infection/extension-installer": true
9+
}
10+
}
11+
}

0 commit comments

Comments
 (0)