From 0e271a3cb0ff279efdaf177854fa971cb93a4772 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EB=8F=99=ED=9B=88?= <2dh2@naver.com> Date: Sun, 12 Apr 2026 17:45:38 +0900 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20?= =?UTF-8?q?=EB=AF=B8=EC=8B=A4=ED=96=89=20=EC=8B=9C=20JaCoCo=20=EC=98=A4?= =?UTF-8?q?=EB=A5=98=20=EB=A9=94=EC=8B=9C=EC=A7=80=20=EB=B0=8F=20=EA=B0=80?= =?UTF-8?q?=EB=93=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - no-report 상태 처리 및 관련 PR 댓글 내용 추가 - always 조건으로 오류 발생 시에도 후속 스텝 실행 보장 --- .github/workflows/pr-coverage.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pr-coverage.yml b/.github/workflows/pr-coverage.yml index 8d70c1219..8ed73ce08 100644 --- a/.github/workflows/pr-coverage.yml +++ b/.github/workflows/pr-coverage.yml @@ -67,6 +67,7 @@ jobs: - name: Parse coverage for changed files id: parse-coverage + if: always() run: | python3 << 'PYEOF' import os @@ -91,7 +92,8 @@ jobs: raise SystemExit(0) if not os.path.exists(report_path): - raise SystemExit(f"Error: Report not found at {report_path}") + write_outputs('N/A', 0, 0, 'no-report', 'JaCoCo 리포트 파일이 생성되지 않았습니다. 테스트 실행을 확인해주세요.') + raise SystemExit(1) tree = ET.parse(report_path) root = tree.getroot() @@ -167,6 +169,7 @@ jobs: echo "✅ 커버리지 ${OVERALL_COVERAGE}% 가 임계값을 충족합니다." - name: Comment PR with coverage results + if: always() uses: actions/github-script@v7 env: OVERALL_COVERAGE: ${{ steps.parse-coverage.outputs.overall_coverage }} @@ -190,6 +193,10 @@ jobs: body += '> 이 PR에서 변경된 main Java 소스 파일이 없습니다.\n'; } else if (bodyType === 'no-coverage-data') { body += '> 변경된 main Java 소스 파일에 대한 JaCoCo 데이터가 없습니다.\n'; + } else if (bodyType === 'no-report') { + body += '> JaCoCo 리포트 파일이 생성되지 않았습니다. 테스트 실행을 확인해주세요.\n'; + } else if (!bodyType) { + body += '> 이전 스텝에서 오류가 발생해 커버리지를 계산하지 못했습니다.\n'; } else { const ratio = parseFloat(coverage); const status = ratio >= 70 ? '✅' : (ratio >= 50 ? '⚠️' : '❌'); From cae8e9e66f42b9fa1534258526b42a5569745fd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EB=8F=99=ED=9B=88?= <2dh2@naver.com> Date: Sun, 12 Apr 2026 18:25:51 +0900 Subject: [PATCH 2/2] =?UTF-8?q?fix:=20PR=20=EC=BB=A4=EB=B2=84=EB=A6=AC?= =?UTF-8?q?=EC=A7=80=20=EC=9B=8C=ED=81=AC=ED=94=8C=EB=A1=9C=EC=9A=B0=20?= =?UTF-8?q?=EC=BD=94=EB=A9=98=ED=8A=B8=20=EA=B0=B1=EC=8B=A0=20=EB=B0=8F=20?= =?UTF-8?q?=EC=98=A4=EB=A5=98=20=EC=A7=84=EB=8B=A8=20=EA=B0=9C=EC=84=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 선행 스텝(tests, changed-files) outcome을 파서에 전달하여 실제 원인(테스트 실패 vs 리포트 누락 vs 변경파일 없음)을 구분 - parse-coverage, comment 스텝에 if: always() 추가로 이전 스텝 실패 시에도 코멘트가 항상 갱신되도록 수정 - workflow-error 분기 추가로 선행 스텝 실패 메시지 명확화 - Actions 실행 링크를 분기 밖으로 이동하여 모든 결과에 포함 --- .github/workflows/pr-coverage.yml | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pr-coverage.yml b/.github/workflows/pr-coverage.yml index 8ed73ce08..d0b10db1d 100644 --- a/.github/workflows/pr-coverage.yml +++ b/.github/workflows/pr-coverage.yml @@ -62,12 +62,16 @@ jobs: echo "Changed file count: $FILE_COUNT" - name: Run tests with JaCoCo + id: run-tests run: | ./gradlew test jacocoTestReport --no-daemon --build-cache - name: Parse coverage for changed files id: parse-coverage if: always() + env: + CHANGED_FILES_OUTCOME: ${{ steps.changed-files.outcome }} + RUN_TESTS_OUTCOME: ${{ steps.run-tests.outcome }} run: | python3 << 'PYEOF' import os @@ -87,6 +91,17 @@ jobs: report_path = 'build/reports/jacoco/test/jacocoTestReport.xml' changed_raw = os.getenv('CHANGED_FILES', '').strip() + # 선행 스텝 실패 여부를 먼저 확인하여 실제 원인을 명확히 전달 + changed_files_outcome = os.getenv('CHANGED_FILES_OUTCOME', '') + run_tests_outcome = os.getenv('RUN_TESTS_OUTCOME', '') + + if changed_files_outcome != 'success': + write_outputs('N/A', 0, 0, 'workflow-error', '변경 파일 목록을 계산하지 못했습니다.') + raise SystemExit(1) + if run_tests_outcome != 'success': + write_outputs('N/A', 0, 0, 'workflow-error', '테스트 실행에 실패했습니다.') + raise SystemExit(1) + if not changed_raw: write_outputs('N/A', 0, 0, 'no-main-changes', '변경된 main Java 소스 파일이 없어 커버리지를 계산하지 않았습니다.') raise SystemExit(0) @@ -193,6 +208,8 @@ jobs: body += '> 이 PR에서 변경된 main Java 소스 파일이 없습니다.\n'; } else if (bodyType === 'no-coverage-data') { body += '> 변경된 main Java 소스 파일에 대한 JaCoCo 데이터가 없습니다.\n'; + } else if (bodyType === 'workflow-error') { + body += '> 워크플로우 실행 중 오류가 발생했습니다. 로그를 확인해주세요.\n'; } else if (bodyType === 'no-report') { body += '> JaCoCo 리포트 파일이 생성되지 않았습니다. 테스트 실행을 확인해주세요.\n'; } else if (!bodyType) { @@ -213,10 +230,10 @@ jobs: } else if (ratio < 70) { body += '> ⚠️ **알림:** 커버리지가 70% 미만입니다. 테스트 추가를 권장합니다.\n'; } - - body += `\n[📊 View Full Report](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})\n`; } + body += `\n[📊 View Workflow Run](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})\n`; + const comments = await github.paginate( github.rest.issues.listComments, {