Skip to content

Commit 68e0865

Browse files
authored
Setup mutation testing
1 parent 0b87f52 commit 68e0865

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"
@@ -159,3 +163,67 @@ 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: "Checkout build-infection"
186+
uses: actions/checkout@v5
187+
with:
188+
repository: "phpstan/build-infection"
189+
path: "build-infection"
190+
ref: "1.x"
191+
192+
- uses: ./build-infection/.github/actions/setup-php
193+
with:
194+
php-version: "${{ matrix.php-version }}"
195+
extensions: mbstring
196+
197+
- name: "Install dependencies"
198+
run: "composer install --no-interaction --no-progress"
199+
200+
- name: "Install build-infection dependencies"
201+
working-directory: "build-infection"
202+
run: "composer install --no-interaction --no-progress"
203+
204+
- name: "Configure infection"
205+
run: |
206+
php build-infection/bin/infection-config.php \
207+
> infection.json5
208+
cat infection.json5 | jq
209+
210+
- name: "Cache Result cache"
211+
uses: actions/cache@v4
212+
with:
213+
path: ./tmp
214+
key: "result-cache-v1-${{ matrix.php-version }}-${{ github.run_id }}"
215+
restore-keys: |
216+
result-cache-v1-${{ matrix.php-version }}-
217+
218+
- name: "Run infection"
219+
run: |
220+
git fetch --depth=1 origin $GITHUB_BASE_REF
221+
infection \
222+
--git-diff-base=origin/$GITHUB_BASE_REF \
223+
--git-diff-lines \
224+
--ignore-msi-with-no-mutations \
225+
--min-msi=100 \
226+
--min-covered-msi=100 \
227+
--log-verbosity=all \
228+
--debug \
229+
--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)