Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Setup mutation testing #4480

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
ondrejmirtes merged 13 commits into phpstan:2.1.x from staabm:infec
Oct 27, 2025
Merged
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions .github/workflows/tests.yml
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -222,3 +222,71 @@ jobs:

- name: "Tests"
run: "make tests"

mutation-testing:
name: "Mutation Testing"
runs-on: "ubuntu-latest"
needs: ["tests", "tests-levels"]
Copy link
Member

@ondrejmirtes ondrejmirtes Oct 26, 2025

Choose a reason for hiding this comment

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

tests-levels? I don't want Infection to run these levels so it doesn't make sense to wait for them.

Copy link
Member

@ondrejmirtes ondrejmirtes Oct 26, 2025

Choose a reason for hiding this comment

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

Also: what about static analysis? I know it's in another workflow but not warmed-up cache might have a downside or two here?

Copy link
Contributor Author

@staabm staabm Oct 26, 2025
edited
Loading

Choose a reason for hiding this comment

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

tests-levels? I don't want Infection to run these levels so it doesn't make sense to wait for them.

I initially added levels to make sure we run late enough for the static analysis step... does no longer make sense as we no longer have the artifact down/upload step.

deleted it.

Also: what about static analysis? I know it's in another workflow but not warmed-up cache might have a downside or two here?

as we restore the previous cache I think it will be "fresh enough". waiting across workflows will complicate it, as this is only supported in github actions with work-arrounds. I don't think its worth the effort.

infection will start and fail in the "preparation phase" when SA is not green.

Copy link
Member

@ondrejmirtes ondrejmirtes Oct 26, 2025

Choose a reason for hiding this comment

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

I thought we could just run PHPStan again before Infection.

Copy link
Contributor Author

@staabm staabm Oct 26, 2025
edited
Loading

Choose a reason for hiding this comment

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

infection will run it once before it starts it as a process killer


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 }}"
ini-file: development
extensions: ds,mbstring
tools: infection:0.31.7

- 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: "Cache Result cache"
uses: actions/cache@v4
Copy link
Member

@ondrejmirtes ondrejmirtes Oct 26, 2025

Choose a reason for hiding this comment

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

This isn't going to save the cache if the build fails, right? Shouldn't we do what's recommended here? https://phpstan.org/user-guide/result-cache#setup-in-github-actions

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
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
Loading

AltStyle によって変換されたページ (->オリジナル) /