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.

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.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.18.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.18.1
File Size Uploaded
pytest_mergify-2026.9.18.1.tar.gz 160.5 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for pytest-mergify 2026.9.18.1
File
pytest_mergify-2026.9.18.1-cp38-abi3-win_amd64.whl CPython 3.8 abi3 Windows x86-64 Details
pytest_mergify-2026.9.18.1-cp38-abi3-musllinux_1_2_x86_64.whl CPython 3.8 abi3 Linux musl 1.2+ x86-64 Details
pytest_mergify-2026.9.18.1-cp38-abi3-musllinux_1_2_aarch64.whl CPython 3.8 abi3 Linux musl 1.2+ ARM64 Details
pytest_mergify-2026.9.18.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.18.1-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.8 abi3 Linux glibc 2.17+ ARM64 Details
pytest_mergify-2026.9.18.1-cp38-abi3-macosx_11_0_arm64.whl CPython 3.8 abi3 macOS 11.0+ ARM64 Details
pytest_mergify-2026.9.18.1-cp38-abi3-macosx_10_12_x86_64.whl CPython 3.8 abi3 macOS 10.12+ x86-64 Details

Total release size: 21.7 MB

Release files / pytest_mergify-2026.9.18.1.tar.gz

Download URL pytest_mergify-2026.9.18.1.tar.gz
Size 160.5 kB
Tags Source
SHA-256 checksum
How to use checksums
cbfe4098ccfaf7d9c07d60018e7b86f3e7f56eb2ad9cb9e3d26a1245121c15cf
BLAKE2b-256 checksum
How to use checksums
137fb0dbeebfa37cbad1fadb65b6088d42fc651cf5d54a4e3c90051bfd6ee2be
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 18, 2026.

Transparency log

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

Download URL pytest_mergify-2026.9.18.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
d7004bdca2ae67c7ea16d2a509cbcb459cddf0cc71bc6019dc6a4b50a48804af
BLAKE2b-256 checksum
How to use checksums
fda4a58a95612ec5dc77280f529a972af02f4a1deaa00769edcefac6f408c86c
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 18, 2026.

Transparency log

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

Download URL pytest_mergify-2026.9.18.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
96b3d4d22477b11413420f5252edf3bbcb87dc33aca672d46392c09b660faed1
BLAKE2b-256 checksum
How to use checksums
cca55ea6282a57ea5558ca6848d7b9288ef05ef237dde217b6099fea44227efa
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 18, 2026.

Transparency log

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

Download URL pytest_mergify-2026.9.18.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
b860e2a77a8f27b427d21cc790032e05073d2caeda2ef24cc185bd071ecddfdc
BLAKE2b-256 checksum
How to use checksums
81081e04c5f432f5eb61ab916877ef3c35a62e1eba34fca2a8074a2653928252
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 18, 2026.

Transparency log

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

Download URL pytest_mergify-2026.9.18.1-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 3.2 MB
Tags CPython 3.8 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
def413e27375dc2aece7de0f2bf73b0439262f583454a19eabef8f4f2df23183
BLAKE2b-256 checksum
How to use checksums
33e62dda264f9934ae8f94c88a4b1ab7bb4be4e96512a5738bd3685e04edbb65
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 18, 2026.

Transparency log

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

Download URL pytest_mergify-2026.9.18.1-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 3.0 MB
Tags CPython 3.8 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
c04008cd7e3a534062d0e80548e6a2d1473e7663cc2f0b622db248c645818818
BLAKE2b-256 checksum
How to use checksums
8fdae62a054bb5992c658e7242cdef1dd11b77d961e6cdad2f906b00199f2ed1
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 18, 2026.

Transparency log

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

Download URL pytest_mergify-2026.9.18.1-cp38-abi3-macosx_11_0_arm64.whl
Size 2.9 MB
Tags CPython 3.8 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
f932abfedc29576aea207d623f4cd9f71973d8031fa3e5f25da2362b65943313
BLAKE2b-256 checksum
How to use checksums
6cce36e70cd274f57d9055824b042e1a774eef898e88601c6b243241a0138c66
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 18, 2026.

Transparency log

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

Download URL pytest_mergify-2026.9.18.1-cp38-abi3-macosx_10_12_x86_64.whl
Size 3.1 MB
Tags CPython 3.8 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
11a8328dfe694073bd25696db01c1d39108328070a48babc672d3ea4e90a9f1c
BLAKE2b-256 checksum
How to use checksums
a0b000bb85f8efb375f76e14a50722957eef1f88a22bc44c62ad95784a14b865
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 18, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

2026.9.18.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