Skip to content

Commit

Permalink
Enhancement: Run mutation tests with infection/infection
Browse files Browse the repository at this point in the history
  • Loading branch information
localheinz committed Dec 27, 2021
1 parent e368627 commit f56c74c
Show file tree
Hide file tree
Showing 8 changed files with 843 additions and 8 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Expand Up @@ -6,6 +6,7 @@
/.gitignore export-ignore
/.php_cs export-ignore
/composer-require-checker.json export-ignore
/infection.json export-ignore
/Makefile export-ignore
/psalm-baseline.xml export-ignore
/psalm.xml export-ignore
12 changes: 12 additions & 0 deletions .github/CONTRIBUTING.md
Expand Up @@ -83,6 +83,18 @@ $ make tests

to run all the tests.

## Mutation Tests

We are using [`infection/infection`](https://github.com/infection/infection) to ensure a minimum quality of the tests.

Enable `Xdebug` and run

```sh
$ make mutation-tests
```

to run mutation tests.

## Extra lazy?

Run
Expand Down
1 change: 1 addition & 0 deletions .github/settings.yml
Expand Up @@ -17,6 +17,7 @@ branches:
- "Code Coverage (7.4, locked)"
- "Coding Standards (7.4, locked)"
- "Dependency Analysis (7.4, locked)"
- "Mutation Tests (7.4, locked)"
- "Static Code Analysis (7.4, locked)"
- "Tests (7.4, highest)"
- "Tests (7.4, locked)"
Expand Down
44 changes: 42 additions & 2 deletions .github/workflows/integrate.yaml
Expand Up @@ -9,8 +9,6 @@ on: # yamllint disable-line rule:truthy
- "main"

env:
MIN_COVERED_MSI: 92
MIN_MSI: 92
PHP_EXTENSIONS: "mbstring"

jobs:
Expand Down Expand Up @@ -264,3 +262,45 @@ jobs:
env:
CODECOV_TOKEN: "${{ secrets.CODECOV_TOKEN }}"
run: "bash <(curl -s https://codecov.io/bash)"

mutation-tests:
name: "Mutation Tests"

runs-on: "ubuntu-latest"

strategy:
matrix:
php-version:
- "7.4"

dependencies:
- "locked"

steps:
- name: "Checkout"
uses: "actions/checkout@v2.4.0"

- name: "Install PHP with extensions"
uses: "shivammathur/setup-php@2.16.0"
with:
coverage: "xdebug"
extensions: "${{ env.PHP_EXTENSIONS }}"
php-version: "${{ matrix.php-version }}"

- name: "Determine composer cache directory"
uses: "./.github/actions/composer/composer/determine-cache-directory"

- name: "Cache dependencies installed with composer"
uses: "actions/cache@v2.1.7"
with:
path: "${{ env.COMPOSER_CACHE_DIR }}"
key: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }}"
restore-keys: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-"

- name: "Install ${{ matrix.dependencies }} dependencies with composer"
uses: "./.github/actions/composer/composer/install"
with:
dependencies: "${{ matrix.dependencies }}"

- name: "Run mutation tests with Xdebug and infection/infection"
run: "vendor/bin/infection --configuration=infection.json"
8 changes: 5 additions & 3 deletions Makefile
@@ -1,6 +1,3 @@
MIN_COVERED_MSI:=92
MIN_MSI:=92

.PHONY: it
it: coding-standards static-code-analysis tests ## Runs the coding-standards, static-code-analysis, and tests targets

Expand All @@ -24,6 +21,11 @@ dependency-analysis: vendor ## Runs a dependency analysis with maglnet/composer-
help: ## Displays this list of targets with descriptions
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[32m%-30s\033[0m %s\n", $$1, $$2}'

.PHONY: mutation-tests
mutation-tests: vendor ## Runs mutation tests with infection/infection
mkdir -p .build/infection
vendor/bin/infection --configuration=infection.json

.PHONY: static-code-analysis
static-code-analysis: vendor ## Runs a static code analysis with vimeo/psalm
mkdir -p .build/psalm
Expand Down
4 changes: 3 additions & 1 deletion composer.json
Expand Up @@ -24,13 +24,15 @@
"ergebnis/license": "^1.1.0",
"ergebnis/php-cs-fixer-config": "^3.4.0",
"fakerphp/faker": "^1.17.0",
"infection/infection": "~0.25.5",
"phpunit/phpunit": "^9.5.11",
"psalm/plugin-phpunit": "~0.16.1",
"vimeo/psalm": "^4.16.1"
},
"config": {
"allow-plugins": {
"composer/package-versions-deprecated": true
"composer/package-versions-deprecated": true,
"infection/extension-installer": true
},
"platform": {
"php": "7.4.26"
Expand Down

0 comments on commit f56c74c

Please sign in to comment.