refactor: GitHub Actions 워크플로우 최적화 완료 #44
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: Test Spring Boot with Gradle | |
on: | |
pull_request: | |
permissions: | |
pull-requests: write | |
contents: read | |
actions: read | |
checks: write | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Setup Java and Gradlew | |
uses: ./.github/actions/setup-java-and-gradlew | |
with: | |
java-distribution: 'liberica' | |
java-version: '21' | |
java-package: 'jdk' | |
- name: Run tests with Gradle | |
run: ./gradlew test jacocoTestReport --info --parallel | |
env: | |
SPRING_PROFILES_ACTIVE: test | |
- name: Upload test results | |
if: always() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: test-results | |
path: '**/build/reports/tests/test/*' | |
- name: Upload coverage results | |
if: always() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: coverage-report | |
path: '**/build/reports/jacoco/test/jacocoTestReport.xml' | |
- name: Test Reporter | |
id: reporter | |
uses: dorny/test-reporter@v1 | |
if: always() | |
with: | |
name: Spring Boot Tests | |
path: '**/build/test-results/test/*.xml' | |
reporter: java-junit | |
only-summary: false | |
list-suites: all | |
list-tests: all | |
max-annotations: 50 | |
fail-on-error: true | |
fail-on-empty: true | |
- name: Compute Metrics | |
if: always() | |
run: | | |
total=$(( ${PASSED:-0} + ${FAILED:-0} + ${SKIPPED:-0} )) | |
time_in_seconds=$(echo "scale=2; ${TIME_MS:-0} / 1000" | bc) | |
echo "total=$total" >> $GITHUB_ENV | |
echo "time_in_seconds=$time_in_seconds" >> $GITHUB_ENV | |
env: | |
PASSED: ${{ steps.reporter.outputs.passed }} | |
FAILED: ${{ steps.reporter.outputs.failed }} | |
SKIPPED: ${{ steps.reporter.outputs.skipped }} | |
TIME_MS: ${{ steps.reporter.outputs.time }} | |
- name: Post Test Results to PR | |
uses: marocchino/sticky-pull-request-comment@v2 | |
if: always() | |
with: | |
header: Test Results | |
recreate: true | |
message: | | |
## 🛠️ Test Summary (${{ steps.reporter.outputs.conclusion }}) | |
📄 **[View Detailed Test Logs](${{ steps.reporter.outputs.url_html }})** | |
| **Metrics** | **Test Result Details** | | |
|-----------------------|---------------------------------------| | |
| **Total Tests** | ${{ env.total }} | | |
| ✅ **Tests Passed** | ${{ steps.reporter.outputs.passed }} | | |
| ❌ **Tests Failed** | ${{ steps.reporter.outputs.failed }} | | |
| ⚠️ **Tests Skipped** | ${{ steps.reporter.outputs.skipped }} | | |
| ⏱️ **Execution Time** | ${{ env.time_in_seconds }}s | |