Skip to content

Commit c7f8ddc

Browse files
authored
[#0] make fail when pytest fails
1 parent 3d4c8fb commit c7f8ddc

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

.github/workflows/pytest-with-coverage.yml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@ on:
55
pull_request:
66
branches: [ main ]
77

8-
# https://docs.github.com/en/actions/using-jobs/assigning-permissions-to-jobs
9-
# `contents` is for permission to the contents of the repository.
10-
# `pull-requests` is for permission to pull request
118
permissions:
129
contents: write
1310
checks: write
@@ -30,9 +27,10 @@ jobs:
3027
pip install flake8 pytest pytest-cov
3128
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
3229
33-
- name: Build coverage file
30+
- name: Run tests with coverage
3431
run: |
3532
pytest --junitxml=pytest.xml --cov-report=term-missing:skip-covered --cov=. tests/ | tee pytest-coverage.txt
33+
continue-on-error: false # 테스트가 실패하면 CI/CD 실패 처리
3634

3735
- name: Pytest coverage comment
3836
id: coverageComment
@@ -46,13 +44,16 @@ jobs:
4644
echo "Coverage Percentage - ${{ steps.coverageComment.outputs.coverage }}"
4745
echo "Coverage Color - ${{ steps.coverageComment.outputs.color }}"
4846
echo "Coverage Html - ${{ steps.coverageComment.outputs.coverageHtml }}"
49-
5047
echo "Coverage Warnings - ${{ steps.coverageComment.outputs.warnings }}"
51-
5248
echo "Coverage Errors - ${{ steps.coverageComment.outputs.errors }}"
5349
echo "Coverage Failures - ${{ steps.coverageComment.outputs.failures }}"
5450
echo "Coverage Skipped - ${{ steps.coverageComment.outputs.skipped }}"
5551
echo "Coverage Tests - ${{ steps.coverageComment.outputs.tests }}"
5652
echo "Coverage Time - ${{ steps.coverageComment.outputs.time }}"
57-
5853
echo "Not Success Test Info - ${{ steps.coverageComment.outputs.notSuccessTestInfo }}"
54+
55+
- name: Fail if tests failed
56+
if: steps.coverageComment.outputs.failures != '0' || steps.coverageComment.outputs.errors != '0'
57+
run: |
58+
echo "❌ Tests failed. Check the test report."
59+
exit 1

0 commit comments

Comments
 (0)