Skip to content

Commit

Permalink
Add mutation testing (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
sanmai committed Jun 27, 2023
1 parent 72b56cf commit fc3bac2
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 7 deletions.
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
}
}

0 comments on commit fc3bac2

Please sign in to comment.