Skip to main content

pytest-mergify

Pytest plugin for Mergify Test Engine.

More information at https://mergify.com

Features

  • Test tracing — Sends OpenTelemetry traces for every test to Mergify's API
  • Flaky test detection — Intelligently reruns tests to detect flakiness with budget constraints
  • Test quarantine — Quarantines failing tests so they don't block CI
  • Test selection — Runs only the previously-failing tests when Mergify's merge queue reruns a job

Installation

Install the package alongside pytest (>= 6.0.0):

pip install pytest-mergify

The plugin is auto-discovered by pytest — no manual registration required.

Configuration

Set the MERGIFY_TOKEN environment variable with your Mergify API token.

The plugin activates automatically when running in CI (detected via the CI environment variable). To enable outside CI, set MERGIFY_CI_ENABLE=true.

Environment Variables

Variable Description Default
MERGIFY_TOKEN Mergify API authentication token (required)
MERGIFY_API_URL Mergify API endpoint https://api.mergify.com
MERGIFY_CI_ENABLE Force-enable outside CI false
MERGIFY_CI_DEBUG Print spans to console instead of uploading false
MERGIFY_TRACEPARENT W3C distributed trace context —
MERGIFY_TEST_JOB_NAME Mergify test job name —
MERGIFY_TEST_SELECTION_ENABLE Opt this job into test selection (see below) false

The names these replace, PYTEST_MERGIFY_ENABLE and PYTEST_MERGIFY_DEBUG, are deprecated: they still work when the new name is not set, and the plugin says which one to switch to at the end of the session.

For detailed documentation, see the official guide.

Test selection

When Mergify's merge queue reruns a job — a retry, or a step of a batch bisection — only the tests that failed on the previous attempt are informative. The plugin asks Mergify whether the current run is such a rerun and, if so, runs only those tests; the rest are reported as deselected.

Two other answers exist. Mergify may say the previous attempt of this job already ran every one of these tests and they all passed: the run then executes no test and exits green, and still reports itself so the attempt is visible. Or Mergify may stop the run outright. That happens when several runs of this job report under the same name and run the same tests: Mergify cannot tell which one the current run repeats, and it will not guess which tests to skip. The run then fails, showing Mergify's explanation of what it saw — usually asking you to give each of those runs its own MERGIFY_TEST_JOB_NAME.

This is off until you turn it on, per job. Installing the plugin is not enough: a feature that decides not to run tests starts only where you wrote that it should. Set MERGIFY_TEST_SELECTION_ENABLE=true on the job you want reduced:

      - name: Run tests
        run: pytest
        env:
          MERGIFY_TOKEN: ${{ secrets.MERGIFY_TOKEN }}
          MERGIFY_TEST_SELECTION_ENABLE: "true"

A job that does not set it never queries the endpoint and always runs the full suite; everything else the plugin does — test tracing, flaky detection, quarantine — is unaffected either way. Anything that is not a recognised yes (unset, empty, false, or a value the plugin cannot parse) means no.

Past that there is nothing to configure: the plugin uses the token and job identity it already has, and Mergify decides. Every remaining situation — a normal run, a rerun Mergify has no previous results for, an unreachable API, an answer from a newer Mergify this plugin does not understand — runs the full suite, so the feature never costs coverage. It is also enabled per organization on Mergify's side, so a job that opts in stays inactive until your organization is opted in too.

Bisection steps: failures first

When the merge queue splits a failed batch, a test that passed with every pull request of the batch can fail with only some of them, so a bisection step is never reduced: it runs its full suite. Mergify may instead tell it to run first the tests this job failed in the run the step was split from. They run before every other test; if one of them fails again, the step is red whatever the rest does, so the run stops there (exit code 1, the remaining tests not run) and the queue can split again without waiting for the suite. If they all pass, the rest of the suite runs as usual. No test is ever skipped, so a green step still comes from a full suite. A test a retry rescued, or a quarantined failure, does not stop the run.

Under pytest-xdist this works with the load (the default with -n) and worksteal schedulers; with loadgroup, tests marked xdist_group still run before them. With loadscope and loadfile, xdist schedules whole modules or classes by size, so those tests do not run first: the run still stops once they have all run and one failed again. Workers on a remote gateway (--tx ssh=…) run to the end.

An opted-in job also tells Mergify what it concluded when its session ends — which tests failed, how many ran — in one small request sent before the test results are uploaded. That is what the next rerun of the job is answered from, seconds after this one finished, without waiting for the results to be processed. If that request fails, the run's own result is untouched: the terminal says so, and the next rerun simply runs the full suite.

Development

Prerequisites

  • Python >= 3.10
  • uv

Setup

uv sync

Running Tests

uv run poe test

uv run poe build builds the wheel into dist/; when one is there, poe test runs against it rather than the project's own install, which is how CI builds the extension once for every Python version. Every uv-driven build of the extension uses Cargo's dev profile.

Linting

uv run poe lint

License

Proprietary. Use is governed by the Mergify Terms of Service.

