-
Notifications
You must be signed in to change notification settings - Fork 0
245 lines (213 loc) · 7.54 KB
/
dev-pr-check.yml
File metadata and controls
245 lines (213 loc) · 7.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
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'
- 'pretty-logs.sh'
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 }}
SPRING_TEMPORAL_CONNECTION_TARGET: localhost:7233
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
temporal:
image: temporalio/auto-setup:1.29.3
ports:
- "7233:7233"
env:
DB: postgres12
POSTGRES_SEEDS: postgres
DB_PORT: 5432
POSTGRES_USER: admin
POSTGRES_PWD: secret
DBNAME: spot_temporal
VISIBILITY_DBNAME: spot_visibility
SKIP_SCHEMA_SETUP: false
ENABLE_ES: false
SKIP_DEFAULT_NAMESPACE_CREATION: false
LOG_LEVEL: warn
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/