Skip to main content

pytest-mergify

Pytest plugin for Mergify Test Insights.

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 PYTEST_MERGIFY_ENABLE=true.

Environment Variables

Variable Description Default
MERGIFY_TOKEN Mergify API authentication token (required)
MERGIFY_API_URL Mergify API endpoint https://api.mergify.com
PYTEST_MERGIFY_ENABLE Force-enable outside CI false
PYTEST_MERGIFY_DEBUG Print spans to console 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

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.

Development

Prerequisites

  • Python >= 3.8
  • uv

Setup

uv sync

Running Tests

uv run poe test

Linting

uv run poe linters

License

Apache-2.0

Metadata

Release files for pytest-mergify 2026.9.11.1

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

Source distribution (sdist)

Source distribution for pytest-mergify 2026.9.11.1
File Size Uploaded
pytest_mergify-2026.9.11.1.tar.gz 128.0 kB Details

Built distributions (wheels)

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

Total release size: 21.4 MB

Release files / pytest_mergify-2026.9.11.1.tar.gz

Download URL pytest_mergify-2026.9.11.1.tar.gz
Size 128.0 kB
Tags Source
SHA-256 checksum
How to use checksums
26014258ed91283629cc9937c68f6da124e80345b1c280ad02599b39ed853fdd
BLAKE2b-256 checksum
How to use checksums
2d73b9fb802d2ffc44b04184d87c4b799fb66007fa09d3aae6622503da9fe542
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 11, 2026.

Transparency log

Release files / pytest_mergify-2026.9.11.1-cp38-abi3-win_amd64.whl

Download URL pytest_mergify-2026.9.11.1-cp38-abi3-win_amd64.whl
Size 2.9 MB
Tags CPython 3.8 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
9598d8fbf9e3cf848af82213927244d1dda73c6c088d821656a09e8df6190762
BLAKE2b-256 checksum
How to use checksums
e7d3d874aacd80d56882a7c42b0d5e820af066d56fb9c7e380387247cab02c15
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 11, 2026.

Transparency log

Release files / pytest_mergify-2026.9.11.1-cp38-abi3-musllinux_1_2_x86_64.whl

Download URL pytest_mergify-2026.9.11.1-cp38-abi3-musllinux_1_2_x86_64.whl
Size 3.4 MB
Tags CPython 3.8 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
2d7d49241884c534b318fea69bb409151af32aefc6b94dd769cee0568a8a5bea
BLAKE2b-256 checksum
How to use checksums
682c644db62260128bde8ea7442072932161f7a73180ab0f5e9146a3a5dad680
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 11, 2026.

Transparency log

Release files / pytest_mergify-2026.9.11.1-cp38-abi3-musllinux_1_2_aarch64.whl

Download URL pytest_mergify-2026.9.11.1-cp38-abi3-musllinux_1_2_aarch64.whl
Size 3.1 MB
Tags CPython 3.8 Linux musl 1.2+ ARM64 abi3
SHA-256 checksum
How to use checksums
4594539730fac8533d6c79a3116502082e4d1b7ec38e16ba11329a986ee181a0
BLAKE2b-256 checksum
How to use checksums
ff182680df595a229701908a0135c58716a71d0256a4053d7de1591ab4b632e0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 11, 2026.

Transparency log

Release files / pytest_mergify-2026.9.11.1-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL pytest_mergify-2026.9.11.1-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 3.1 MB
Tags CPython 3.8 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
47777ee88e4e98336b8fc0e19e92ccca808364dea0dd0e1305c70f3b28c3f346
BLAKE2b-256 checksum
How to use checksums
33b9de4c3c78c37b2d2daa14891b94d0fe9aed2fc300589bc1bb03f6bcaf20d5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 11, 2026.

Transparency log

Release files / pytest_mergify-2026.9.11.1-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL pytest_mergify-2026.9.11.1-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 2.9 MB
Tags CPython 3.8 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
bb94aeed73cb77abe279e25c358bdee56e595faae781e81e9cf3b351c05b777d
BLAKE2b-256 checksum
How to use checksums
773593376cd0fb700e90c8d38d92cb3257e83695918a8a958e88a7fcb8ec714b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 11, 2026.

Transparency log

Release files / pytest_mergify-2026.9.11.1-cp38-abi3-macosx_11_0_arm64.whl

Download URL pytest_mergify-2026.9.11.1-cp38-abi3-macosx_11_0_arm64.whl
Size 2.8 MB
Tags CPython 3.8 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
4475ac5d70b60b4d3b5023036f6a660eaeb94be061c9227aa2aa871a6e5c3787
BLAKE2b-256 checksum
How to use checksums
f9ef99dca3d971979361b7705a1a4fe3c894d5b8950bed75df39bdca5b1d527a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 11, 2026.

Transparency log

Release files / pytest_mergify-2026.9.11.1-cp38-abi3-macosx_10_12_x86_64.whl

Download URL pytest_mergify-2026.9.11.1-cp38-abi3-macosx_10_12_x86_64.whl
Size 3.0 MB
Tags CPython 3.8 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
83e9db8266511b7add53f78884cadc747b1f76bb4f7bec4f217ac82eed9e3824
BLAKE2b-256 checksum
How to use checksums
114f67941dd6a6b2c8cdaf5d9ec73381e0544f92c0e2121d07b66fc6dccfc453
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 11, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

2026.9.11.1 This release

8 release files

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