diff --git a/.github/workflows/infection.yml b/.github/workflows/infection.yml new file mode 100644 index 0000000..e9d5af7 --- /dev/null +++ b/.github/workflows/infection.yml @@ -0,0 +1,24 @@ +--- + +on: # yamllint disable-line rule:truthy + pull_request: + push: + branches: + - 1.x + +name: 🧬 Mutation Tests + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.ref }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} + +permissions: + contents: read + +jobs: + infection: + name: Infection + uses: cycle/gh-actions/.github/workflows/infection.yml@master + secrets: inherit + +... diff --git a/README.md b/README.md index 3c1f53e..3a7c442 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,7 @@ [![Psalm Level](https://shepherd.dev/github/cycle/entity-behavior-identifier/level.svg)](https://shepherd.dev/github/cycle/entity-behavior-identifier) [![Type Coverage](https://shepherd.dev/github/cycle/entity-behavior-identifier/coverage.svg)](https://shepherd.dev/github/cycle/entity-behavior-identifier) [![Codecov](https://codecov.io/gh/cycle/entity-behavior-identifier/branch/1.x/graph/badge.svg)](https://codecov.io/gh/cycle/entity-behavior-identifier) +[![Mutation testing badge](https://img.shields.io/endpoint?style=flat-square&url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2Fcycle%2Fentity-behavior-identifier%2F1.x)](https://dashboard.stryker-mutator.io/reports/github.com/cycle/entity-behavior-identifier/1.x) diff --git a/composer.json b/composer.json index b72d19f..6d433d7 100644 --- a/composer.json +++ b/composer.json @@ -87,6 +87,18 @@ "cs:fix": "php-cs-fixer fix -v --config=vendor-bin/code-style/.php-cs-fixer.dist.php", "db:down": "docker compose -f vendor/cycle/testing/resources/docker/compose.yaml down -v", "db:up": "docker compose -f vendor/cycle/testing/resources/docker/compose.yaml up -d --wait", + "infect": [ + "Composer\\Config::disableProcessTimeout", + "@putenv XDEBUG_MODE=coverage", + "@putenv DB_DRIVERS=sqlite", + "infection --configuration=infection.json --threads=max" + ], + "infect:ci": [ + "Composer\\Config::disableProcessTimeout", + "@putenv XDEBUG_MODE=coverage", + "@putenv DB_DRIVERS=sqlite", + "infection --ansi --configuration=infection.json --logger-github --threads=max --show-mutations=0 --min-msi=70 --min-covered-msi=70" + ], "psalm": "psalm -c vendor-bin/psalm/psalm.xml", "psalm:baseline": "psalm -c vendor-bin/psalm/psalm.xml --set-baseline=vendor-bin/psalm/psalm-baseline.xml", "psalm:ci": "psalm -c vendor-bin/psalm/psalm.xml --output-format=github --shepherd --show-info=false --stats --threads=4", @@ -99,6 +111,10 @@ "test:sqlserver": "testo --suite=Feature/SQLServer", "test:unit": "testo --suite=Unit" }, + "scripts-descriptions": { + "infect": "Run mutation testing with Infection on the Unit and SQLite suites", + "infect:ci": "Run mutation testing in CI, failing below the minimum MSI" + }, "extra": { "bamarni-bin": { "bin-links": true, diff --git a/infection.json b/infection.json new file mode 100644 index 0000000..cba3c6b --- /dev/null +++ b/infection.json @@ -0,0 +1,16 @@ +{ + "$schema": "vendor-bin/infection/vendor/infection/infection/resources/schema.json", + "source": { + "directories": [ + "src" + ] + }, + "timeout": 10, + "testFramework": "testo", + "tmpDir": "runtime", + "logs": { + "stryker": { + "report": "1.x" + } + } +} diff --git a/vendor-bin/infection/.gitignore b/vendor-bin/infection/.gitignore new file mode 100644 index 0000000..d4da745 --- /dev/null +++ b/vendor-bin/infection/.gitignore @@ -0,0 +1,4 @@ +/vendor/ +/composer.lock +/.*/ +/skills.json diff --git a/vendor-bin/infection/composer.json b/vendor-bin/infection/composer.json new file mode 100644 index 0000000..9709365 --- /dev/null +++ b/vendor-bin/infection/composer.json @@ -0,0 +1,11 @@ +{ + "require": { + "infection/infection": "^0.35.12", + "testo/bridge-infection": "^0.1.9" + }, + "config": { + "allow-plugins": { + "infection/extension-installer": true + } + } +}