Skip to content

Commit 3cddd68

Browse files
committed
Install infection
1 parent b4e33b5 commit 3cddd68

File tree

8 files changed

+73
-1
lines changed

8 files changed

+73
-1
lines changed

.github/workflows/check.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,24 @@ jobs:
106106
env:
107107
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
108108

109+
infection:
110+
runs-on: ubuntu-latest
111+
steps:
112+
- uses: actions/checkout@v4
113+
- uses: arduino/setup-task@v2
114+
with:
115+
repo-token: ${{ secrets.GITHUB_TOKEN }}
116+
- uses: shivammathur/setup-php@v2
117+
with:
118+
php-version: 8.1
119+
tools: composer:v2
120+
- uses: ramsey/composer-install@v3
121+
with:
122+
composer-options: --optimize-autoloader
123+
- run: task infection
124+
env:
125+
STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }}
126+
109127
packages:
110128
runs-on: ubuntu-latest
111129
steps:

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,4 @@ Typhoon's mission is to give you everything you need to accomplish this:
2020
[![Psalm Level](https://shepherd.dev/github/typhoon-php/typhoon/level.svg)](https://shepherd.dev/github/typhoon-php/typhoon)
2121
[![Psalm Type Coverage](https://shepherd.dev/github/typhoon-php/typhoon/coverage.svg)](https://shepherd.dev/github/typhoon-php/typhoon)
2222
[![Code Coverage](https://codecov.io/gh/typhoon-php/typhoon/branch/0.4.x/graph/badge.svg)](https://codecov.io/gh/typhoon-php/typhoon/tree/0.4.x)
23+
[![Mutation testing badge](https://img.shields.io/endpoint?style=flat&url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2Ftyphoon-php%2Ftyphoon%2F0.4.x)](https://dashboard.stryker-mutator.io/reports/github.com/typhoon-php/typhoon/0.4.x)

Taskfile.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ vars:
66
REQUIRE_CHECKER: "{{.PHP}} tools/composer-require-checker/vendor/bin/composer-require-checker"
77
PSALM: "{{.PHP}} tools/psalm/vendor/bin/psalm --show-info --no-diff --no-cache"
88
PHPUNIT: "{{.PHP}} tools/phpunit/vendor/bin/phpunit"
9+
INFECTION: "{{.PHP}} vendor/bin/infection --threads=max --show-mutations"
910
PACKAGES:
1011
sh: find src -type d -maxdepth 1 -mindepth 1 -exec basename {} ';'
1112

@@ -49,6 +50,10 @@ tasks:
4950
deps: [var, install]
5051
cmd: "{{.PHPUNIT}} {{.CLI_ARGS}}"
5152

53+
infection:
54+
deps: [var, install]
55+
cmd: "{{.INFECTION}} {{.CLI_ARGS}}"
56+
5257
composer-normalize-fix:
5358
deps: [install]
5459
cmds:

composer.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"dragon-code/benchmark": "^2.6 || ^3",
2929
"ergebnis/composer-normalize": "^2.43.0",
3030
"friendsofphp/php-cs-fixer": "^3.62.0",
31+
"infection/infection": "^0.29.6",
3132
"mikey179/vfsstream": "^1.6.11",
3233
"phpstan/phpstan": "^1.11.9",
3334
"phpyh/coding-standard": "^2.6.1",
@@ -52,7 +53,8 @@
5253
"config": {
5354
"allow-plugins": {
5455
"bamarni/composer-bin-plugin": true,
55-
"ergebnis/composer-normalize": true
56+
"ergebnis/composer-normalize": true,
57+
"infection/extension-installer": true
5658
},
5759
"lock": false,
5860
"sort-packages": true

infection.json5.dist

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"$schema": "vendor/infection/infection/resources/schema.json",
3+
"phpUnit": {
4+
"customPath": "tools/phpunit/vendor/bin/phpunit"
5+
},
6+
"source": {
7+
"directories": [
8+
"src/ChangeDetector"
9+
]
10+
},
11+
"logs": {
12+
"html": "var/infection_report.html",
13+
"stryker": {
14+
"report": "/^\\d+\\.\\d+\\.x$/"
15+
}
16+
},
17+
"tmpDir": "var",
18+
"minCoveredMsi": 80,
19+
"mutators": {
20+
"@default": true
21+
},
22+
"testFrameworkOptions": "--testsuite=ChangeDetector"
23+
}

phpunit.xml.dist

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@
2323
<testsuite name="compatibility">
2424
<file>tests/Reflection/Internal/NativeAdapter/AdapterCompatibilityTest.php</file>
2525
</testsuite>
26+
27+
<testsuite name="ChangeDetector">
28+
<directory>tests/ChangeDetector</directory>
29+
</testsuite>
2630
</testsuites>
2731

2832
<source restrictDeprecations="true" restrictNotices="true" restrictWarnings="true">

tests/ChangeDetector/ComposerPackageChangeDetectorTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,13 @@ public function testFromNameThrowsOnNonInstalledPackage(): void
4646

4747
ComposerPackageChangeDetector::fromName('abc');
4848
}
49+
50+
public function testDeduplicateResult(): void
51+
{
52+
$changeDetector = new ComposerPackageChangeDetector('abc', '123');
53+
54+
$deduplicate = $changeDetector->deduplicate();
55+
56+
self::assertSame(['Typhoon\ChangeDetector\ComposerPackageChangeDetector{"name":"abc","reference":"123"}' => $changeDetector], $deduplicate);
57+
}
4958
}

tests/ChangeDetector/FileChangeDetectorTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use org\bovigo\vfs\vfsStream;
88
use org\bovigo\vfs\vfsStreamDirectory;
99
use PHPUnit\Framework\Attributes\CoversClass;
10+
use PHPUnit\Framework\Attributes\TestWith;
1011
use PHPUnit\Framework\TestCase;
1112

1213
#[CoversClass(FileChangeDetector::class)]
@@ -86,4 +87,13 @@ public function testItReturnsDeduplicatedDetectors(): void
8687

8788
self::assertCount(3, $deduplicated);
8889
}
90+
91+
#[TestWith([false, 'awdawd'])]
92+
#[TestWith([123, false])]
93+
public function testCannotCreateWithInvalidMtimeXxh3Combinations(false|int $mtime, false|string $xxh3): void
94+
{
95+
$this->expectException(\AssertionError::class);
96+
97+
new FileChangeDetector('a', $mtime, $xxh3);
98+
}
8999
}

0 commit comments

Comments
 (0)