Skip to content

Commit d3f8f82

Browse files
committed
feat(tests): improve coverage parsing in GitHub Actions workflow to output percentage correctly
1 parent 79e1e05 commit d3f8f82

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

.github/workflows/pr-test.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,14 @@ jobs:
7070
- name: Parse Coverage for Comment
7171
id: coverage-comment
7272
run: |
73-
poetry run python -c "
73+
percentage=$(poetry run python -c "
7474
import xml.etree.ElementTree as ET
7575
tree = ET.parse('coverage.xml')
7676
root = tree.getroot()
7777
line_rate = float(root.attrib['line-rate'])
78-
percentage = line_rate * 100
79-
print(f'COVERAGE_PERCENT={percentage:.2f}') # GitHub Actions에서 사용할 환경 변수 출력"
80-
shell: bash
78+
print(f'{line_rate * 100:.2f}')
79+
")
80+
echo "COVERAGE_PERCENT=$percentage" >> "$GITHUB_OUTPUT"
8181
8282
- name: Add Coverage Comment to PR
8383
uses: peter-evans/create-or-update-comment@v4
@@ -89,4 +89,3 @@ jobs:
8989
|--------|-----|
9090
| 📊 Line Coverage | ${{ steps.coverage-comment.outputs.COVERAGE_PERCENT }}% |
9191
token: ${{ secrets.PAT_TOKEN }}
92-
if: github.event_name == 'pull_request'

0 commit comments

Comments
 (0)