Skip to content

Commit 74e5a7d

Browse files
committed
ci: add mutation testing workflow with Infection
- Add Infection to composer.json require-dev dependencies - Create GitHub workflow for mutation testing - Configure workflow to fail if MSI is below 87% - Set threads to max for optimal performance - Run on push to main and pull requests
1 parent afa5bf5 commit 74e5a7d

File tree

2 files changed

+46
-1
lines changed

2 files changed

+46
-1
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Mutation Testing
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
mutation-testing:
14+
name: Mutation Testing
15+
runs-on: ubuntu-24.04
16+
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6
20+
21+
- name: Setup PHP
22+
uses: shivammathur/setup-php@44454db4f0199b8b9685a5d763dc37cbf79108e1 # v2
23+
with:
24+
php-version: '8.2'
25+
extensions: json
26+
coverage: xdebug
27+
tools: composer:v2
28+
29+
- name: Get composer cache directory
30+
id: composer-cache
31+
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
32+
33+
- name: Cache dependencies
34+
uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # v5
35+
with:
36+
path: ${{ steps.composer-cache.outputs.dir }}
37+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
38+
restore-keys: ${{ runner.os }}-composer-
39+
40+
- name: Install dependencies
41+
run: composer update -n --prefer-dist
42+
43+
- name: Run mutation testing
44+
run: vendor/bin/infection --threads=max --min-msi=87 --min-covered-msi=87

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
"phpunit/phpunit": "^11||^12",
2727
"guzzlehttp/guzzle": "^7.0",
2828
"humbug/box": "^4.6",
29-
"phpstan/phpstan": "^2.0"
29+
"phpstan/phpstan": "^2.0",
30+
"infection/infection": "^0.30"
3031
},
3132
"autoload": {
3233
"psr-4": {

0 commit comments

Comments
 (0)