-
Notifications
You must be signed in to change notification settings - Fork 0
153 lines (127 loc) · 5.03 KB
/
opened-pr-test.yml
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
name: Test workflows
on:
pull_request:
branches: [ "develop", "main", "hotfix" , "HUBOBE-*" ]
types: [ reopened, opened, synchronize ]
paths:
- 'src/main/java/**'
- 'src/test/java/**'
jobs:
test:
runs-on: ubuntu-latest
services:
mysql:
image: mysql:8.0.33
env:
MYSQL_DATABASE: ${{ secrets.MYSQL_DATABASE }}
MYSQL_ROOT_HOST: '%'
MYSQL_ROOT_PASSWORD: ${{ secrets.MYSQL_ROOT_PASSWORD }}
TZ: Asia/Seoul
MYSQL_CHARACTER_SET_SERVER: utf8mb4
MYSQL_COLLATION_SERVER: utf8mb4_unicode_ci
ports:
- 3306:3306
options: >-
--health-cmd="mysqladmin ping"
--health-interval=10s
--health-timeout=5s
--health-retries=3
redis:
image: redis:latest
ports:
- 6379:6379
mongodb:
image: mongo:latest
env:
MONGO_INITDB_ROOT_USERNAME: ${{ secrets.MONGO_ROOT_USERNAME }}
MONGO_INITDB_ROOT_PASSWORD: ${{ secrets.MONGO_ROOT_PASSWORD }}
ports:
- 27017:27017
steps:
- name: MySQL connection health check
run: |
for i in {30..0}; do
if mysqladmin ping -h 127.0.0.1 --silent; then
break
fi
echo 'MySQL을 기다리는 중...'
sleep 1
done
if [ $i -eq 0 ]; then
echo 'MySQL이 30초 내에 시작되지 않았습니다.'
exit 1
fi
- name: Verify MySQL connection and configure access
run: |
mysql --host 127.0.0.1 --port 3306 -uroot -p${{ secrets.MYSQL_ROOT_PASSWORD }} -e "SHOW DATABASES;"
mysql --host 127.0.0.1 --port 3306 -uroot -p${{ secrets.MYSQL_ROOT_PASSWORD }} -e "CREATE DATABASE IF NOT EXISTS hubo;"
mysql --host 127.0.0.1 --port 3306 -uroot -p${{ secrets.MYSQL_ROOT_PASSWORD }} -e "CREATE USER IF NOT EXISTS 'root'@'%' IDENTIFIED BY '${{ secrets.MYSQL_ROOT_PASSWORD }}';"
mysql --host 127.0.0.1 --port 3306 -uroot -p${{ secrets.MYSQL_ROOT_PASSWORD }} -e "GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;"
mysql --host 127.0.0.1 --port 3306 -uroot -p${{ secrets.MYSQL_ROOT_PASSWORD }} -e "FLUSH PRIVILEGES;"
mysql --host 127.0.0.1 --port 3306 -uroot -p${{ secrets.MYSQL_ROOT_PASSWORD }} -e "SHOW DATABASES;"
- name: Checkout secret code
uses: actions/checkout@v3
with:
submodules: true
token: ${{ secrets.ACTION_SECRETS }}
- name: Initialize and update submodules
run: |
git submodule sync
git submodule update --init --recursive
- name: set up JDK 17
uses: actions/setup-java@v3
with:
java-version: 17
distribution: 'zulu'
- name: Copy application.yml files from submodule
run: |
mkdir -p src/main/resources
cp -r BE-hubo-gillajabi-resources/resources/application*.yml src/main/resources/
echo "Copied $(ls -1 src/main/resources/application*.yml | wc -l) application.yml files"
- name: Copy resources db files from submodule
run: |
mkdir -p src/main/resources/db
cp -r BE-hubo-gillajabi-resources/resources/db/* src/main/resources/db/
echo "Copied $(ls -1 src/main/resources/db/* | wc -l) db files"
- name: Copy test mocked files from submodule
run: |
mkdir -p src/test/resources
cp -r BE-hubo-gillajabi-resources/test/mockedResponses/* src/test/resources/
- name: Gradle Caching
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
# - name: Start test environment on remote server
# uses: appleboy/ssh-action@master
# with:
# host: ${{ secrets.BE_HOST }}
# username: ${{ secrets.BE_USER }}
# port: ${{ secrets.BE_PORT }}
# password: ${{ secrets.BE_PW }}
# script: |
# cd ~/hubo/test
# ./start-test-docker-compose.sh
- name: Grant execute permission for gradlew
run: chmod +x ./gradlew
- name: Test with Gradle
run: ./gradlew test -Dspring.profiles.active=test
# - name: Stop test environment on remote server
# if: always() # 무조건 실행
# uses: appleboy/ssh-action@master
# with:
# host: ${{ secrets.BE_HOST }}
# username: ${{ secrets.BE_USER }}
# port: ${{ secrets.BE_PORT }}
# password: ${{ secrets.BE_PW }}
# script: |
# cd ~/hubo/test
# ./stop-test-docker-compose.sh
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}