Skip to content

Commit

Permalink
[CHORE] CI 스크립트 작성 (#21)
Browse files Browse the repository at this point in the history
* chore: jacoco 의존성 추가

* chore: CI 스크립트 작성

* chore: 스크립트 수정

* chore: test report 경로 수정

* chore: write 권한 부여

* chore: gradle 캐싱 로직 추가

* chore: 스크립트 이름 변경

Backend_Dev_CI.yml > Dev_CI.yml

* chore: dto와 lombok 코드를 테스트 대상에서 제외

* chore: local 환경에서는 Test_Report가 작동하지 않도록 수정

* chore: test report에 if always 추가

* chore: 권한 변경

* chore: 권한에 PR 추가

* chore: 타임아웃 3분으로 변경

* chore: 이벤트 트리거 원상 복구

---------

Co-authored-by: coli-geonwoo <[email protected]>
  • Loading branch information
coli-geonwoo and coli-geonwoo authored Dec 15, 2024
1 parent 8d203f6 commit edd7dfb
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 0 deletions.
61 changes: 61 additions & 0 deletions .github/workflows/Dev_CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: dev-ci

on:
pull_request:
branches:
- develop

permissions:
contents: read
checks: write
pull-requests: write

jobs:
build-and-push:
runs-on: ubuntu-latest
timeout-minutes: 3
env:
TEST_REPORT: true

steps:
- uses: actions/checkout@v4

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4

- name: Grant Permission
run: chmod +x ./gradlew

- name: Clean And Test With Gradle
run: ./gradlew clean test

- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action@v2
if: always()
with:
files: ${{ github.workspace }}/build/test-results/**/*.xml

- name: JUnit Report Action
uses: mikepenz/action-junit-report@v4
if: always()
with:
report_paths: ${{ github.workspace }}/build/test-results/**/*.xml

- name: Report test Coverage to PR
id: jacoco
uses: madrapps/[email protected]
if: always()
with:
title: 📝 Test Coverage Report
paths: ${{ github.workspace }}/build/reports/jacoco/test/jacocoTestReport.xml
token: ${{ secrets.GITHUB_TOKEN }}
min-coverage-overall: 80
min-coverage-changed-files: 80
update-comment: true
debug-mode: true
27 changes: 27 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
plugins {
id 'java'
id 'jacoco'
id 'org.springframework.boot' version '3.4.0'
id 'io.spring.dependency-management' version '1.1.6'
}
Expand Down Expand Up @@ -39,6 +40,32 @@ dependencies {
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.6.0'
}

jacoco {
toolVersion = '0.8.9'
}

tasks.named('test') {
useJUnitPlatform()
finalizedBy jacocoTestReport
}

jacocoTestReport {
dependsOn test
reports {
xml.required.set(true)
csv.required.set(false)
html.required.set(false)
}

afterEvaluate {
classDirectories.setFrom(files(classDirectories.files.collect {
fileTree(dir: it, exclude: [
"com/debatetimer/**/dto/**"
])
}))
}

onlyIf {
return System.getenv('TEST_REPORT') == 'true'
}
}
1 change: 1 addition & 0 deletions src/lombok.config
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
lombok.addLombokGeneratedAnnotation = true

0 comments on commit edd7dfb

Please sign in to comment.