Skip to content

Commit 53e33fc

Browse files
authored
Setup mutation testing
1 parent 12676a7 commit 53e33fc

File tree

3 files changed

+72
-1
lines changed

3 files changed

+72
-1
lines changed

.github/workflows/build.yml

Lines changed: 68 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"
@@ -213,3 +217,67 @@ jobs:
213217

214218
- name: "PHPStan"
215219
run: "make phpstan"
220+
221+
mutation-testing:
222+
name: "Mutation Testing"
223+
runs-on: "ubuntu-latest"
224+
needs: ["tests", "static-analysis"]
225+
226+
strategy:
227+
fail-fast: false
228+
matrix:
229+
php-version:
230+
- "8.2"
231+
- "8.3"
232+
- "8.4"
233+
operating-system: [ubuntu-latest]
234+
235+
steps:
236+
- name: "Checkout"
237+
uses: actions/checkout@v5
238+
239+
- name: "Checkout build-infection"
240+
uses: actions/checkout@v5
241+
with:
242+
repository: "phpstan/build-infection"
243+
path: "build-infection"
244+
ref: "1.x"
245+
246+
- uses: ./build-infection/.github/actions/setup-php
247+
with:
248+
php-version: "${{ matrix.php-version }}"
249+
extensions: mbstring
250+
251+
- name: "Install dependencies"
252+
run: "composer install --no-interaction --no-progress"
253+
254+
- name: "Install build-infection dependencies"
255+
working-directory: "build-infection"
256+
run: "composer install --no-interaction --no-progress"
257+
258+
- name: "Configure infection"
259+
run: |
260+
php build-infection/bin/infection-config.php \
261+
> infection.json5
262+
cat infection.json5 | jq
263+
264+
- name: "Cache Result cache"
265+
uses: actions/cache@v4
266+
with:
267+
path: ./tmp
268+
key: "result-cache-v1-${{ matrix.php-version }}-${{ github.run_id }}"
269+
restore-keys: |
270+
result-cache-v1-${{ matrix.php-version }}-
271+
272+
- name: "Run infection"
273+
run: |
274+
git fetch --depth=1 origin $GITHUB_BASE_REF
275+
infection \
276+
--git-diff-base=origin/$GITHUB_BASE_REF \
277+
--git-diff-lines \
278+
--ignore-msi-with-no-mutations \
279+
--min-msi=100 \
280+
--min-covered-msi=100 \
281+
--log-verbosity=all \
282+
--debug \
283+
--logger-text=php://stdout

phpstan.neon

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ includes:
99
parameters:
1010
reportUnmatchedIgnoredErrors: false
1111

12+
resultCachePath: tmp/resultCache.php
13+
1214
excludePaths:
1315
- tests/*/data/*
1416
ignoreErrors:

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
<testsuites>
1617
<testsuite name="PHPStan for PHPUnit">

0 commit comments

Comments
 (0)