|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: [ develop, main ] |
| 6 | + |
| 7 | +permissions: |
| 8 | + contents: read |
| 9 | + pull-requests: write # JaCoCo 커버리지 코멘트용 |
| 10 | + |
| 11 | +jobs: |
| 12 | + build: |
| 13 | + runs-on: ubuntu-latest |
| 14 | + |
| 15 | + steps: |
| 16 | + - name: Checkout |
| 17 | + uses: actions/checkout@v4 |
| 18 | + with: |
| 19 | + submodules: recursive |
| 20 | + token: ${{ secrets.SUBMODULE_TOKEN != '' && secrets.SUBMODULE_TOKEN || github.token }} |
| 21 | + |
| 22 | + - name: Set up JDK 25 |
| 23 | + uses: actions/setup-java@v4 |
| 24 | + with: |
| 25 | + java-version: '25' |
| 26 | + distribution: 'temurin' |
| 27 | + |
| 28 | + # ── Gradle Setup (Build Cache 포함) ── |
| 29 | + - name: Setup Gradle |
| 30 | + uses: gradle/actions/setup-gradle@v4 |
| 31 | + with: |
| 32 | + cache-read-only: ${{ github.event_name == 'pull_request' && github.base_ref != 'main' || github.ref != 'refs/heads/main' }} |
| 33 | + |
| 34 | + # ── Lint ── |
| 35 | + - name: Run ktlint |
| 36 | + run: ./gradlew ktlintCheck |
| 37 | + |
| 38 | + # ── Detekt (정적 분석) ── |
| 39 | + - name: Run Detekt |
| 40 | + run: ./gradlew detekt |
| 41 | + |
| 42 | + # ── Build & Test + JaCoCo 리포트 생성 ── |
| 43 | + - name: Build and Test |
| 44 | + run: ./gradlew build jacocoTestReport |
| 45 | + |
| 46 | + # ── JaCoCo 커버리지 PR 코멘트 ── |
| 47 | + - name: JaCoCo Coverage Report |
| 48 | + if: github.event_name == 'pull_request' |
| 49 | + uses: madrapps/jacoco-report@v1.7.1 |
| 50 | + with: |
| 51 | + paths: '**/build/reports/jacoco/test/jacocoTestReport.xml' |
| 52 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 53 | + min-coverage-overall: 50 |
| 54 | + min-coverage-changed-files: 70 |
| 55 | + title: '📊 테스트 커버리지 리포트' |
| 56 | + update-comment: true |
| 57 | + |
| 58 | + # ── Docker 이미지 빌드 검증 ── |
| 59 | + - name: Docker Build (verification only) |
| 60 | + if: hashFiles('Dockerfile') != '' |
| 61 | + run: | |
| 62 | + docker build -t ${{ github.repository }}:pr-${{ github.event.pull_request.number }} . |
0 commit comments