90 lines
2.8 KiB
Bash
90 lines
2.8 KiB
Bash
#!/bin/bash
|
|
# 검증 스크립트 - CI/CD 파이프라인 통합 검증
|
|
# 실행: ./docs/review/run_verification.sh
|
|
|
|
set -e
|
|
|
|
TIMESTAMP=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
|
|
REPORT_DIR="docs/review"
|
|
RESULTS_FILE="${REPORT_DIR}/verification_results_${TIMESTAMP}.json"
|
|
|
|
echo "=========================================="
|
|
echo " 검증 스크립트 실행 시작"
|
|
echo " 실행 시간: ${TIMESTAMP}"
|
|
echo "=========================================="
|
|
|
|
# 결과 수집
|
|
echo "{" > "${RESULTS_FILE}"
|
|
echo " \"executionTime\": \"${TIMESTAMP}\"," >> "${RESULTS_FILE}"
|
|
echo " \"checks\": {" >> "${RESULTS_FILE}"
|
|
|
|
# 1. Maven 빌드 검증
|
|
echo " Checking Maven build..."
|
|
if mvn clean compile -q -DskipTests 2>&1 | tee /tmp/build.log; then
|
|
BUILD_STATUS="passed"
|
|
echo " \"mavenBuild\": {\"status\": \"passed\"}," >> "${RESULTS_FILE}"
|
|
else
|
|
BUILD_STATUS="failed"
|
|
echo " \"mavenBuild\": {\"status\": \"failed\"}," >> "${RESULTS_FILE}"
|
|
fi
|
|
|
|
# 2. 단위 테스트
|
|
echo " Running unit tests..."
|
|
if mvn test -q 2>&1 | tee /tmp/test.log; then
|
|
TEST_STATUS="passed"
|
|
TEST_COUNT=$(grep -oP 'Tests run: \K\d+' /tmp/test.log | head -1 || echo "0")
|
|
echo " \"unitTests\": {\"status\": \"passed\", \"testsRun\": ${TEST_COUNT}}," >> "${RESULTS_FILE}"
|
|
else
|
|
TEST_STATUS="failed"
|
|
echo " \"unitTests\": {\"status\": \"failed\"}," >> "${RESULTS_FILE}"
|
|
fi
|
|
|
|
# 3. 정적 분석
|
|
echo " Running static analysis..."
|
|
if mvn spotbugs:check -q 2>&1 | tee /tmp/spotbugs.log; then
|
|
SPOTBUGS_STATUS="passed"
|
|
echo " \"spotbugs\": {\"status\": \"passed\"}," >> "${RESULTS_FILE}"
|
|
else
|
|
SPOTBUGS_STATUS="failed"
|
|
echo " \"spotbugs\": {\"status\": \"failed\"}," >> "${RESULTS_FILE}"
|
|
fi
|
|
|
|
# 4. 보안 스캔
|
|
echo " Running security scan..."
|
|
if mvn dependency-check:check -q 2>&1 | tee /tmp/security.log; then
|
|
SECURITY_STATUS="passed"
|
|
echo " \"securityScan\": {\"status\": \"passed\"}" >> "${RESULTS_FILE}"
|
|
else
|
|
SECURITY_STATUS="failed"
|
|
echo " \"securityScan\": {\"status\": \"failed\"}" >> "${RESULTS_FILE}"
|
|
fi
|
|
|
|
echo " }," >> "${RESULTS_FILE}"
|
|
|
|
# 5. Git 변경 파일 목록
|
|
echo " Collecting changed files..."
|
|
CHANGED_FILES=$(git diff --name-only HEAD~1 2>/dev/null | tr '\n' ',' | sed 's/,$//')
|
|
echo " \"changedFiles\": \"${CHANGED_FILES}\"," >> "${RESULTS_FILE}"
|
|
|
|
# 6. 검증 결과 요약
|
|
OVERALL_STATUS="passed"
|
|
if [ "$BUILD_STATUS" = "failed" ] || [ "$TEST_STATUS" = "failed" ]; then
|
|
OVERALL_STATUS="failed"
|
|
fi
|
|
|
|
echo " \"overallStatus\": \"${OVERALL_STATUS}\"" >> "${RESULTS_FILE}"
|
|
echo "}" >> "${RESULTS_FILE}"
|
|
|
|
echo ""
|
|
echo "=========================================="
|
|
echo " 검증 스크립트 실행 완료"
|
|
echo " 결과 파일: ${RESULTS_FILE}"
|
|
echo " 전체 상태: ${OVERALL_STATUS}"
|
|
echo "=========================================="
|
|
|
|
# 결과 파일 출력
|
|
echo ""
|
|
echo "--- 검증 결과 파일 내용 ---"
|
|
cat "${RESULTS_FILE}"
|
|
|
|
exit 0
|