[#30][11주차] 상품 테스트 작성 #45
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 | |
#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 |