Skip to content

fix: Avoid emitthing duplicate GitHub Actions error annotations when running with pytest-xdist - #140

Merged
edgarrmondragon merged 2 commits into
pytest-dev:mainfrom
atsuoishimoto:duplicate-annotations
Jun 17, 2026
Merged

edgarrmondragon merged 2 commits into
pytest-dev:mainfrom
atsuoishimoto:duplicate-annotations

Conversation

@atsuoishimoto

Copy link
Copy Markdown
Contributor

With pytest-github-actions-annotate-failures==0.4.0, failed tests can emit duplicate ::error workflow commands under xdist. With 0.3.0, the annotation is emitted once.

Reproduction

# sample.py
def test():
    assert 0
GITHUB_ACTIONS=true uvx \
--with pytest-github-actions-annotate-failures==0.4.0 \
--with pytest-xdist \
pytest sample.py -n 2

Output:

❯ GITHUB_ACTIONS=true uvx --with pytest-github-actions-annotate-failures==0.4.0 --with pytest-xdist pytest sample.py -n 2
================================================ test session starts =================================================
platform linux -- Python 3.14.2, pytest-9.1.0, pluggy-1.6.0
rootdir: /home/ishimoto/src/pytest-github-actions-annotate-failures
configfile: pyproject.toml
plugins: xdist-3.8.0, github-actions-annotate-failures-0.4.0
2 workers [1 item]
::error file=sample.py,line=5::test%0A%0Aassert 0
::error file=sample.py,line=5::test%0A%0Aassert 0
F                                                                                                              [100%]
====================================================== FAILURES ======================================================
________________________________________________________ test ________________________________________________________
[gw0] linux -- Python 3.14.2 /home/ishimoto/.cache/uv/archive-v0/8-EX62Pw4kymunE2/bin/python

    def test():
>       assert 0
E       assert 0

sample.py:5: AssertionError
============================================== short test summary info ===============================================
FAILED sample.py::test - assert 0
================================================= 1 failed in 0.16s ==================================================

Fix

  • Register annotation hooks only on the controller process when xdist is active. Workers skip registration because the controller re-emits their reports.
  • I had to fix tox.ini: it used groups = test, but tox has no such key. PEP 735 dependency groups are exposed as
    dependency_groups, so the test deps were never installed.

@atsuoishimoto
atsuoishimoto marked this pull request as ready for review June 17, 2026 05:03
@edgarrmondragon edgarrmondragon changed the title Fix duplicate GitHub Actions error annotations when running with pytest-xdist fix: Avoid emitthing duplicate GitHub Actions error annotations when running with pytest-xdist Jun 17, 2026
@edgarrmondragon edgarrmondragon self-assigned this Jun 17, 2026
@edgarrmondragon
edgarrmondragon self-requested a review June 17, 2026 15:21
@edgarrmondragon

Copy link
Copy Markdown
Collaborator

Thanks @atsuoishimoto !

@edgarrmondragon
edgarrmondragon merged commit 70d0656 into pytest-dev:main Jun 17, 2026
15 of 17 checks passed
@edgarrmondragon

Copy link
Copy Markdown
Collaborator

Shipped with https://pypi.org/project/pytest-github-actions-annotate-failures/0.4.1/

@atsuoishimoto

Copy link
Copy Markdown
Contributor Author

Thanks for the quick release!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants