diff --git a/.github/workflows/infection.yml b/.github/workflows/infection.yml new file mode 100644 index 0000000..0acdb7b --- /dev/null +++ b/.github/workflows/infection.yml @@ -0,0 +1,24 @@ +--- + +on: # yamllint disable-line rule:truthy + pull_request: + push: + branches: + - 4.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 6b7b5f8..978d696 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,7 @@ [![Psalm Level](https://shepherd.dev/github/cycle/migrations/level.svg)](https://shepherd.dev/github/cycle/migrations) [![Type Coverage](https://shepherd.dev/github/cycle/migrations/coverage.svg)](https://shepherd.dev/github/cycle/migrations) [![Codecov](https://img.shields.io/codecov/c/github/cycle/migrations/4.x?style=flat-square&logo=codecov)](https://codecov.io/gh/cycle/migrations/tree/4.x) +[![Mutation testing badge](https://img.shields.io/endpoint?style=flat-square&url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2Fcycle%2Fmigrations%2F4.x)](https://dashboard.stryker-mutator.io/reports/github.com/cycle/migrations/4.x) diff --git a/composer.json b/composer.json index 205b268..6c97f38 100644 --- a/composer.json +++ b/composer.json @@ -57,6 +57,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" + ], "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", @@ -69,6 +81,8 @@ "test:unit": "testo --suite=Unit" }, "scripts-descriptions": { + "infect": "Run mutation testing with Infection against the Unit and SQLite suites", + "infect:ci": "Run mutation testing in CI: GitHub annotations, the Stryker dashboard report and the MSI gate", "test:new-case": "Generate a regression case for an issue: composer test:new-case -- " }, "minimum-stability": "dev", diff --git a/infection.json b/infection.json new file mode 100644 index 0000000..0dec2b2 --- /dev/null +++ b/infection.json @@ -0,0 +1,18 @@ +{ + "$schema": "vendor-bin/infection/vendor/infection/infection/resources/schema.json", + "source": { + "directories": [ + "src" + ] + }, + "timeout": 10, + "minMsi": 95, + "minCoveredMsi": 95, + "testFramework": "testo", + "tmpDir": "runtime", + "logs": { + "stryker": { + "report": "4.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..8436e13 --- /dev/null +++ b/vendor-bin/infection/composer.json @@ -0,0 +1,11 @@ +{ + "require": { + "infection/infection": "^0.35", + "testo/bridge-infection": "^0.1.9" + }, + "config": { + "allow-plugins": { + "infection/extension-installer": true + } + } +}