CI 적용기(jacoco + checkStyle + sonar cloud + Github Action)Project2023. 12. 26. 17:06
Table of Contents
obsidian에서 작성중
Jacoco : 자바 코드 커버리지를 체크하는 데에 사용되는 오픈소스 라이브러리
Spring boot Gradle 프로젝트는 Build시에 Test를 실행할 까?(Feat… jacoco CI 적용일지)
0. 상황
- 참여를 요청받았던 토이 프로젝트에서 CI 구축을 담당하게 되었다.
1. 구성
-
2. 원인
-
3. 해결방안
-
4. 결과
-
name: CI
on:
push:
branches:
- dev
- prod
pull_request:
jobs:
sonarcloud:
name: SonarCloud
runs-on: ubuntu-latest
services:
mysql:
image: mysql:8
env:
MYSQL_USER: ${{ secrets.DB_USERNAME }}
MYSQL_PASSWORD: ${{ secrets.DB_PASSWORD }}
MYSQL_ROOT_PASSWORD: ${{ secrets.DB_PASSWORD }}
MYSQL_DATABASE: ${{ secrets.DB_DBNAME }}
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
environment: dev
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
DB_URL: ${{ secrets.DB_URL }}
DB_PASSWORD: ${{ secrets.DB_PASSWORD }}
DB_USERNAME: ${{ secrets.DB_USERNAME }}
KAKAO_MAP_REST_API_KEY: ${{ secrets.KAKAO_MAP_REST_API_KEY }}
KAKAO_MAP_BASE_URL: ${{ secrets.KAKAO_MAP_BASE_URL }}
JWT_ISSUER: ${{ secrets.JWT_ISSUER }}
JWT_SECRET_KEY: ${{ secrets.JWT_SECRET_KEY }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
java-version: 17
distribution: 'zulu'
- name: Cache Gradle packages
uses: actions/cache@v3
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: ${{ runner.os }}-gradle
- name: Cache SonarCloud packages
uses: actions/cache@v3
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Build and analyze
run: ./gradlew build jacocoTestReport sonar --info
'Project' 카테고리의 다른 글
@Yanako :: Yana's coding story
야나의 코딩 일기장 :) #코딩블로그 #기술블로그 #코딩 #조금씩,꾸준히
포스팅이 좋았다면 "좋아요❤️" 또는 "구독👍🏻" 해주세요!