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_DISABLE Opt out of 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.

Nothing to configure: the plugin uses the token and job identity it already has, and Mergify decides. Any other situation — a normal run, a rerun Mergify has no previous results for, an unreachable API — runs the full suite, so the feature can only remove work, never coverage. The feature is also enabled per organization on Mergify's side, so it stays inactive until your organization is opted in.

Set MERGIFY_TEST_SELECTION_DISABLE=true in your CI to opt out: the plugin then always runs the full suite and never queries the endpoint. It is scoped to this feature only — test tracing, flaky detection and quarantine keep working (unset MERGIFY_TOKEN to turn the plugin off entirely).

Development

Prerequisites

  • Python >= 3.8
  • uv

Setup

uv sync

Running Tests

uv run poe test

Linting

uv run poe linters

License

GPL-3.0-only

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytest_mergify-2026.8.3.1.tar.gz (103.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pytest_mergify-2026.8.3.1-py3-none-any.whl (44.0 kB view details)

Uploaded Python 3

File details

Details for the file pytest_mergify-2026.8.3.1.tar.gz.

File metadata

  • Download URL: pytest_mergify-2026.8.3.1.tar.gz
  • Upload date:
  • Size: 103.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for pytest_mergify-2026.8.3.1.tar.gz
Algorithm Hash digest
SHA256 728d91b06e324be85c3d5933fd6dec05d7a4e10b8ccb33328cf7410112823a55
MD5 fc6b5574eea861bb9a5f9c9593a6b146
BLAKE2b-256 177425385493b85279876439a3ca594ffc33ec51ff9aac891238572affb8f543

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytest_mergify-2026.8.3.1.tar.gz:

Publisher: release-pytest-mergify.yml on Mergifyio/mergify-ci-integrations

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pytest_mergify-2026.8.3.1-py3-none-any.whl.

File metadata

File hashes

Hashes for pytest_mergify-2026.8.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 93f5ed5d32f0532631ca3c2916c3324d41f5f650d63b9230cac0cffc62458eaf
MD5 8a978dd76cf639b4cddaed12ff2afdca
BLAKE2b-256 c319c9bc9337b61c64fc85677fd88f76fbc250cd6241fe6aec40568deedb05ad

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytest_mergify-2026.8.3.1-py3-none-any.whl:

Publisher: release-pytest-mergify.yml on Mergifyio/mergify-ci-integrations

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page