From 43992085d45b6a803e3d99926030489de259fabd Mon Sep 17 00:00:00 2001 From: roxblnfk Date: Fri, 20 Nov 2026 19:19:33 +0400 Subject: [PATCH 1/3] chore: install Infection with the Testo adapter DB_DRIVERS=sqlite limits the run to the Unit and SQLite suites, which need no database server. The adapter lives in vendor-bin/infection only, and the thresholds sit a few points below the measured MSI. Assisted-By: Claude Opus 5.5 --- composer.json | 9 ++++++--- infection.json | 18 ++++++++---------- vendor-bin/infection/composer.json | 2 +- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/composer.json b/composer.json index 94a8dd6..257116a 100644 --- a/composer.json +++ b/composer.json @@ -53,7 +53,6 @@ "roxblnfk/unpoly": "^1.8", "spiral/boot": "^3.18", "spiral/cycle-bridge": "^2.13", - "testo/bridge-infection": "^0.1.9", "testo/testo": "^0.10.60" }, "suggest": { @@ -124,13 +123,13 @@ "Composer\\Config::disableProcessTimeout", "@putenv XDEBUG_MODE=coverage", "@putenv DB_DRIVERS=sqlite", - "infection" + "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=50" + "infection --ansi --configuration=infection.json --logger-github --threads=max --show-mutations=0" ], "psalm": "psalm -c vendor-bin/psalm/psalm.xml --show-info=true", "psalm:baseline": "psalm -c vendor-bin/psalm/psalm.xml --set-baseline=vendor-bin/psalm/psalm-baseline.xml", @@ -148,5 +147,9 @@ "@putenv DB_DRIVERS=sqlite", "testo --coverage" ] + }, + "scripts-descriptions": { + "infect": "Run mutation testing with Infection (install it first: composer bin infection install)", + "infect:ci": "Run mutation testing in CI: GitHub annotations and the MSI thresholds" } } diff --git a/infection.json b/infection.json index 726a428..287af6a 100644 --- a/infection.json +++ b/infection.json @@ -1,14 +1,5 @@ { "$schema": "vendor-bin/infection/vendor/infection/infection/resources/schema.json", - "ignoreMsiWithNoMutations": true, - "logs": { - "text": "runtime/infection/infection-log.txt", - "stryker": { - "report": "1.x" - } - }, - "minCoveredMsi": 50, - "minMsi": 50, "source": { "directories": [ "src" @@ -17,7 +8,14 @@ "Bridge" ] }, + "timeout": 10, + "minMsi": 90, + "minCoveredMsi": 90, "testFramework": "testo", "tmpDir": "runtime", - "timeout": 10 + "logs": { + "stryker": { + "report": "1.x" + } + } } diff --git a/vendor-bin/infection/composer.json b/vendor-bin/infection/composer.json index 8436e13..9709365 100644 --- a/vendor-bin/infection/composer.json +++ b/vendor-bin/infection/composer.json @@ -1,6 +1,6 @@ { "require": { - "infection/infection": "^0.35", + "infection/infection": "^0.35.12", "testo/bridge-infection": "^0.1.9" }, "config": { From 5e5f83aae73689143ac5ced5984baf7801287c51 Mon Sep 17 00:00:00 2001 From: roxblnfk Date: Fri, 20 Nov 2026 19:19:34 +0400 Subject: [PATCH 2/3] ci: run mutation testing through the shared cycle/gh-actions workflow Assisted-By: Claude Opus 5.5 --- .github/workflows/infection.yml | 51 +++++++-------------------------- 1 file changed, 10 insertions(+), 41 deletions(-) diff --git a/.github/workflows/infection.yml b/.github/workflows/infection.yml index 72817f3..e9d5af7 100644 --- a/.github/workflows/infection.yml +++ b/.github/workflows/infection.yml @@ -1,55 +1,24 @@ --- -name: ๐Ÿงฌ Mutation Tests - 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 ยท PHP ${{ matrix.php-version }} - timeout-minutes: 10 - runs-on: ubuntu-latest - concurrency: - cancel-in-progress: ${{ github.event_name == 'pull_request' }} - group: infection-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}-${{ matrix.php-version }} - strategy: - fail-fast: false - matrix: - php-version: - - '8.4' - steps: - - name: ๐Ÿ“ฆ Check out the codebase - uses: actions/checkout@v6 - with: - persist-credentials: false - - - name: ๐Ÿ› ๏ธ Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php-version }} - extensions: mbstring, pdo, pdo_sqlite - ini-values: error_reporting=E_ALL - coverage: xdebug - - - name: ๐Ÿ“ฅ Install dependencies with composer - uses: ramsey/composer-install@v3 - with: - dependency-versions: highest - - - name: ๐Ÿ“ฅ Install Infection - run: composer bin infection install --no-interaction --no-progress + name: Infection + uses: cycle/gh-actions/.github/workflows/infection.yml@master + secrets: inherit - - name: ๐Ÿงฌ Run mutation testing with Infection - run: composer infect:ci - env: - # Upload the report to the Stryker dashboard only on push to 1.x. - # On pull requests (and forks) the key is empty, so Infection skips the upload - # instead of overwriting the branch report with PR data. - STRYKER_DASHBOARD_API_KEY: ${{ github.event_name == 'push' && secrets.STRYKER_DASHBOARD_API_KEY || '' }} +... From 4e1b08ae921aba6d3f2a32956d58d7518ee5d603 Mon Sep 17 00:00:00 2001 From: roxblnfk Date: Fri, 20 Nov 2026 19:20:08 +0400 Subject: [PATCH 3/3] docs: describe mutation testing with the Testo adapter in CONTRIBUTING Assisted-By: Claude Opus 5.5 --- .github/CONTRIBUTING.md | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 60c41cb..f108f42 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -312,16 +312,15 @@ make lint-audit ## ๐Ÿฆ  Mutation Tests -We use [`infection/infection`](https://github.com/infection/infection) together with [`roave/infection-static-analysis-plugin`](https://github.com/Roave/infection-static-analysis-plugin) to ensure a minimum quality of the tests. Roave plugin is used to publish mutation score results to the [Stryker Dashboard](https://dashboard.stryker-mutator.io/). +We use [`infection/infection`](https://github.com/infection/infection) with the Testo adapter [`testo/bridge-infection`](https://github.com/php-testo/bridge-infection) to ensure a minimum quality of the tests. CI publishes the mutation score of the `1.x` branch to the [Stryker Dashboard](https://dashboard.stryker-mutator.io/reports/github.com/cycle/active-record/1.x). -Xdebug support is enabled by default when running commands through the `Makefile`: +Infection runs the Unit and SQLite suites and needs Xdebug or PCOV. Install it once, then run it: ```bash -make infect +composer bin infection install +composer infect ``` -to run mutation tests. -
## ๐Ÿ” Static Code Analysis