pytest Integration with CI Insights
Report your test results from pytest to CI Insights
This guide explains how to integrate Pytest with CI Insights using the
pytest-mergify
plugin. Once installed, test results are automatically
uploaded to CI Insights without any extra workflow changes.
1. Installation
Section titled 1. InstallationYou need to install the
pytest-mergify
plugin to
automatically upload your
test results to CI Insights. This can be done in different way depending on
your way of managing your Python dependencies. Below are a few examples:
Pip / Requirements File
Section titled Pip / Requirements Filepip install pytest-mergify
Or add pytest-mergify
to your requirements.txt
.
setup.py
Section titled setup.pysetup(
name="your-package",
...
install_requires=[
...
],
extras_require={
"dev": ["pytest-mergify"]
},
...
)
Make sure those dependencies are installed when running your tests.
setup.cfg
Section titled setup.cfg[options.extras_require]
dev =
pytest-mergify
Make sure those dependencies are installed when running your tests.
Poetry
Section titled Poetrypoetry add --group dev pytest-mergify
2. Modify Your Workflow
Section titled 2. Modify Your WorkflowYour workflow should run your test as usual while exporting the secret
MERGIFY_TOKEN
as an environment variable. You’ll need to add the following
code to the GitHub Actions step running your tests:
env:
MERGIFY_TOKEN: ${{ secrets.MERGIFY_TOKEN }}
For example:
- name: Run Tests 🧪
env:
MERGIFY_TOKEN: ${{ secrets.MERGIFY_TOKEN }}
run: pytest
The plugin collects your test results and sends them to CI Insights. Check the CI Insights dashboard afterward to view execution metrics, detect flaky tests, and gather actionable feedback.