diff --git a/.github/scripts/generate-coverage-badge.sh b/.github/scripts/generate-coverage-badge.sh deleted file mode 100644 index 120dde48..00000000 --- a/.github/scripts/generate-coverage-badge.sh +++ /dev/null @@ -1,55 +0,0 @@ -#!/bin/bash - -set -e - -REPORT_FILE="build/reports/jacoco/test/jacocoTestReport.xml" -BADGE_FILE="badges/coverage.svg" - -mkdir -p badges - -if [ ! -f "$REPORT_FILE" ]; then - echo "❌ Report not found: $REPORT_FILE" - exit 1 -fi - -# awk로 missed, covered 값 추출 -read missed covered < <(awk -F'"' '/= 90" | bc -l) )); then - color="4c1" # brightgreen -elif (( $(echo "$percent >= 75" | bc -l) )); then - color="dfb317" # yellow -else - color="e05d44" # red -fi - -# SVG badge 생성 -cat > "$BADGE_FILE" < - - - - - - - - - - - - - - coverage - coverage - ${percent}% - ${percent}% - - -EOF - -echo "✅ Coverage badge generated: ${percent}% -> $BADGE_FILE" diff --git a/.github/workflows/pr-ci.yml b/.github/workflows/pr-ci.yml index 0d8b6c67..32420189 100644 --- a/.github/workflows/pr-ci.yml +++ b/.github/workflows/pr-ci.yml @@ -11,7 +11,7 @@ permissions: jobs: build-and-test: - name: Build, Test, and Coverage + name: Build, Test, and Upload Coverage runs-on: ubuntu-latest steps: @@ -42,17 +42,23 @@ jobs: name: coverage-report path: build/reports/jacoco/test/html/ + - name: Upload JaCoCo report to Codecov + uses: codecov/codecov-action@v4 + with: + token: ${{ secrets.CODECOV_TOKEN }} # public repo라면 생략 가능 + files: build/reports/jacoco/test/jacocoTestReport.xml + fail_ci_if_error: true + flags: unittests + verbose: true + - name: Extract JaCoCo Coverage Percentage id: coverage run: | xml_file="build/reports/jacoco/test/jacocoTestReport.xml" - missed=$(awk -F'"' '/> "$GITHUB_OUTPUT" - name: Comment PR with Test and Coverage Result @@ -65,23 +71,13 @@ jobs: **Build:** ${{ job.status }} 🧪 테스트 실행 with Gradle - 📈 **Coverage:** `${{ steps.jacoco.outputs.COVERAGE }}%` + 📈 **Coverage:** `${{ steps.coverage.outputs.COVERAGE }}%` - 📁 [Test Report](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}) - 📁 [Coverage Report (HTML)](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}) + 📁 [테스트 결과](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}) + 📁 [커버리지 보고서 (HTML)](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}) - name: Fail PR if tests fail if: failure() run: | echo "❌ Tests failed. Please fix them before merging." exit 1 - - name: Generate Coverage Badge - run: | - chmod +x .github/scripts/generate-coverage-badge.sh - .github/scripts/generate-coverage-badge.sh - - - name: Commit & Push Coverage Badge - uses: stefanzweifel/git-auto-commit-action@v5 - with: - commit_message: "chore: update coverage badge" - file_pattern: badges/coverage.svg diff --git a/README.md b/README.md index 38c69c77..3b6fe034 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # 🎮 마비노기 경매장 거래 내역 조회 및 통계 서비스 -![Coverage](https://github.com/devnogi/open-api-batch-server/dev/badges/coverage.svg) +[![codecov](https://codecov.io/gh/devnogi/open-api-batch-server/branch/dev/graph/badge.svg)](https://codecov.io/gh/devnogi/open-api-batch-server) [![License](https://img.shields.io/github/license/devnogi/open-api-batch-server)](LICENSE) [![Last Commit](https://img.shields.io/github/last-commit/devnogi/open-api-batch-server)](https://github.com/devnogi/open-api-batch-server)