Skip to content

Commit 6dfaaa6

Browse files
committed
Setup mutation testing
1 parent 38a7dfd commit 6dfaaa6

File tree

3 files changed

+85
-0
lines changed

3 files changed

+85
-0
lines changed

.github/workflows/static-analysis.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,11 @@ jobs:
8585
- name: "PHPStan"
8686
run: "make phpstan"
8787

88+
- uses: "actions/upload-artifact@v4"
89+
with:
90+
name: "result-cache-${{ matrix.php-version }}${{ matrix.operating-system-packages}}"
91+
path: "tmp/resultCache.php"
92+
8893
static-analysis-with-result-cache:
8994
name: "PHPStan with result cache"
9095

.github/workflows/tests.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,3 +222,65 @@ jobs:
222222

223223
- name: "Tests"
224224
run: "make tests"
225+
226+
mutation-testing:
227+
name: "Mutation Testing"
228+
runs-on: "ubuntu-latest"
229+
needs: ["tests", "tests-levels"]
230+
231+
strategy:
232+
fail-fast: false
233+
matrix:
234+
php-version:
235+
- "8.2"
236+
- "8.3"
237+
- "8.4"
238+
operating-system: [ubuntu-latest]
239+
240+
steps:
241+
- name: "Checkout"
242+
uses: actions/checkout@v5
243+
244+
- name: "Install PHP"
245+
uses: "shivammathur/setup-php@v2"
246+
with:
247+
coverage: "pcov"
248+
php-version: "${{ matrix.php-version }}"
249+
tools: pecl, infection:0.31.7
250+
extensions: ds,mbstring
251+
ini-file: development
252+
ini-values: memory_limit=-1
253+
254+
- uses: "ramsey/composer-install@v3"
255+
256+
- name: "Check PHP configuration"
257+
run: "vendor/bin/phpunit --check-php-configuration"
258+
259+
- name: "Checkout build-infection"
260+
uses: actions/checkout@v5
261+
with:
262+
repository: "phpstan/build-infection"
263+
path: "build-infection"
264+
ref: "1.x"
265+
266+
- name: "Install build-infection dependencies"
267+
working-directory: "build-infection"
268+
run: "composer install --no-interaction --no-progress"
269+
270+
- uses: "actions/download-artifact@v4"
271+
with:
272+
name: "result-cache-${{ matrix.php-version }}${{ matrix.operating-system-packages}}"
273+
path: "tmp/"
274+
275+
- name: "Run infection"
276+
run: |
277+
git fetch --depth=1 origin $GITHUB_BASE_REF
278+
infection \
279+
--git-diff-base=origin/$GITHUB_BASE_REF \
280+
--git-diff-lines \
281+
--ignore-msi-with-no-mutations \
282+
--min-msi=100 \
283+
--min-covered-msi=100 \
284+
--log-verbosity=all \
285+
--debug \
286+
--logger-text=php://stdout

infection.json5

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"$schema": "vendor/infection/infection/resources/schema.json",
3+
"timeout": 30,
4+
"source": {
5+
"directories": [
6+
"src"
7+
]
8+
},
9+
"staticAnalysisTool": "phpstan",
10+
"logs": {
11+
"text": "tmp/infection.log"
12+
},
13+
"bootstrap": "build-infection/vendor/autoload.php",
14+
"mutators": {
15+
"@default": false,
16+
"PHPStan\\Infection\\TrinaryLogicMutator": true
17+
}
18+
}

0 commit comments

Comments
 (0)