Skip to content

Feat: Add Infection mutation testing - #8038

Open
UmairRathore wants to merge 2 commits into
LibreSign:mainfrom
UmairRathore:feat/infection-mutation-testing-8000
Open

Feat: Add Infection mutation testing#8038
UmairRathore wants to merge 2 commits into
LibreSign:mainfrom
UmairRathore:feat/infection-mutation-testing-8000

Conversation

@UmairRathore

Copy link
Copy Markdown

Resolves: #8000

📝 Summary

Adds Infection mutation testing to LibreSign and integrates it into GitHub Actions.

This PR:

  • adds Infection 0.35.x as an isolated Composer dependency under vendor-bin/infection
  • adds infection.json5 covering the lib/ source tree while excluding migrations
  • adds the required Nextcloud bootstrap so Infection can resolve both Nextcloud and LibreSign classes
  • adds a composer mutation:test command
  • adds a GitHub Actions workflow that installs Nextcloud, enables LibreSign, and runs mutation testing on pull requests
  • enforces minimum MSI and Covered Code MSI thresholds of 80%
  • uploads the Infection log when the mutation-testing job fails

While validating the full mutation suite, ProcessSignaler::stopPid() exposed a real OS side effect during mutation testing: mutations of the invalid-PID guard could allow PID 0 to reach posix_kill(), which signals the caller's process group.

To make this code safely mutation-testable, the OS signaling operation is isolated behind a protected sendSignal() boundary. The focused unit tests verify that invalid PIDs never reach this boundary and that valid PIDs are delegated correctly, without sending real process signals.

No Infection exclusions or mutator-specific ignores were added for this case.

🧪 How to test

Run the focused ProcessSignaler unit tests:

composer test:unit -- --filter ProcessSignalerTest

Run mutation testing:

composer mutation:test -- --no-progress --no-interaction

The focused ProcessSignaler validation produced:

  • 5 tests
  • 8 assertions
  • 11/11 mutants killed
  • 100% Covered Code MSI

A fresh end-to-end Infection run against the current checkout completed with:

  • 15,180 mutations generated
  • 7,305 killed
  • 1,779 escaped
  • 100% Mutation Code Coverage
  • 81% Covered Code MSI

The configured CI thresholds are:

MSI >= 80%
Covered Code MSI >= 80%

⚙️ API / Back-end changes

  • Added Infection mutation-testing configuration
  • Added isolated Infection Composer dependencies
  • Added Nextcloud/LibreSign bootstrap for mutation testing
  • Added GitHub Actions mutation-testing workflow
  • Added minimum MSI and Covered Code MSI thresholds
  • Isolated the process-signaling OS boundary for safe mutation testing
  • Added focused unit coverage for the signaling boundary
  • Capabilities updated — not applicable
  • API documentation updated — not applicable

✅ Checklist

  • I have read and followed the contribution guide.
  • Focused ProcessSignaler tests pass
  • Focused ProcessSignaler mutation testing passes with 100% MSI
  • Fresh end-to-end mutation run completed
  • git diff --check passes
  • Changes are limited to mutation-testing infrastructure and the required process-signaling test seam

🤖 AI

  • The content of this PR was partially or fully generated using AI

Signed-off-by: Umair Rathore <umairrathore05@gmail.com>
@github-project-automation github-project-automation Bot moved this to 0. Backlog in Roadmap Aug 23, 2026
@UmairRathore UmairRathore changed the title Add Infection mutation testing Feat: Add Infection mutation testing Aug 23, 2026
@UmairRathore
UmairRathore force-pushed the feat/infection-mutation-testing-8000 branch from c84c75a to 2a7d0c0 Compare August 23, 2026 07:42
Comment thread .github/workflows/infection.yml Outdated
Comment on lines +66 to +69
- name: Set up PHP 8.3
uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # 2.37.2
with:
php-version: 8.3

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have a pattern to get the minimum supported PHP version from appinfo/info.xml.

Could you reuse the same approach here instead of hardcoding PHP 8.3?

- name: Get php version
  id: php-versions
  uses: icewind1991/nextcloud-version-matrix@8a7bac6300b2f0f3100088b297995a229558ddba # v1.3.2.3.1.3.2
  with:
    filename: ${{ env.APP_NAME }}/appinfo/info.xml

Then:

php-version: ${{ steps.php-versions.outputs.php-min }}

This way, when the minimum supported PHP version changes in appinfo/info.xml, the Infection workflow will follow it automatically.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to derive the minimum supported PHP version from appinfo/info.xml using the existing version-matrix pattern. Thanks!

Comment thread .github/workflows/infection.yml Outdated
Comment on lines +89 to +92
./occ maintenance:install \
--database=sqlite \
--admin-user=admin \
--admin-pass=admin

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already use a more complete Nextcloud installation setup in the existing PHPUnit workflows.

Could you follow the same pattern here instead of relying on the default values?

      - name: Set up Nextcloud
        env:
          DB_PORT: 4444
        run: |
          mkdir data
          ./occ maintenance:install \
            --verbose \
            --database=sqlite \
            --database-name=nextcloud \
            --database-host=127.0.0.1 \
            --database-port=$DB_PORT \
            --database-user=root \
            --database-pass=rootpassword \
            --admin-user admin \
            --admin-pass admin

This keeps the Infection workflow equals to the same setup way used at workflows with PHPUnit and makes the CI environment explicit instead of depending on maintenance:install defaults.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the Nextcloud setup to match the explicit SQLite installation pattern used by the PHPUnit workflows. Thanks!

@github-project-automation github-project-automation Bot moved this from 0. Backlog to 1. to do in Roadmap Aug 23, 2026
@vitormattos

Copy link
Copy Markdown
Member

Thanks a lot by your contribution!
Before approve to execute the CI, only have small changes to do.

Signed-off-by: Umair Rathore <umairrathore05@gmail.com>
@UmairRathore
UmairRathore force-pushed the feat/infection-mutation-testing-8000 branch from 2a7d0c0 to 6121286 Compare August 23, 2026 13:07
@UmairRathore

Copy link
Copy Markdown
Author

Thanks for the review! I have addressed both requested changes. The Infection workflow now follows the existing PHPUnit patterns for PHP-version detection and Nextcloud installation. Appreciate the guidance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 1. to do

Development

Successfully merging this pull request may close these issues.

[FEATURE] Add PHP mutation testing with Infection

2 participants