pytest-dev/pytest-github-actions-annotate-failures

Help getting it working with a docker flask app

DarrahK opened this issue · 2 comments

Hi,

I love the project that you have been working on!

I was just wondering if anyone could help me. I am trying to get this to work with a docker flask app and I am trying to capture the failed pytest tests inside of Github actions, but I can not seem to get it working.

If anyone could help me, it would be much appreciate!

Thanks,
Darrah

In my machine, the testing command outputs an annotation (the line starting with ::error) to stderr properly.

% docker compose version
Docker Compose version v2.2.3

% docker compose run --rm -e GITHUB_ACTIONS=true app python -m pytest
====================================================== test session starts ======================================================
platform linux -- Python 3.7.12, pytest-7.0.1, pluggy-1.0.0
rootdir: /python-flask
plugins: github-actions-annotate-failures-0.1.6
collected 1 item                                                                                                                

test_function.py 
::error file=test_function.py,line=4::test_function%0A%0Aassert 5 == 2%0A +  where 5 = function(3)
F                                                                                                        [100%]

=========================================================== FAILURES ============================================================
_________________________________________________________ test_function _________________________________________________________

    def test_function():
>       assert function(3) == 2
E       assert 5 == 2
E        +  where 5 = function(3)

test_function.py:4: AssertionError
==================================================== short test summary info ====================================================
FAILED test_function.py::test_function - assert 5 == 2
======================================================= 1 failed in 0.05s =======================================================

But the command in your workflow log outputs nothing. I think that docker compose command suppresses outputs for stderr (but I have no idea for now why this occurs only in GitHub Actions).

How about using docker-compose command instead of docker compose ?

Hi @utgwkk!

Thank you for getting back to me so quickly. I changed docker compose to docker-compose as you said and It work!! https://github.com/DarrahK/python-flask/actions/runs/1973769226

Thank you ever so much 😄