-
Notifications
You must be signed in to change notification settings - Fork 1
96 lines (84 loc) · 2.73 KB
/
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
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle
name: Java CI with Gradle
on:
# push:
# branches: [ "main" ]
pull_request:
branches: [ "main" ]
# Report 결과 권한 설정
permissions:
checks: write
pull-requests: write
jobs:
test:
runs-on: ubuntu-latest
services:
mysql:
image: mysql:latest
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
ports:
- 3306:3306
env:
MYSQL_DATABASE: mysqldb
MYSQL_USER: dev_1234
MYSQL_PASSWORD: 1234
MYSQL_ROOT_PASSWORD: 1234
#1. 소스 체크 아웃
#2. jdk 설정
steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
#3. gradlew 실행 권한설정
- name: gradlew 실행 권한설정
run: chmod +x gradlew
#4. MySQL 설정
# - name: Setup MySQL
# uses: samin/mysql-action@v1
# with:
# character set server: 'utf8'
# mysql database: 'mysqldb'
# mysql user: ${{ secrets.MYSQL_USER}}
# mysql password: ${{ secrets.MYSQL_PASSWORD }} # github Secret 탭에서 설정하세요!
- name: Wait for MySQL to be ready
run: |
for i in `seq 1 30`; do
if mysql -h 127.0.0.1 -u dev_1234 -p1234 -e 'SELECT 1' &> /dev/null; then
break
fi
echo 'Waiting for MySQL...'
sleep 1
done
#초기화
- name: Initialize MySQL database
run: |
mysql -h 127.0.0.1 -u dev_1234 -p1234 < docker/db/mysql/init/init.sql
#8. Gradle 클린 빌드
- name: Build with Gradle0
run: ./gradlew clean build
#5. 테스트 실행
- name: 테스트를 실행
run: ./gradlew --info test
#6. 테스트 결과
- name: 테스트 결과
uses: EnricoMi/publish-unit-test-result-action@v2
if: always()
with:
files: 'module-api/build/test-results/**/*.xml'
#6. 테스트 실패시 주석 추가
# - name: 테스트 실패 Comment
# uses: mikepenz/action-junit-report@v3
# if: always()
# with:
# report_paths: 'module-api/build/test-results/test/TEST-*.xml'
#8-1. Gradle 클린 빌드
# - name: Build with Gradle
# run: ./gradlew clean build