From 4c80332406f95a66927bc472ab75896a33e85954 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Sun, 26 Oct 2025 18:40:47 +0100 Subject: [PATCH 1/5] Setup mutation testing --- .github/workflows/build.yml | 61 +++++++++++++++++++++++++++++++++++++ phpstan.neon | 2 ++ phpunit.xml | 3 +- 3 files changed, 65 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 28ab39c6..065a6544 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -213,3 +213,64 @@ jobs: - name: "PHPStan" run: "make phpstan" + + mutation-testing: + name: "Mutation Testing" + runs-on: "ubuntu-latest" + needs: ["tests", "static-analysis"] + + strategy: + fail-fast: false + matrix: + php-version: + - "8.2" + - "8.3" + - "8.4" + operating-system: [ubuntu-latest] + + steps: + - name: "Checkout" + uses: actions/checkout@v5 + + - name: "Install PHP" + uses: "shivammathur/setup-php@v2" + with: + coverage: "pcov" + php-version: "${{ matrix.php-version }}" + tools: pecl, infection:0.31.7 + extensions: mbstring + ini-file: development + ini-values: memory_limit=-1 + + - name: "Install dependencies" + run: "composer install --no-interaction --no-progress" + + - name: "Checkout build-infection" + uses: actions/checkout@v5 + with: + repository: "phpstan/build-infection" + path: "build-infection" + ref: "1.x" + + - name: "Install build-infection dependencies" + working-directory: "build-infection" + run: "composer install --no-interaction --no-progress" + + - name: "Configure infection" + run: | + php build-infection/bin/infection-config.php \ + > infection.json5 + cat infection.json5 | jq + + - name: "Run infection" + run: | + git fetch --depth=1 origin $GITHUB_BASE_REF + infection \ + --git-diff-base=origin/$GITHUB_BASE_REF \ + --git-diff-lines \ + --ignore-msi-with-no-mutations \ + --min-msi=100 \ + --min-covered-msi=100 \ + --log-verbosity=all \ + --debug \ + --logger-text=php://stdout diff --git a/phpstan.neon b/phpstan.neon index 7f64d1c0..a88579c4 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -9,6 +9,8 @@ includes: parameters: reportUnmatchedIgnoredErrors: false + resultCachePath: tmp/resultCache.php + excludePaths: - tests/*/data/* ignoreErrors: diff --git a/phpunit.xml b/phpunit.xml index 420ef740..2ccef9fc 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -10,7 +10,8 @@ beStrictAboutTodoAnnotatedTests="true" failOnRisky="true" failOnWarning="true" - xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xml" + xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd" + executionOrder="random" > From fd11c3523e98a28db4172d3aeeaced4f0356cf95 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Sun, 26 Oct 2025 18:44:04 +0100 Subject: [PATCH 2/5] Update build.yml --- .github/workflows/build.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 065a6544..586de43e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -262,6 +262,14 @@ jobs: > infection.json5 cat infection.json5 | jq + - name: "Cache Result cache" + uses: actions/cache@v4 + with: + path: ./tmp + key: "result-cache-v1-${{ matrix.php-version }}-${{ github.run_id }}" + restore-keys: | + result-cache-v1-${{ matrix.php-version }}- + - name: "Run infection" run: | git fetch --depth=1 origin $GITHUB_BASE_REF From 2aaa392f8254fcb04aca00c4fcca4fea4307ab6c Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Sun, 26 Oct 2025 18:46:31 +0100 Subject: [PATCH 3/5] Update build.yml --- .github/workflows/build.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 586de43e..ea90ca25 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -8,6 +8,10 @@ on: branches: - "2.0.x" +concurrency: + group: build-${{ github.head_ref || github.run_id }} # will be canceled on subsequent pushes in pull requests but not branches + cancel-in-progress: true + jobs: lint: name: "Lint" From 6dc362bfb7d204a9da94809e39747a3d3aa722d4 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Sun, 26 Oct 2025 21:16:19 +0100 Subject: [PATCH 4/5] use composite action --- .github/workflows/build.yml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ea90ca25..eb32e1ee 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -236,15 +236,10 @@ jobs: - name: "Checkout" uses: actions/checkout@v5 - - name: "Install PHP" - uses: "shivammathur/setup-php@v2" + - uses: ./build-infection/.github/actions/setup-php with: - coverage: "pcov" php-version: "${{ matrix.php-version }}" - tools: pecl, infection:0.31.7 extensions: mbstring - ini-file: development - ini-values: memory_limit=-1 - name: "Install dependencies" run: "composer install --no-interaction --no-progress" From d9a20b63dc3c9a4629d1b77fa52794d35c56870e Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Sun, 26 Oct 2025 21:18:29 +0100 Subject: [PATCH 5/5] Update build.yml --- .github/workflows/build.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index eb32e1ee..f4f92b51 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -236,6 +236,13 @@ jobs: - name: "Checkout" uses: actions/checkout@v5 + - name: "Checkout build-infection" + uses: actions/checkout@v5 + with: + repository: "phpstan/build-infection" + path: "build-infection" + ref: "1.x" + - uses: ./build-infection/.github/actions/setup-php with: php-version: "${{ matrix.php-version }}" @@ -244,13 +251,6 @@ jobs: - name: "Install dependencies" run: "composer install --no-interaction --no-progress" - - name: "Checkout build-infection" - uses: actions/checkout@v5 - with: - repository: "phpstan/build-infection" - path: "build-infection" - ref: "1.x" - - name: "Install build-infection dependencies" working-directory: "build-infection" run: "composer install --no-interaction --no-progress"