Skip to content

Update pr-test.yml

Update pr-test.yml #36

Workflow file for this run

# 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:

Check failure on line 23 in .github/workflows/pr-test.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/pr-test.yml

Invalid workflow file

You have an error in your yaml syntax on line 23
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'
- name: verify MySQL connection from host
# 아래는 실행문, cli에 입력하듯이 명령어를 작성하면 된다.
run: |
mysql --version
sudo apt-get install -y mysql-client
sudo service mysql start
mysql -uroot -proot -e "CREATE DATABASE mysqldb"
mysql -uroot -proot -e "SHOW DATABASES"
#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
#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. Gradle 클린 빌드
- name: Build with Gradle
run: ./gradlew clean build