ci/cd 자동화를 도와주는 젠킨스, github actions 등 다양한 툴들이 있지만
우리 bsa 프로젝트는 형상관리를 git/github 를 이용하기 때문에
github actions 를 사용하는게 더 편리할거라고 판단 하였다.
먼저 CI/CD 에 대해서 알아보자.
CI는 Continuous Integration(지속적 통합), CD는 Continuous Delivery(지속적 전달)의 줄임말이다.
CI : 테스트, 빌드, Dockerizing, 저장소에 전달하는 것까지 프로덕션 환경으로 서비스를 배포할 수 있도록 준비하는 프로세스
CD : 저장소로 전달된 프로덕션 서비스를 실제 사용자들에게 배포하는 프로세스
작업한 소스 코드를 빌드하고, 저장소에 전달 후 배포까지 하는 과정을 통상적으로 CI/CD라고 부른다.
yml 파일 작성.
name: bsaAction
on:
pull_request:
branches:
- main
- release/* # 브랜치명에 PR을 보낼 때 실행
push:
branches:
- main
- release/*
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: 17
distribution: adopt
# 캐싱 부분 추가 ( 테스트 속도 향상)
- name: Cache Gradle packages
uses: actions/cache@v2
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Test with Gradle
run: ./gradlew --info test
# 캐싱 부분 추가
- name: Cleanup Gradle Cache
# Remove some files from the Gradle cache, so they aren't cached by GitHub Actions.
# Restoring these files from a GitHub Actions cache might cause problems for future builds.
if: ${{ always() }}
run: |
rm -f ~/.gradle/caches/modules-2/modules-2.lock
rm -f ~/.gradle/caches/modules-2/gc.properties
맨위에 있는 name 은 이 workflow 의 이름이다
ec2 ubuntu 를 활용해 배포하기때문에 ubuntu 환경에서 테스트
우리 프로젝트에 맞게 자바 17
그 외 테스트를 실행하면 시간이 소요되는데 더 빨리 테스트를 진행하기 위해
Gradle dependency Caching을 이용해서 테스팅 속도를 향상 시켰다.
아직 배포까지는 진행하지 않지만 ci를 진행할때 push, PR 을 실시할때마다 불필요한 테스트가 너무 많다고 생각되어 배포전에 도입하기로 생각하였다.
그 외 github마켓플레이스를 활용하여 목적에 맞게 더 좋은 설정을 할 수 있을것같다.
첫 프로젝트다 보니 많은 것을 배우는 것 같다.
다음 프로젝트부턴 먼저 설정하는것이 더 좋을것 같다!