Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to configure? #80

Open
ilyakamens opened this issue Dec 19, 2023 · 4 comments
Open

How to configure? #80

ilyakamens opened this issue Dec 19, 2023 · 4 comments

Comments

@ilyakamens
Copy link

Hi! I'm having trouble getting this to work. I've installed the plugin via our requirements.txt file. We use docker, and so I set the env var as mentioned. I see the following in the test output:

::error file=foo/tests/unit/test_bar.py,line=13::TestBar.test_fail%0A%0Aassert False

That path looks correct to me. foo is a top-level directory in our repository. Is there something else I need to do to get this to work? We use a Jenkins pipeline + shell command to run tests. Thanks!

@edgarrmondragon edgarrmondragon added question Further information is requested and removed question Further information is requested labels Jan 17, 2025
@daveisfera
Copy link

I'm having the same issue. I'm running inside of a container, I've set GITHUB_ACTIONS=true and verified that it's set when running the test, but the output is identical.

@edgarrmondragon
Copy link
Collaborator

edgarrmondragon commented Jan 23, 2025

inside of a container

@daveisfera or @ilyakamens Can you share an example of how you're doing that in GitHub Actions or set up a MRE repo?

(My suspicion is that the container's output is being redirected to stdout and GitHub doesn't detect it there?)

@daveisfera
Copy link

I mean something even simpler than that. The actual output isn't changed at all when this is installed and that's with both GITHUB_ACTIONS=true set and not. I assume that this is supposed to change the output so that GitHub Actions parses it to tie it to the code or is that not correct?

@edgarrmondragon
Copy link
Collaborator

The actual output isn't changed at all when this is installed and that's with both GITHUB_ACTIONS=true set and not. I assume that this is supposed to change the output so that GitHub Actions parses it to tie it to the code or is that not correct?

Yeah, consider this working example:

FROM python:3.13-slim

RUN pip install pytest pytest-github-actions-annotate-failures

RUN echo "def test_fail():\n    assert False" > test_fail.py

ENV GITHUB_ACTIONS=true
CMD ["pytest", "test_fail.py"]

Then

  1. build the image

    docker build -t pytest-gh 
  2. run it

    $ docker run --rm pytest-gh            
    ============================= test session starts ==============================
    platform linux -- Python 3.13.1, pytest-8.3.4, pluggy-1.5.0
    rootdir: /
    plugins: github-actions-annotate-failures-0.3.0
    collected 1 item
    
    test_fail.py F::error file=test_fail.py,line=2::test_fail%0A%0Aassert False
                                                            [100%]
    
    =================================== FAILURES ===================================
    __________________________________ test_fail ___________________________________
    
       def test_fail():
    >       assert False
    E       assert False
    
    test_fail.py:2: AssertionError
    =========================== short test summary info ============================
    FAILED test_fail.py::test_fail - assert False
    ============================== 1 failed in 0.02s ===============================

    so you can see the output is there and in the right format

  3. confirm it's sent to stderr

    $ docker run --rm pytest-gh > /dev/null
    ::error file=test_fail.py,line=2::test_fail%0A%0Aassert False

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants