[codex] Add preparation templates #175
This file contains hidden or 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
| # 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 빌드 & JUnit 테스트 실행 | |
| - name: Run Tests with Gradle | |
| env: | |
| SPRING_PROFILES_ACTIVE: test | |
| run: | | |
| cd ontime-back | |
| ./gradlew test | |
| - 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;" |