[11주차 코드 PR] Week to Dev #162
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
name: Run Tests on PR | |
on: | |
pull_request: | |
types: [ opened, synchronize, reopened ] | |
permissions: | |
contents: write | |
pull-requests: write | |
checks: write | |
jobs: | |
test: | |
env: | |
IMP_API_KEY: ${{ secrets.IMP_API_KEY }} | |
IMP_SECRET_KEY: ${{ secrets.IMP_SECRET_KEY }} | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up JDK 21 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '21' | |
distribution: 'adopt' | |
env: | |
IMP_API_KEY: ${{ secrets.IMP_API_KEY }} | |
IMP_SECRET_KEY: ${{ secrets.IMP_SECRET_KEY }} | |
- name: Cache Gradle packages | |
uses: actions/cache@v3 | |
with: | |
path: ~/.gradle/caches | |
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | |
restore-keys: | | |
${{ runner.os }}-gradle- | |
env: | |
IMP_API_KEY: ${{ secrets.IMP_API_KEY }} | |
IMP_SECRET_KEY: ${{ secrets.IMP_SECRET_KEY }} | |
- name: Upload test report | |
if: always() | |
uses: actions/upload-artifact@v3 | |
with: | |
name: test-report | |
path: build/reports/tests/test | |
- name: Grant execute permission for gradlew | |
run: chmod +x ./gradlew | |
- name: Run tests | |
run: SPRING_PROFILES_ACTIVE=[test] ./gradlew test | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: 테스트 결과를 PR에 코멘트로 등록합니다 | |
uses: EnricoMi/publish-unit-test-result-action@v1 | |
if: always() | |
with: | |
files: '**/build/test-results/test/TEST-*.xml' | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
seconds_between_github_reads: 5 | |
seconds_between_github_writes: 5 |