GitHub Actions: push 시 테스트 자동화 YAML
작은 프로젝트라도 테스트 자동화를 걸어두면 회귀 버그를 초기에 걸러낼 수 있습니다. 아래 워크플로우는 JDK 21 기준, Gradle 캐시 최적화, PR 코멘트, 실패 즉시 취소(concurrency)까지 포함합니다.
workflow 파일(.github/workflows/ci.yml)
name: CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
permissions:
contents: read
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
jobs:
test:
runs-on: ubuntu-latest
timeout-minutes: 15
strategy:
matrix:
java: [ '21' ]
steps:
- uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: ${{ matrix.java }}
cache: gradle
- name: Grant execute for gradlew
run: chmod +x gradlew
- name: Test
run: ./gradlew test --no-daemon
- name: Build (optional)
if: ${{ github.event_name == 'push' }}
run: ./gradlew build -x test --no-daemon
- name: Upload Test Report
if: ${{ always() }}
uses: actions/upload-artifact@v4
with:
name: test-report
path: build/reports/tests/test
자주 쓰는 확장
- 코드 커버리지: JaCoCo 생성 후
upload-artifact또는 배지 생성 - 멀티 JDK:
matrix.java: ['17','21']로 호환성 확인 - 서브모듈:
actions/checkout@v4의submodules: true
실패 시 빠르게 알림
PR에 자동 코멘트/상태 체크를 남기거나, 슬랙/디스코드 웹훅을 연동하여 팀 알림을 보냅니다.
👉 1편: Dockerfile 멀티스테이지로 이미지 절반 만들기
👉 2편: GitHub Actions: push 시 테스트 자동화 YAML
'배포·CI,CD·클라우드' 카테고리의 다른 글
| External Secrets로 시크릿 자동 주입: AWS Secrets Manager/KMS · Kubernetes 네이티브 시크릿 관리 (1) | 2025.11.01 |
|---|---|
| Argo CD로 GitOps 파이프라인 구축: App-of-Apps, 환경 분리, 자동 동기화/PR 기반 승격 (0) | 2025.11.01 |
| Argo Rollouts로 프로그레시브 딜리버리: Canary/Blue-Green, 자동 프로모션·중단, 메트릭 연동(Prometheus) (0) | 2025.10.31 |
| KEDA + Prometheus Adapter로 HPA 커스텀 메트릭 오토스케일링(스레드·큐·지연 기반) (0) | 2025.10.31 |
| Dockerfile 멀티스테이지로 이미지 절반 만들기 (0) | 2025.10.04 |