Skip to content
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

Add mutation testing #7

Merged
merged 2 commits into from
Jun 27, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion .github/workflows/ca.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
id: composer-cache
uses: actions/cache@v3
with:
path: vendor
path: ~/.cache/composer
key: composer-${{ matrix.php-version }}-${{ hashFiles('composer.*') }}
restore-keys: |
composer-${{ matrix.php-version }}-
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/cs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
id: composer-cache
uses: actions/cache@v3
with:
path: vendor
path: ~/.cache/composer
key: composer-${{ matrix.php-version }}-${{ hashFiles('composer.*') }}
restore-keys: |
composer-${{ matrix.php-version }}-
Expand Down
48 changes: 48 additions & 0 deletions .github/workflows/mt.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# yamllint disable rule:line-length
# yamllint disable rule:braces

name: Mutation Testing

on:
pull_request:
push:
branches:
- main

permissions: read-all

jobs:
build:
name: Mutatation testing with PHP ${{ matrix.php-version }}
runs-on: ubuntu-latest

strategy:
matrix:
php-version:
- "8.2"

steps:
- uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
coverage: pcov

- name: Cache Composer packages
uses: actions/cache@v3
with:
path: ~/.cache/composer
key: composer-${{ matrix.php-version }}-${{ hashFiles('composer.*') }}
restore-keys: |
composer-${{ matrix.php-version }}-
composer-

- name: Install dependencies
run: |
composer install --prefer-dist --no-progress

- name: Run Infection
run: |
make mt SILENT=
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ COMPOSER=$(PHP) $(shell which composer)

# Infection
INFECTION=vendor/bin/infection
MIN_MSI=50
MIN_COVERED_MSI=50
INFECTION_ARGS=--min-msi=$(MIN_MSI) --min-covered-msi=$(MIN_COVERED_MSI) --threads=$(JOBS) --coverage=build/logs --show-mutations --no-interaction --only-covered --only-covering-test-cases
MIN_MSI=84
MIN_COVERED_MSI=84
INFECTION_ARGS=--min-msi=$(MIN_MSI) --min-covered-msi=$(MIN_COVERED_MSI) --threads=$(JOBS) --coverage=build/logs --show-mutations --no-interaction

all: test

Expand All @@ -56,8 +56,8 @@ phpunit-coverage: cs prerequisites
rm -fr build/logs/*
$(SILENT) $(PHP) $(PHPUNIT) $(PHPUNIT_ARGS)

.PHONY: infection
infection: phpunit-coverage prerequisites infection.json.dist
.PHONY: mt
mt: phpunit-coverage prerequisites infection.json.dist
$(SILENT) $(PHP) $(INFECTION) $(INFECTION_ARGS)

.PHONY: sa
Expand Down
11 changes: 11 additions & 0 deletions infection.json.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"$schema": "vendor/infection/infection/resources/schema.json",
"source": {
"directories": [
"src"
]
},
"mutators": {
"@default": true
}
}
Loading