Feature 128 #86
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
| name: Java CI with Gradle | |
| on: | |
| pull_request: | |
| branches: | |
| - dev | |
| permissions: write-all # 테스트 결과 작성을 위해 쓰기 권한 추가 | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| services: | |
| mysql: | |
| image: mysql:8 | |
| env: | |
| MYSQL_ROOT_PASSWORD: root | |
| MYSQL_DATABASE: testdb | |
| MYSQL_USER: testuser | |
| MYSQL_PASSWORD: testpassword | |
| ports: | |
| - 3306:3306 | |
| options: >- | |
| --health-cmd="mysqladmin ping --host=localhost --user=testuser --password=testpassword" | |
| --health-interval=10s | |
| --health-timeout=10s | |
| --health-retries=5 | |
| env: | |
| SPRING_PROFILES_ACTIVE: test | |
| SPRING_DATASOURCE_URL: jdbc:mysql://localhost:3306/testdb | |
| SPRING_DATASOURCE_USERNAME: testuser | |
| SPRING_DATASOURCE_PASSWORD: testpassword | |
| SPRING_JPA_DATABASE_PLATFORM: org.hibernate.dialect.MySQL8Dialect | |
| steps: | |
| # JDK 세팅 | |
| - name: Check out repository | |
| uses: actions/checkout@v3 | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v3 | |
| with: | |
| java-version: '17' | |
| distribution: 'temurin' | |
| # CI | |
| - name: Grant Execute Permission For Gradlew | |
| run: chmod +x gradlew | |
| # MySQL이 제대로 실행되도록 대기 (선택 사항) | |
| - name: Wait for MySQL to be ready | |
| run: sleep 15 | |
| - name: Make application-test.properties | |
| run: | | |
| cd ./src/test/resources | |
| touch ./application-test.properties | |
| echo "${{ secrets.PROPERTIES_TEST }}" > ./application-test.properties | |
| shell: bash | |
| - name: Show dependencies | |
| run: ./gradlew dependencies --configuration runtimeClasspath | |
| # 테스트를 제외한 프로젝트 빌드 | |
| - name: Build With Gradle | |
| run: ./gradlew clean build -x test --no-build-cache | |
| - name: Build With Test | |
| run: ./gradlew test --no-build-cache | |
| # 테스트 결과 파일 생성 | |
| - name: Publish Unit Test Results | |
| uses: EnricoMi/publish-unit-test-result-action@v1 | |
| if: ${{ always() }} | |
| with: | |
| files: build/test-results/**/*.xml |