Skip to content

Commit 41e79be

Browse files
Merge pull request #358 from mauriciofauth/infection-php
Add mutation tests with Infection
2 parents bcbdb7e + f5e422c commit 41e79be

6 files changed

Lines changed: 103 additions & 1 deletion

File tree

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
.github export-ignore
66
.weblate export-ignore
77
.scrutinizer.yml export-ignore
8+
infection.json.dist export-ignore
89
phpcs.xml.dist export-ignore
910
phpstan.neon.dist export-ignore
1011
phpstan-baseline.neon export-ignore
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: Mutation tests
2+
3+
on:
4+
push:
5+
branches: [master]
6+
pull_request:
7+
branches: [master]
8+
9+
jobs:
10+
tests:
11+
name: Mutation tests with PHP ${{ matrix.php-version }}
12+
13+
runs-on: ${{ matrix.operating-system }}
14+
15+
strategy:
16+
matrix:
17+
php-version: ["8.0"]
18+
operating-system: [ubuntu-latest]
19+
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v2
23+
24+
- name: Fetch github.base_ref (for diffing)
25+
if: ${{ github.base_ref != '' }}
26+
run: |
27+
git fetch --depth=1 origin +refs/heads/${{ github.base_ref }}:refs/remotes/origin/${{ github.base_ref }}
28+
29+
- name: Install PHP ${{ matrix.php-version }}
30+
uses: shivammathur/setup-php@v2
31+
with:
32+
php-version: ${{ matrix.php-version }}
33+
coverage: pcov
34+
ini-values: memory_limit=-1
35+
tools: composer:v2, phive
36+
37+
- name: Install Infection
38+
# The GPG key can be found at https://infection.github.io/guide/installation.html
39+
run: |
40+
phive --no-progress install --target ./build/tools --trust-gpg-keys C5095986493B4AA0 infection
41+
42+
- name: Get Composer cache directory
43+
id: composer-cache
44+
run: |
45+
echo "::set-output name=dir::$(composer config cache-files-dir)"
46+
47+
- name: Cache dependencies
48+
uses: actions/cache@v2
49+
with:
50+
path: ${{ steps.composer-cache.outputs.dir }}
51+
key: composer-${{ runner.os }}-${{ matrix.php-version }}-${{ hashFiles('**/composer.*') }}
52+
restore-keys: |
53+
composer-${{ runner.os }}-${{ matrix.php-version }}-
54+
55+
- name: Install dependencies
56+
run: |
57+
composer update --no-interaction --no-progress
58+
59+
- name: Collect coverage report
60+
run: |
61+
./vendor/bin/phpunit --stop-on-failure
62+
63+
- name: Infection
64+
if: ${{ github.base_ref != '' }}
65+
run: |
66+
CHANGED_FILES=$(git diff origin/$GITHUB_BASE_REF --diff-filter=AM --name-only | grep src/ | paste -sd "," -);
67+
./build/tools/infection -j$(nproc) --skip-initial-tests --no-interaction --no-progress --coverage=build/logs \
68+
--ignore-msi-with-no-mutations \
69+
--filter=$CHANGED_FILES
70+
env:
71+
INFECTION_BADGE_API_KEY: ${{ secrets.INFECTION_BADGE_API_KEY }}
72+
73+
- name: Infection
74+
if: ${{ github.base_ref == '' }}
75+
run: |
76+
./build/tools/infection -j$(nproc) --skip-initial-tests --no-interaction --no-progress --coverage=build/logs
77+
env:
78+
INFECTION_BADGE_API_KEY: ${{ secrets.INFECTION_BADGE_API_KEY }}

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,6 @@ phpunit.xml
1212
phpcs.xml
1313
.phpunit.result.cache
1414
phpstan.neon
15+
# Infection
16+
infection.json
17+
infection.log

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ A validating SQL lexer and parser with a focus on MySQL dialect.
1212
[![Packagist](https://img.shields.io/packagist/dt/phpmyadmin/sql-parser.svg)](https://packagist.org/packages/phpmyadmin/sql-parser)
1313
[![Open Source Helpers](https://www.codetriage.com/phpmyadmin/sql-parser/badges/users.svg)](https://www.codetriage.com/phpmyadmin/sql-parser)
1414
[![Type coverage](https://shepherd.dev/github/phpmyadmin/sql-parser/coverage.svg)](https://shepherd.dev/github/phpmyadmin/sql-parser)
15+
[![Infection MSI](https://badge.stryker-mutator.io/github.com/phpmyadmin/sql-parser/master)](https://infection.github.io)
1516

1617
## Installation
1718

infection.json.dist

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"source": {
3+
"directories": [
4+
"src"
5+
]
6+
},
7+
"logs": {
8+
"badge": {
9+
"branch": "master"
10+
}
11+
},
12+
"mutators": {
13+
"@default": true
14+
},
15+
"minMsi": 84,
16+
"minCoveredMsi": 88
17+
}

phpunit.xml.dist

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
processIsolation="false"
1212
stopOnFailure="false">
1313
<logging>
14-
<log type="coverage-clover" target="build/logs/clover.xml" />
14+
<log type="coverage-clover" target="build/logs/clover.xml"/>
15+
<log type="coverage-xml" target="build/logs/coverage-xml"/>
16+
<log type="junit" target="build/logs/junit.xml"/>
1517
</logging>
1618
<testsuites>
1719
<testsuite name="Builder">

0 commit comments

Comments
 (0)