Skip to content

Commit ab70959

Browse files
committed
Setup mutation testing
1 parent 0b87f52 commit ab70959

File tree

3 files changed

+77
-1
lines changed

3 files changed

+77
-1
lines changed

.github/workflows/build.yml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ on:
88
branches:
99
- "2.0.x"
1010

11+
concurrency:
12+
group: build-${{ github.head_ref || github.run_id }} # will be canceled on subsequent pushes in pull requests but not branches
13+
cancel-in-progress: true
14+
1115
jobs:
1216
lint:
1317
name: "Lint"
@@ -159,3 +163,72 @@ jobs:
159163

160164
- name: "PHPStan"
161165
run: "make phpstan"
166+
167+
mutation-testing:
168+
name: "Mutation Testing"
169+
runs-on: "ubuntu-latest"
170+
needs: ["tests", "static-analysis"]
171+
172+
strategy:
173+
fail-fast: false
174+
matrix:
175+
php-version:
176+
- "8.2"
177+
- "8.3"
178+
- "8.4"
179+
operating-system: [ubuntu-latest]
180+
181+
steps:
182+
- name: "Checkout"
183+
uses: actions/checkout@v5
184+
185+
- name: "Install PHP"
186+
uses: "shivammathur/setup-php@v2"
187+
with:
188+
coverage: "pcov"
189+
php-version: "${{ matrix.php-version }}"
190+
tools: pecl, infection:0.31.7
191+
extensions: mbstring
192+
ini-file: development
193+
ini-values: memory_limit=-1
194+
195+
- name: "Install dependencies"
196+
run: "composer install --no-interaction --no-progress"
197+
198+
- name: "Checkout build-infection"
199+
uses: actions/checkout@v5
200+
with:
201+
repository: "phpstan/build-infection"
202+
path: "build-infection"
203+
ref: "1.x"
204+
205+
- name: "Install build-infection dependencies"
206+
working-directory: "build-infection"
207+
run: "composer install --no-interaction --no-progress"
208+
209+
- name: "Configure infection"
210+
run: |
211+
php build-infection/bin/infection-config.php \
212+
> infection.json5
213+
cat infection.json5 | jq
214+
215+
- name: "Cache Result cache"
216+
uses: actions/cache@v4
217+
with:
218+
path: ./tmp
219+
key: "result-cache-v1-${{ matrix.php-version }}-${{ github.run_id }}"
220+
restore-keys: |
221+
result-cache-v1-${{ matrix.php-version }}-
222+
223+
- name: "Run infection"
224+
run: |
225+
git fetch --depth=1 origin $GITHUB_BASE_REF
226+
infection \
227+
--git-diff-base=origin/$GITHUB_BASE_REF \
228+
--git-diff-lines \
229+
--ignore-msi-with-no-mutations \
230+
--min-msi=100 \
231+
--min-covered-msi=100 \
232+
--log-verbosity=all \
233+
--debug \
234+
--logger-text=php://stdout

phpstan.neon

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,7 @@ includes:
55
- vendor/phpstan/phpstan-phpunit/extension.neon
66

77
parameters:
8+
resultCachePath: tmp/resultCache.php
9+
810
excludePaths:
911
- tests/*/data/*

phpunit.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
beStrictAboutTodoAnnotatedTests="true"
1111
failOnRisky="true"
1212
failOnWarning="true"
13-
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xml"
13+
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
14+
executionOrder="random"
1415
>
1516
<coverage>
1617
<include>

0 commit comments

Comments
 (0)