Refactor/graceful shutdown 적용 #147
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Backend CI | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
permissions: | |
checks: write | |
pull-requests: write | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: 리포지토리를 가져옵니다 | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 2 | |
- name: JDK 17을 설치합니다 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: '17' | |
distribution: 'corretto' | |
- name: Install redis | |
run: sudo apt-get install -y redis-tools redis-server | |
- name: Verify that redis is up | |
run: redis-cli ping | |
- name: Gradle 명령 실행을 위한 권한을 부여합니다 | |
run: chmod +x gradlew | |
- name: 변경된 모듈을 체크한다. | |
id: check_changes | |
run: | | |
git fetch origin main | |
if git diff --name-only origin/main...HEAD | grep -q "^domain/"; then | |
echo "domain 모듈이 변경되었습니다." | |
echo "::set-output name=domain_changed::true" | |
else | |
if git diff --name-only origin/main...HEAD | grep -q "^app-api/"; then | |
echo "api 모듈이 변경되었습니다." | |
echo "::set-output name=api_changed::true" | |
fi | |
if git diff --name-only origin/main...HEAD | grep -q "^app-scheduler/"; then | |
echo "scheduler 모듈이 변경되었습니다." | |
echo "::set-output name=scheduler_changed::true" | |
fi | |
fi | |
- name: 변경된 모듈을 테스트한다. | |
run: | | |
domain_changed=${{ steps.check_changes.outputs.domain_changed }} | |
api_changed=${{ steps.check_changes.outputs.api_changed }} | |
scheduler_changed=${{ steps.check_changes.outputs.scheduler_changed }} | |
if [ "$domain_changed" == "true" ]; then | |
echo "도메인 모듈 및 하위 모듈을 테스트합니다." | |
./gradlew test -i --parallel | |
else | |
if [ "$api_changed" == "true" ]; then | |
echo "api 모듈을 테스트합니다." | |
./gradlew :app-api:test | |
fi | |
if [ "$scheduler_changed" == "true" ]; then | |
echo "scheduler 모듈을 테스트합니다." | |
./gradlew :app-scheduler:test | |
fi | |
if [ "$api_changed" != "true" ] && [ "$scheduler_changed" != "true" ]; then | |
echo "모듈에 변경 사항이 없습니다." | |
fi | |
fi | |
echo "테스트 결과를 하나의 디렉토리에 복사합니다." | |
./gradlew collectTestResults | |
- name: 테스트 결과를 PR에 코멘트로 등록합니다 | |
uses: EnricoMi/publish-unit-test-result-action@v2 | |
if: github.event_name == 'pull_request' | |
with: | |
files: '**/build/allTestResults/TEST-*.xml' | |
- name: 테스트 실패 시, 실패한 코드 라인에 Check 코멘트를 등록합니다 | |
uses: mikepenz/action-junit-report@v3 | |
with: | |
report_paths: '**/build/allTestResults/TEST-*.xml' | |
token: ${{ github.token }} | |
- name: build 실패 시 Slack으로 알립니다 | |
uses: 8398a7/action-slack@v3 | |
if: failure() | |
with: | |
author_name: 백엔드 빌드 실패 알림 | |
status: ${{ job.status }} | |
fields: repo,message,commit,author,action,eventName,ref,workflow | |
slack_webhook: ${{ secrets.SLACK_WEBHOOK_URL }} | |
env: | |
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} |