Metadata

Release files for pytest-mergify 2026.10.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for pytest-mergify 2026.10.6
File
pytest_mergify-2026.10.6-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details
pytest_mergify-2026.10.6-cp310-abi3-musllinux_1_2_x86_64.whl CPython 3.10 abi3 Linux musl 1.2+ x86-64 Details
pytest_mergify-2026.10.6-cp310-abi3-musllinux_1_2_aarch64.whl CPython 3.10 abi3 Linux musl 1.2+ ARM64 Details
pytest_mergify-2026.10.6-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.10 abi3 Linux glibc 2.17+ x86-64 Details
pytest_mergify-2026.10.6-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.10 abi3 Linux glibc 2.17+ ARM64 Details
pytest_mergify-2026.10.6-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details
pytest_mergify-2026.10.6-cp310-abi3-macosx_10_12_x86_64.whl CPython 3.10 abi3 macOS 10.12+ x86-64 Details

Total release size: 24.9 MB

Release files / pytest_mergify-2026.10.6-cp310-abi3-win_amd64.whl

Download URL pytest_mergify-2026.10.6-cp310-abi3-win_amd64.whl
Size 3.4 MB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
4ebe967a2d1a0ad7e09449a6696b8507715950c7473eb43bedd1ea6607b3131f
BLAKE2b-256 checksum
How to use checksums
21098e9cc14efe9ada46e70278f345f0e5cab80be719148721884ae5b710b94d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 22, 2026.

Transparency log

Release files / pytest_mergify-2026.10.6-cp310-abi3-musllinux_1_2_x86_64.whl

Download URL pytest_mergify-2026.10.6-cp310-abi3-musllinux_1_2_x86_64.whl
Size 3.9 MB
Tags CPython 3.10 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
6cba9c2de5535a35d138dc23286aba164c3331f7fec0da600496354166a5321f
BLAKE2b-256 checksum
How to use checksums
5f97004199daeea14bc3afc865225d9657a19f5c9794e60514b70a54e50dea38
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 22, 2026.

Transparency log

Release files / pytest_mergify-2026.10.6-cp310-abi3-musllinux_1_2_aarch64.whl

Download URL pytest_mergify-2026.10.6-cp310-abi3-musllinux_1_2_aarch64.whl
Size 3.6 MB
Tags CPython 3.10 Linux musl 1.2+ ARM64 abi3
SHA-256 checksum
How to use checksums
d2fb6ef2b4f6c9205e78e893b447efd2fc4f6a354d330be5c7176dfac6da989f
BLAKE2b-256 checksum
How to use checksums
80060576ff22ab4bf759267da20b77b148bc4ec677f443aeffa92175a27f02af
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 22, 2026.

Transparency log

Release files / pytest_mergify-2026.10.6-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL pytest_mergify-2026.10.6-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 3.7 MB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
04a3a22bdffefb410505ccdb2f1aeec5c90358a9b2afbabc00b50ca64767cbda
BLAKE2b-256 checksum
How to use checksums
52eee789a5adafc8536984d0e5d550e0c5b851d536884d9c67c464dedabe37e5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 22, 2026.

Transparency log

Release files / pytest_mergify-2026.10.6-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL pytest_mergify-2026.10.6-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 3.4 MB
Tags CPython 3.10 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
12de2800d368c4e14a516a0f40486897c21ebf3cfa47286779ad10a6c7fdf897
BLAKE2b-256 checksum
How to use checksums
a94317167657dac96694369649b1b2a883e41ff522ef2be8aaa3d9085e73b099
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 22, 2026.

Transparency log

Release files / pytest_mergify-2026.10.6-cp310-abi3-macosx_11_0_arm64.whl

Download URL pytest_mergify-2026.10.6-cp310-abi3-macosx_11_0_arm64.whl
Size 3.3 MB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
eba429900d1008f63c631f2b3a3b7825d496a96142db16ac681932005f163b65
BLAKE2b-256 checksum
How to use checksums
6383ceb0b63d6450b75b554ec2c6d9a0b382b98b22cd5fc77ffbeda740108b70
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 22, 2026.

Transparency log

Release files / pytest_mergify-2026.10.6-cp310-abi3-macosx_10_12_x86_64.whl

Download URL pytest_mergify-2026.10.6-cp310-abi3-macosx_10_12_x86_64.whl
Size 3.6 MB
Tags CPython 3.10 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
191d410226390852ac11629c54786c3a957a91d40f4408f2e331ef083a5cd83b
BLAKE2b-256 checksum
How to use checksums
8f4901b3397b8c544fe0a164f82b5cebc3fa06169fbd23442dcf470885ec59ab
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 22, 2026.

Transparency log

Security for pytest-mergify 2026.10.6

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 7 files in this release have been uploaded with provenance metadata.

Select from 7 files

Attestation for pytest_mergify-2026.10.6-cp310-abi3-win_amd64.whl

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 22, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

2026.10.6 This release

7 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page