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

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.2
File Size Uploaded
pytest_mergify-2026.9.11.2.tar.gz 134.6 kB Details

Built distributions (wheels)

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

Download URL pytest_mergify-2026.9.11.2.tar.gz
Size 134.6 kB
Tags Source
SHA-256 checksum
How to use checksums
fd41f0f670c8a256aa444a90eff57c4bfbc56443be8ed230a9158e1ed2941c8e
BLAKE2b-256 checksum
How to use checksums
d02f5ba426919578043cbe7c06b10b04c3bbcf907e36c44153599bab2b5f304d
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 15, 2026.

Transparency log

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

Download URL pytest_mergify-2026.9.11.2-cp38-abi3-win_amd64.whl
Size 2.9 MB
Tags CPython 3.8 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
da1c2c2d188f1212820da73dd9f16782075e64551c8305837760abe89584f757
BLAKE2b-256 checksum
How to use checksums
00b306fe257f87f1f11ea9371bc0fcc95901a510134c749651fcbf29163ed70b
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 15, 2026.

Transparency log

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

Download URL pytest_mergify-2026.9.11.2-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
7778a5315ea509de806a94951e79d49d68978147bec463445bb2ad6ccf154071
BLAKE2b-256 checksum
How to use checksums
94515033ea89f590a27047b05bc731e9fb01ea5180f6cc7b5d12676664084871
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 15, 2026.

Transparency log

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

Download URL pytest_mergify-2026.9.11.2-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
dc4908371e73bc20e0f4f892438bc424a64ce68d576061effbab4e3220254efa
BLAKE2b-256 checksum
How to use checksums
c4630959adcc4ec0e381e2581491cddec927f669f1760e609194eecbc4789c39
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 15, 2026.

Transparency log

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

Download URL pytest_mergify-2026.9.11.2-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
a1dbd0d183343888248710499cdcf1f00ae6c945bb2002b47f4b579ae7799268
BLAKE2b-256 checksum
How to use checksums
b0ee71dde3d2140792a3791ebbdcdf78c2d251bcfd05f3fa927d74bb59265754
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 15, 2026.

Transparency log

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

Download URL pytest_mergify-2026.9.11.2-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
dd1a0d54b7d46d28c53f2dcda305ea4a09fc458332a85d6e1b4f85df648ec14c
BLAKE2b-256 checksum
How to use checksums
24bd150ff3c4d20d146209cf197e403f33e8969411b7325cd35059fa2daa3a95
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 15, 2026.

Transparency log

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

Download URL pytest_mergify-2026.9.11.2-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
662d7a0cbe4065bb662380b70d09653cbf0b07f0a5e631ada5f3b0acdd17bd13
BLAKE2b-256 checksum
How to use checksums
133f815eaa3281cfa9ef6312ce99709be56395f39e76052b60d629521ae2d3e8
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 15, 2026.

Transparency log

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

Download URL pytest_mergify-2026.9.11.2-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
96d65cd8705f8c5c286432de9025cf4daf508cb8ff2551213fc51c17c0f25cff
BLAKE2b-256 checksum
How to use checksums
219678cf15d9721248958b4a1fdb7958a9830e12f4e89fa4a55ef0b4132b1313
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 15, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

2026.9.11.2 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