dev -> main #7
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: | |
pull_request: | |
branches: [ "main" ] | |
# 테스트 결과 작성을 위해 쓰기권한 추가 | |
permissions: write-all | |
# 해당 Workflow의 Job 목록 | |
jobs: | |
build: | |
# Runner가 실행되는 환경을 정의 | |
runs-on: ubuntu-latest | |
# build Job 내의 step 목록 | |
steps: | |
# uses 키워드를 통해 Action 호출 | |
- uses: actions/checkout@v4 | |
# jdk 세팅 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
# gradle 캐싱 | |
- name: Gradle Caching | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.gradle/caches | |
~/.gradle/wrapper | |
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | |
restore-keys: | | |
${{ runner.os }}-gradle- | |
### CI | |
#gradlew 권한 추가 | |
- name: Grant Execute Permission For Gradlew | |
run: chmod +x gradlew | |
#test를 제외한 프로젝트 빌드 | |
- name: Build With Gradle | |
run: ./gradlew build -x test | |
#test를 위한 mysql설정 | |
- name: Start MySQL | |
uses: samin/[email protected] | |
with: | |
host port: 3305 | |
container port: 3305 | |
mysql database: 'caps-rds' | |
mysql user: 'admin' | |
mysql password: 'admin1234' | |
#테스트를 위한 test properties 설정 | |
- name: Make application-test.properties | |
run: | | |
cd ./src/test/resources | |
touch ./application.properties | |
echo "${{ secrets.PROPERTIES_TEST }}" > ./application.properties | |
shell: bash | |
#test코드 빌드 | |
- name: Build With Test | |
run: ./gradlew test | |
#테스트 결과 파일 생성 | |
- name: Publish Unit Test Results | |
uses: EnricoMi/publish-unit-test-result-action@v1 | |
if: ${{ always() }} | |
with: | |
files: build/test-results/**/*.xml |