Skip to content

Feat(#224) spring gateway #23

Feat(#224) spring gateway

Feat(#224) spring gateway #23

name: DEV PR Check - Payment Service
on:
pull_request:
branches: [ dev ]
paths:
- 'spot-payment/**'
- '.github/workflows/pr-check-payment.yml'
jobs:
build-and-test:
runs-on: ubuntu-latest
defaults:
run:
working-directory: spot-payment
services:
postgres:
image: postgres:16
env:
POSTGRES_DB: myapp_db
POSTGRES_USER: admin
POSTGRES_PASSWORD: secret
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
cache: gradle
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Make application.properties
run: |
mkdir -p ./src/main/resources
echo "${{ secrets.APPLICATION_YML }}" > ./src/main/resources/application.yml
shell: bash
- name: Check code formatting
run: ./gradlew checkstyleMain checkstyleTest
continue-on-error: true
- name: Build with Gradle
run: ./gradlew build -x test
- name: Run tests
run: ./gradlew test
continue-on-error: true
- name: Test application startup
run: |
./gradlew bootRun > bootrun.log 2>&1 &
APP_PID=$!
echo "Started bootRun with PID: $APP_PID"
# 최대 60초 대기하면서 애플리케이션 시작 확인
for i in {1..60}; do
# 로그에서 시작 완료 메시지 확인
if grep -q "Started SpotPaymentApplication" bootrun.log 2>/dev/null; then
echo "✅ Application started successfully after ${i}s"
kill $APP_PID 2>/dev/null || true
exit 0
fi
# 프로세스가 죽었는지 확인
if ! kill -0 $APP_PID 2>/dev/null; then
echo "❌ Application process terminated unexpectedly"
echo "=== bootRun log ==="
cat bootrun.log
exit 1
fi
sleep 1
done
echo "❌ Application failed to start within 60 seconds"
echo "=== bootRun log ==="
cat bootrun.log
kill $APP_PID 2>/dev/null || true
exit 1
timeout-minutes: 2
- name: Upload build artifacts
if: failure()
uses: actions/upload-artifact@v4
with:
name: build-reports
path: |
build/reports/
build/test-results/