Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions .github/workflows/build_and_health_check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,35 @@ jobs:
with:
java-version: '21'
distribution: 'temurin'
cache: gradle

- name: setup gradle
uses: gradle/actions/setup-gradle@v5

- name: configure 1password
id: op-config
uses: 1password/load-secrets-action/configure@v2
continue-on-error: true
with:
service-account-token: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}

- name: load secrets
id: op-load
uses: 1password/load-secrets-action@v2
continue-on-error: true
if: steps.op-config.outcome == 'success'
with:
export-env: true
unset-previous: false
env:
ENV_FILE: op://instance/.env/.env

- name: create env file
run: echo "${{ env.ENV_FILE }}" > .env
run: |
if [ -n "${{ env.ENV_FILE }}" ]; then
echo "${{ env.ENV_FILE }}" > .env
else
echo "# Empty .env file for tests" > .env
fi

- name: run tests
run: ./gradlew test
Expand All @@ -66,7 +78,9 @@ jobs:
with:
java-version: '21'
distribution: 'temurin'
cache: gradle

- name: setup gradle
uses: gradle/actions/setup-gradle@v5

- name: configure 1password
uses: 1password/load-secrets-action/configure@v2
Expand Down
96 changes: 96 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
name: Code Coverage

on:
pull_request:
branches:
- '**'
push:
branches:
- main

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
coverage:
runs-on: ubuntu-latest
steps:
- name: checkout code
uses: actions/checkout@v4

- name: setup java 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'

- name: setup gradle
uses: gradle/actions/setup-gradle@v5

- name: configure 1password
id: op-config
uses: 1password/load-secrets-action/configure@v2
continue-on-error: true
with:
service-account-token: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}

- name: load secrets
id: op-load
uses: 1password/load-secrets-action@v2
continue-on-error: true
if: steps.op-config.outcome == 'success'
with:
export-env: true
unset-previous: false
env:
ENV_FILE: op://instance/.env/.env

- name: create env file
run: |
if [ -n "${{ env.ENV_FILE }}" ]; then
echo "${{ env.ENV_FILE }}" > .env
else
echo "# Empty .env file for tests" > .env
fi

- name: run tests with coverage
run: ./gradlew test jacocoRootReport checkOverallCoverageTarget

- name: upload coverage report
uses: actions/upload-artifact@v4
if: always()
with:
name: coverage-report
path: |
**/build/reports/jacoco/
build/reports/jacoco/jacocoRootReport/

- name: add coverage pr comment
uses: madrapps/jacoco-report@v1.6.1
if: github.event_name == 'pull_request'
with:
paths: |
${{ github.workspace }}/build/reports/jacoco/jacocoRootReport/jacocoRootReport.xml
token: ${{ secrets.GITHUB_TOKEN }}
min-coverage-overall: 75
min-coverage-changed-files: 70
title: 'Code Coverage Report'
update-comment: true

- name: generate coverage badge
uses: cicirello/jacoco-badge-generator@v2
if: github.ref == 'refs/heads/main'
with:
jacoco-csv-file: build/reports/jacoco/jacocoRootReport/jacocoRootReport.csv
badges-directory: .github/badges
generate-branches-badge: true
generate-summary: true

- name: commit and push badge
if: github.ref == 'refs/heads/main'
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add .github/badges
git diff --quiet && git diff --staged --quiet || (git commit -m "docs: update coverage badge [skip ci]" && git push)
28 changes: 28 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,34 @@ docker-compose up -d
./gradlew test --tests "*.NormalProfanityFilterTest"
```

### 코드 커버리지
```bash
# 전체 프로젝트 커버리지 리포트 생성 (모듈별 + 통합)
./gradlew test jacocoRootReport checkOverallCoverageTarget

# 특정 모듈 커버리지 리포트 생성
./gradlew :profanity-api:jacocoTestReport
./gradlew :profanity-domain:jacocoTestReport

# 모듈별 커버리지 목표치 확인
./gradlew :profanity-api:checkCoverageTargets
./gradlew :profanity-domain:checkCoverageTargets

# 커버리지 리포트 위치
# - 통합 리포트: build/reports/jacoco/jacocoRootReport/html/index.html
# - 모듈별 리포트: {module}/build/reports/jacoco/test/html/index.html
```

#### 커버리지 목표치
- **profanity-api**: 70% (Line), 65% (Branch), 70% (Instruction)
- **profanity-domain**: 80% (Line), 75% (Branch), 80% (Instruction)
- **profanity-shared**: 60% (Line), 55% (Branch), 60% (Instruction)
- **profanity-storage:rdb**: 70% (Line), 65% (Branch), 70% (Instruction)
- **profanity-storage:redis**: 70% (Line), 65% (Branch), 70% (Instruction)
- **전체 프로젝트**: 75% (Line), 70% (Branch), 75% (Instruction)

*참고: 목표치는 현재 빌드 실패를 유발하지 않으며, 달성 여부만 체크합니다.*

### 의존성 관리
```bash
# 의존성 확인
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

# 한국어 비속어 필터 API 서비스

[![Coverage](.github/badges/jacoco.svg)](https://github.com/Whale0928/profanity-filter-api/actions/workflows/coverage.yml)
[![Branches](.github/badges/branches.svg)](https://github.com/Whale0928/profanity-filter-api/actions/workflows/coverage.yml)

> API 인증 키 발급 후 사용 가능합니다. 문서 링크를 참조해 주세요
>
> [API DOCS](https://whale0928.github.io/profanity-filter-api/)
Expand Down
Loading
Loading