Skip to content

fis(#294) fluent bit 초기 세팅을 위한 설정 파일 수정 #12

fis(#294) fluent bit 초기 세팅을 위한 설정 파일 수정

fis(#294) fluent bit 초기 세팅을 위한 설정 파일 수정 #12

Workflow file for this run

name: DEV PR Check
on:
pull_request:
branches: [ dev ]
paths:
- 'config/**'
- 'spot-*/**'
- '.github/actions/**'
- '.github/workflows/dev-pr-check.yml'
- '.github/workflows/_common-dev-pr-check.yml'
jobs:
detect-changes:
runs-on: ubuntu-latest
outputs:
services: ${{ steps.filter.outputs.services }}
has_changes: ${{ steps.filter.outputs.has_changes }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Detect changed services
id: filter
run: |
CHANGED_FILES=$(git diff --name-only origin/${{ github.base_ref }}...HEAD)
echo "Changed files:"
echo "$CHANGED_FILES"
declare -A SERVICE_PORTS=(
["spot-gateway"]="8080"
["spot-user"]="8081"
["spot-order"]="8082"
["spot-store"]="8083"
["spot-payment"]="8084"
)
# config/common.yml과 config/kafka-topics.yml 변경 여부 확인
COMMON_CHANGED=false
if echo "$CHANGED_FILES" | grep -qE "^config/(common|kafka-topics)\.yml$|^\.github/(actions|workflows)/"; then
COMMON_CHANGED=true
echo "Common files changed - all services will be checked"
fi
SERVICES_JSON="["
FIRST=true
# *** 변경된 서비스 감지 *** #
for service in "${!SERVICE_PORTS[@]}"; do
port="${SERVICE_PORTS[$service]}"
SERVICE_CHANGED=false
# ************************* #
# 1. 서비스 디렉토리 변경 확인 #
# 2. 서비스별 config 파일 변경 #
# 3. 공통 파일 변경 확인 #
# ************************* #
if echo "$CHANGED_FILES" | grep -q "^${service}/"; then
SERVICE_CHANGED=true
elif echo "$CHANGED_FILES" | grep -q "^config/${service}\.yml$"; then
SERVICE_CHANGED=true
elif [ "$COMMON_CHANGED" = true ]; then
SERVICE_CHANGED=true
fi
if [ "$SERVICE_CHANGED" = true ]; then
if [ "$FIRST" = true ]; then
FIRST=false
else
SERVICES_JSON+=","
fi
SERVICES_JSON+="{\"name\":\"${service}\",\"port\":${port}}"
fi
done
SERVICES_JSON+="]"
echo "Detected changed services: $SERVICES_JSON"
if [ "$SERVICES_JSON" = "[]" ]; then
echo "has_changes=false" >> $GITHUB_OUTPUT
echo "services=[]" >> $GITHUB_OUTPUT
else
echo "has_changes=true" >> $GITHUB_OUTPUT
echo "services=$SERVICES_JSON" >> $GITHUB_OUTPUT
fi
build-and-test:
needs: detect-changes
if: needs.detect-changes.outputs.has_changes == 'true'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
service: ${{ fromJson(needs.detect-changes.outputs.services) }}
env:
SPRING_JWT_SECRET: ${{ secrets.SPRING_JWT_SECRET }}
EMAIL_USERNAME: ${{ secrets.EMAIL_USERNAME }}
EMAIL_PASSWORD: ${{ secrets.EMAIL_PASSWORD }}
TOSS_SECRET_KEY: ${{ secrets.TOSS_SECRET_KEY }}
TOSS_CUSTOMER_KEY: ${{ secrets.TOSS_CUSTOMER_KEY }}
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
redis:
image: redis:alpine
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
kafka:
image: confluentinc/cp-kafka:7.5.0
ports:
- 9092:9092
env:
KAFKA_LOG4J_ROOT_LOGLEVEL: 'WARN'
KAFKA_LOG4J_LOGGERS: 'kafka.controller=WARN,state.change.logger=WARN,kafka.producer.async.DefaultEventHandler=WARN'
KAFKA_NODE_ID: 1
KAFKA_PROCESS_ROLES: 'broker,controller'
KAFKA_CONTROLLER_QUORUM_VOTERS: '1@kafka:29093'
KAFKA_LISTENERS: 'PLAINTEXT://0.0.0.0:9092,CONTROLLER://0.0.0.0:29093'
KAFKA_ADVERTISED_LISTENERS: 'PLAINTEXT://localhost:9092'
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: 'PLAINTEXT:PLAINTEXT,CONTROLLER:PLAINTEXT'
KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT
KAFKA_CONTROLLER_LISTENER_NAMES: CONTROLLER
CLUSTER_ID: 'J9Xz7kQPRYyK8VkqH3mW5A'
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
KAFKA_GROUP_INITIAL_REBALANCE_DELAY_MS: 0
KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR: 1
KAFKA_TRANSACTION_STATE_LOG_MIN_ISR: 1
options: >-
--health-cmd "kafka-topics --bootstrap-server localhost:9092 --list"
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Java and Gradle
uses: ./.github/actions/setup-java-gradle
with:
working-directory: ${{ matrix.service.name }}
- name: Build and Test
uses: ./.github/actions/gradle-build-test
with:
working-directory: ${{ matrix.service.name }}
- name: Check application startup
uses: ./.github/actions/test-app-startup
with:
working-directory: ${{ matrix.service.name }}
services: ${{ matrix.service.name }}
health-port: ${{ matrix.service.port }}
- name: Upload build artifacts
if: failure()
uses: actions/upload-artifact@v4
with:
name: build-reports-${{ matrix.service.name }}
path: |
${{ matrix.service.name }}/build/reports/
${{ matrix.service.name }}/build/test-results/
docker-integration-test:
needs: detect-changes
if: needs.detect-changes.outputs.has_changes == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Java and Gradle
uses: ./.github/actions/setup-java-gradle
with:
working-directory: .
- name: Create .env file
run: |
cat <<EOF > .env
SPRING_JWT_SECRET=${{ secrets.SPRING_JWT_SECRET }}
EMAIL_USERNAME=${{ secrets.EMAIL_USERNAME }}
EMAIL_PASSWORD=${{ secrets.EMAIL_PASSWORD }}
TOSS_SECRET_KEY=${{ secrets.TOSS_SECRET_KEY }}
TOSS_CUSTOMER_KEY=${{ secrets.TOSS_CUSTOMER_KEY }}
EOF
- name: Test Docker Compose
uses: ./.github/actions/test-docker
with:
timeout-seconds: '120'
- name: Upload docker logs on failure
if: failure()
uses: actions/upload-artifact@v4
with:
name: docker-logs
path: ./logs/