MishaKav / pytest-coverage-comment

Comments a pull request with the pytest code coverage badge and full report
MIT License
181 stars 60 forks source link

Action didn't raise an error #69

Closed arkadybag closed 2 years ago

arkadybag commented 2 years ago

Hello. First of all thanks for your action!

I am trying to use it for my project and it looks good! But I have some issues with it. When tests are finished without errors everything is ok, but when I have errors in tests I expect to have an error in the pipeline, but unfortunately, the action didn't fail. I emulated error in tests and as you can see it was passed.

image

Status of my pipeline

image
arkadybag commented 2 years ago

Solved.

My solution is set set -o pipefail

      - name: Run pytest
        run: |
          set -o pipefail
          poetry run pytest --color=yes --junitxml=/tmp/pytest.xml --cov-report=term-missing:skip-covered --cov=api --cov=services --cov=schemas --cov=repositories --cov=models tests/ | tee /tmp/pytest-coverage.txt
arkadybag commented 2 years ago

Also alternative option:

      - name: Run pytest
        run: |
          poetry run pytest --color=yes --junitxml=/tmp/pytest.xml --cov-report=term-missing:skip-covered --cov=api --cov=services --cov=schemas --cov=repositories --cov=models tests/ 2>&1 | tee /tmp/pytest-coverage.txt; exit ${PIPESTATUS[0]}