From abb8c7a74dabd7dbdeca2d689571ae02d64138ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=ED=99=8D=EC=B0=AC=ED=9D=AC?= Date: Sat, 20 Jan 2024 21:49:10 +0900 Subject: [PATCH 1/6] =?UTF-8?q?chore:=20jacoco=20=EC=9D=98=EC=A1=B4?= =?UTF-8?q?=EC=84=B1=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/build.gradle | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/backend/build.gradle b/backend/build.gradle index f7e6c02e1..3072e01c9 100644 --- a/backend/build.gradle +++ b/backend/build.gradle @@ -2,6 +2,7 @@ plugins { id 'java' id 'org.springframework.boot' version '3.2.1' id 'io.spring.dependency-management' version '1.1.4' + id 'jacoco' } group = 'com.example' @@ -67,3 +68,16 @@ dependencies { tasks.named('test') { useJUnitPlatform() } + +jacoco { + toolVersion = "0.8.11" // 버전 명시 +} + +jacocoTestReport { + dependsOn test + reports { + xml.required.set(false) + csv.required.set(false) + html.required.set(true) + } +} From 64d730d85fc5b1ac0ca6387a5560b2ff8c6c8646 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=ED=99=8D=EC=B0=AC=ED=9D=AC?= Date: Sat, 20 Jan 2024 21:57:07 +0900 Subject: [PATCH 2/6] =?UTF-8?q?chore:=20test=20=EC=9D=B4=ED=9B=84=20jacoco?= =?UTF-8?q?TestReport=EA=B0=80=20=EC=88=98=ED=96=89=EB=90=98=EA=B2=8C=20?= =?UTF-8?q?=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/build.gradle | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/backend/build.gradle b/backend/build.gradle index 3072e01c9..d7ced5b3e 100644 --- a/backend/build.gradle +++ b/backend/build.gradle @@ -69,6 +69,10 @@ tasks.named('test') { useJUnitPlatform() } +test { + finalizedBy jacocoTestReport +} + jacoco { toolVersion = "0.8.11" // 버전 명시 } @@ -76,7 +80,7 @@ jacoco { jacocoTestReport { dependsOn test reports { - xml.required.set(false) + xml.required.set(true) csv.required.set(false) html.required.set(true) } From 6a5dad618f9605b46092efb1f5d83d649ef817f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=ED=99=8D=EC=B0=AC=ED=9D=AC?= Date: Sat, 20 Jan 2024 21:59:16 +0900 Subject: [PATCH 3/6] =?UTF-8?q?chore:=20=ED=8C=8C=EC=9D=B4=ED=94=84?= =?UTF-8?q?=EB=9D=BC=EC=9D=B8=20=EC=BB=A4=EB=B2=84=EB=A6=AC=EC=A7=80=20?= =?UTF-8?q?=EC=8A=A4=ED=85=9D=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/CI_dev_be_pull_request.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.github/workflows/CI_dev_be_pull_request.yml b/.github/workflows/CI_dev_be_pull_request.yml index 1fbfd603d..c56e116f4 100644 --- a/.github/workflows/CI_dev_be_pull_request.yml +++ b/.github/workflows/CI_dev_be_pull_request.yml @@ -49,3 +49,16 @@ jobs: - name: yaml 파일 변경 run: | echo "${{ secrets.APPLICATION_DEFAULT_DEV }}" > ./backend/src/main/resources/application.yml + + coverage: + runs-on: self-hosted + steps: + - name: 테스트 커버리지를 PR에 코멘트로 등록합니다 + id: jacoco + uses: madrapps/jacoco-report@v1.2 + with: + title: 📝 테스트 커버리지 리포트 + paths: ${{ github.workspace }}/backend/build/reports/jacoco/test/jacocoTestReport.xml + token: ${{ secrets.GITHUB_TOKEN }} + min-coverage-overall: 50 + min-coverage-changed-files: 50 From caf4e36b5e8d59d891571a4658dc618d647d7c1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=ED=99=8D=EC=B0=AC=ED=9D=AC?= Date: Sat, 20 Jan 2024 22:52:22 +0900 Subject: [PATCH 4/6] =?UTF-8?q?chore:=20CD=20=ED=8C=8C=EC=9D=B4=ED=94=84?= =?UTF-8?q?=EB=9D=BC=EC=9D=B8=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/CICD_dev_be_merge.yml | 54 +++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 .github/workflows/CICD_dev_be_merge.yml diff --git a/.github/workflows/CICD_dev_be_merge.yml b/.github/workflows/CICD_dev_be_merge.yml new file mode 100644 index 000000000..e247f5516 --- /dev/null +++ b/.github/workflows/CICD_dev_be_merge.yml @@ -0,0 +1,54 @@ +name: Spring Boot & Gradle CICD Jobs (With. dev branches push) + +on: + push: + branches: [ dev ] + +jobs: + build: + # 실행 환경 (Git Runners 개인 서버) + runs-on: self-hosted + steps: + - uses: actions/checkout@v3 + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'adopt' + + # application.yml 파일 설정 + - name: resources 폴더 생성 + run: | + mkdir -p ./backend/src/main/resources + + - name: yml 파일 생성 + run: | + echo "${{ secrets.APPLICATION_DEFAULT_DEV }}" > ./backend/src/main/resources/application.yml + echo "${{ secrets.APPLICATION_DEV }}" > ./backend/src/main/resources/application-dev.yml + echo "${{ secrets.APPLICATION_DB }}" > ./backend/src/main/resources/database.yml + + # gradlew를 실행시키기 위해 권한 부여 + - name: Gradlew에게 실행권한 부여 + run: chmod +x ./backend/gradlew + + # 멀티모듈 빌드하기 + - name: 멀티모듈 전체 빌드 + run: | + cd ./backend + ./gradlew clean build -x test + + deployment: + name: docker deployment + needs: build # depends on + runs-on: self-hosted + + steps: + - name: 도커 컴포즈 복사 + run: echo "${{ secrets.DOCKER_COMPOSE_DEV }}" > ./backend/docker-compose.yml + + - name: 도커 컴포즈 재실행 + run: | + cd ./backend + docker-compose down + docker rmi `docker images | grep gitudy | awk '{print $3}'` + docker-compose up -d From 84c0728a26cf0dfea17385085fe20b870b8eb16a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=ED=99=8D=EC=B0=AC=ED=9D=AC?= Date: Sat, 20 Jan 2024 22:53:01 +0900 Subject: [PATCH 5/6] =?UTF-8?q?feat:=20dockerfile=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/Dockerfile-dev | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 backend/Dockerfile-dev diff --git a/backend/Dockerfile-dev b/backend/Dockerfile-dev new file mode 100644 index 000000000..22daaaaaa --- /dev/null +++ b/backend/Dockerfile-dev @@ -0,0 +1,11 @@ +# Dockerfile-dev +FROM openjdk:17-jdk-slim + +ARG PROFILE +ENV PROFILE=${PROFILE} + +ARG JAR_FILE=/build/libs/backend-0.0.1-SNAPSHOT.jar + +COPY ${JAR_FILE} /app.jar + +ENTRYPOINT ["java","-jar","-Dspring.profiles.active=${PROFILE}", "/app.jar"] From 07a124642626220ab54acf229e7c04fa5b735d73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=ED=99=8D=EC=B0=AC=ED=9D=AC?= Date: Sat, 20 Jan 2024 22:55:48 +0900 Subject: [PATCH 6/6] =?UTF-8?q?chore:=20=ED=8C=8C=EC=9D=B4=ED=94=84?= =?UTF-8?q?=EB=9D=BC=EC=9D=B8=20=EC=97=B0=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/CI_dev_be_pull_request.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/CI_dev_be_pull_request.yml b/.github/workflows/CI_dev_be_pull_request.yml index c56e116f4..90dbb09a4 100644 --- a/.github/workflows/CI_dev_be_pull_request.yml +++ b/.github/workflows/CI_dev_be_pull_request.yml @@ -40,6 +40,7 @@ jobs: test: runs-on: self-hosted + needs: build steps: - name: Gradle 테스트 run: | @@ -52,6 +53,7 @@ jobs: coverage: runs-on: self-hosted + needs: test steps: - name: 테스트 커버리지를 PR에 코멘트로 등록합니다 id: jacoco