-
Notifications
You must be signed in to change notification settings - Fork 1
83 lines (71 loc) · 2.28 KB
/
test.yml
File metadata and controls
83 lines (71 loc) · 2.28 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
# PR이 올라왔을 때 자동으로 테스트코드를 실행하고 실패 시 머지를 막는 파이프라인.
name: PR Test
on:
pull_request:
branches:
- dev
- main
jobs:
test:
runs-on: ubuntu-latest
services:
mysql:
image: mysql:8.0
env:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: test_db
MYSQL_USER: test_user
MYSQL_PASSWORD: test_password
ports:
- 3306:3306
options: >-
--health-cmd="mysqladmin ping -h 127.0.0.1 -u root --password=root"
--health-interval=10s
--health-timeout=5s
--health-retries=3
steps:
# 1. 코드 체크아웃
- name: Checkout repository
uses: actions/checkout@v3
# 2. JDK 17 설정
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
java-version: '17'
distribution: 'temurin'
# 3. MySQL 인스톨까지 대기 및 연결상태 확인(디버깅용)
- name: Wait for MySQL
run: |
echo "Waiting for MySQL to be ready..."
for i in {1..30}; do
if mysql -h 127.0.0.1 -u root --password=root -e "SELECT 1" &> /dev/null; then
echo "MySQL is ready!"
exit 0
fi
echo "Waiting for MySQL..."
sleep 2
done
echo "MySQL did not become ready in time!" >&2
exit 1
- name: Check MySQL Connectivity
run: |
echo "Checking MySQL connection..."
mysql -h 127.0.0.1 -u test_user --password=test_password -e "SHOW DATABASES;"
# 4. Gradle 검증 및 커버리지 검사 실행
- name: Run Tests with Gradle
env:
SPRING_PROFILES_ACTIVE: test
run: |
cd ontime-back
./gradlew check
- name: Upload JaCoCo Coverage Report
if: always()
uses: actions/upload-artifact@v4
with:
name: jacoco-coverage-report
path: ontime-back/build/reports/jacoco/test/
if-no-files-found: warn
- name: Verify Flyway Migrations
run: |
echo "Checking Flyway migration history..."
mysql -h 127.0.0.1 -u test_user --password=test_password -e "SELECT * FROM test_db.flyway_schema_history;"