This python-mutation-report performs a mutation test on the changed lines in the pull request with mutmut of the pip package, and comments the mutation test summary as shown in the example below.
- If the directory structure is as follows.
. ├── README.md └── python-project ├── Pipfile ├── Pipfile.lock ├── src │ ├── __init__.py │ ├── src_1.py │ └── src_2.py └── tests ├── __init__.py ├── test_src_1.py └── test_src_2.py
on:
pull_request:
paths:
- "python-project/src/**"
- "python-project/tests/**"
jobs:
mutation-testing-report:
runs-on: ubuntu-latest
name: Mutation testing report
timeout-minutes: 15
permissions:
pull-requests: write
contents: read
steps:
- uses: actions/checkout@v4
- uses: Century-ss/python-mutation-report@v2
with:
lock-file-path: "python-project/Pipfile.lock"
src-directory: "python-project/src"
test-directory: "python-project/tests"
where-to-run-test: "python-project"
python-version: "3.11"- Only
pull_requestevents are supported. - Perform mutation test only on
pull_requestchanged lines in files undersrc-directory. - Only
ubuntuandmac osrunners are supported. - Only
pytestis supported as a test module. Write permission for pull_requestandread permission for contentsis required.- If there are many changed files in the pull_request, it may take longer, so it is recommended to set a
timeout-minutes.
- If the change diff has a
hoge.pyin the src file, trying to findtest_hoge.pyin the test directory- If
test_hoge.pyis found, includehoge.pyandtest_hoge.pyin the mutation test. - If
test_hoge.pyis not found, not includehoge.pyin the mutation test. - If multiple
test_hoge.pyis found, include them all in the mutation test.
- If
- Required parameters
lock-file-path: Lock file path for installing python dependencies. The following lock files are supported.requirements.txtof pip.Pipfile.lockof pipenvrequirements-dev.lockorrequirements.lockof rye.
src-directory: Directory path of the source to plant the mutant.test-directory: Directory path of the test to evaluate the mutant.
- Optional parameters.
where-to-run-test: Path to the location where test is run. Default is".", it runs in the repository root directory.python-version: Version of python used. Default is"3.11"
No outputs.
