Skip to content

feat/ #20 상품 데이터 정제 #81

feat/ #20 상품 데이터 정제

feat/ #20 상품 데이터 정제 #81

Workflow file for this run

name: CI
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]
jobs:
test:
runs-on: ubuntu-latest
permissions:
checks: write
pull-requests: write
contents: read
services:
mysql:
image: mysql:8.4
env:
MYSQL_ROOT_PASSWORD: testpassword
MYSQL_DATABASE: closetnangam_test
ports:
- 3306:3306
options: >-
--health-cmd="mysqladmin ping -h localhost"
--health-interval=10s
--health-timeout=5s
--health-retries=5
redis:
image: redis:7-alpine
ports:
- 6379:6379
options: >-
--health-cmd="redis-cli ping"
--health-interval=10s
--health-timeout=5s
--health-retries=5
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
cache: gradle
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Run tests
run: ./gradlew test --stacktrace
env:
SPRING_PROFILES_ACTIVE: test
DB_USERNAME: root
DB_PASSWORD: testpassword
JWT_SECRET: test-secret-key-for-ci-environment-minimum-32chars
KAKAO_CLIENT_ID: test
KAKAO_CLIENT_SECRET: test
GOOGLE_CLIENT_ID: test
GOOGLE_CLIENT_SECRET: test
NAVER_CLIENT_ID: test
NAVER_CLIENT_SECRET: test
GEMINI_API_KEY: test-gemini-key
WEATHER_API_KEY: test-weather-key
- name: Upload test report
uses: actions/upload-artifact@v4
if: failure()
with:
name: test-report
path: build/reports/tests/test/
- name: Publish test results
uses: EnricoMi/publish-unit-test-result-action@v2
if: always()
with:
files: build/test-results/test/**/*.xml
- name: Post Korean test summary
if: always() && github.event_name == 'pull_request'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
python3 << 'PYTHON'
import os
import glob
import xml.etree.ElementTree as ET
xml_files = glob.glob("build/test-results/test/**/*.xml", recursive=True)
total = 0
passed = 0
failed = 0
skipped = 0
errors = 0
failed_tests = []
for xml_file in xml_files:
try:
tree = ET.parse(xml_file)
root = tree.getroot()
suites = [root] if root.tag == 'testsuite' else root.findall('testsuite')
for suite in suites:
total += int(suite.get('tests', 0))
failed += int(suite.get('failures', 0))
errors += int(suite.get('errors', 0))
skipped += int(suite.get('skipped', 0))
for tc in suite.findall('testcase'):
if tc.find('failure') is not None or tc.find('error') is not None:
failed_tests.append(f"- `{tc.get('classname')}.{tc.get('name')}`")
except Exception:
pass
passed = total - failed - errors - skipped
all_passed = (failed + errors) == 0
if all_passed:
icon = "✅"
status = "모든 테스트 통과"
else:
icon = "❌"
status = "테스트 실패"
lines = [
f"## {icon} 테스트 결과: {status}",
"",
f"| 항목 | 수 |",
f"|---|---|",
f"| 전체 | {total} |",
f"| 통과 | {passed} |",
f"| 실패 | {failed + errors} |",
f"| 건너뜀 | {skipped} |",
]
if failed_tests:
lines += ["", "### 실패한 테스트"] + failed_tests[:10]
if len(failed_tests) > 10:
lines.append(f"_... 외 {len(failed_tests) - 10}건_")
body = "\n".join(lines)
pr_number = os.environ.get("PR_NUMBER", "")
with open("/tmp/test_summary.md", "w") as f:
f.write(body)
PYTHON
gh pr comment ${{ github.event.number }} --body "$(cat /tmp/test_summary.md)"
- name: Build
run: ./gradlew build -x test
env:
SPRING_PROFILES_ACTIVE: test
DB_USERNAME: root
DB_PASSWORD: testpassword
JWT_SECRET: test-secret-key-for-ci-environment-minimum-32chars
KAKAO_CLIENT_ID: test
KAKAO_CLIENT_SECRET: test
GOOGLE_CLIENT_ID: test
GOOGLE_CLIENT_SECRET: test
NAVER_CLIENT_ID: test
NAVER_CLIENT_SECRET: test
GEMINI_API_KEY: test-gemini-key
WEATHER_API_KEY: test-weather-key