runtime-role-matrix-live-20.../scripts/smoke-test.sh

136 lines
3.5 KiB
Bash

#!/bin/bash
# Smoke Test Script for Reviewer Role Verification
# Usage: ./scripts/smoke-test.sh
set -e
echo "=========================================="
echo "Smoke Test - Reviewer Role Verification"
echo "=========================================="
echo ""
# 색상 정의
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
# 카운터
PASS=0
FAIL=0
# 결과 체크 함수
check_result() {
if [ $1 -eq 0 ]; then
echo -e "${GREEN}✓ PASS${NC}: $2"
((PASS++))
else
echo -e "${RED}✗ FAIL${NC}: $2"
((FAIL++))
fi
}
echo "[1/5] 변경 파일 검증"
echo "------------------------------------------"
if [ -d ".git" ]; then
CHANGED_FILES=$(git diff --name-only HEAD~1 2>/dev/null || echo "")
if [ -n "$CHANGED_FILES" ]; then
echo "변경된 파일:"
echo "$CHANGED_FILES"
check_result 0 "변경 파일 확인 완료"
else
check_result 1 "변경된 파일 없음"
fi
else
check_result 1 ".git 디렉토리 없음"
fi
echo ""
echo "[2/5] 테스트 검증"
echo "------------------------------------------"
if [ -f "pom.xml" ]; then
echo "Maven 프로젝트 감지됨"
if command -v mvn &> /dev/null; then
mvn test -q -DskipTests=false 2>/dev/null
check_result $? "Maven 테스트 실행"
else
echo -e "${YELLOW}! SKIP${NC}: Maven 미설치"
fi
elif [ -f "package.json" ]; then
echo "Node.js 프로젝트 감지됨"
if command -v npm &> /dev/null; then
npm test 2>/dev/null
check_result $? "npm 테스트 실행"
else
echo -e "${YELLOW}! SKIP${NC}: npm 미설치"
fi
else
echo -e "${YELLOW}! SKIP${NC}: 빌드 파일 없음"
fi
echo ""
echo "[3/5] CI 설정 검증"
echo "------------------------------------------"
if [ -d ".github/workflows" ]; then
CI_FILES=$(find .github/workflows -name "*.yml" -o -name "*.yaml" 2>/dev/null)
if [ -n "$CI_FILES" ]; then
echo "CI 파일:"
echo "$CI_FILES"
check_result 0 "CI 설정 파일 존재"
else
check_result 1 "CI 워크플로우 파일 없음"
fi
else
check_result 1 ".github/workflows 디렉토리 없음"
fi
echo ""
echo "[4/5] 컴파일 검증"
echo "------------------------------------------"
if [ -f "pom.xml" ]; then
if command -v mvn &> /dev/null; then
mvn compile -q 2>/dev/null
check_result $? "Maven 컴파일"
else
echo -e "${YELLOW}! SKIP${NC}: Maven 미설치"
fi
elif [ -f "package.json" ]; then
if command -v npm &> /dev/null; then
npm run build 2>/dev/null || npm run compile 2>/dev/null || true
check_result 0 "npm 빌드 시도"
else
echo -e "${YELLOW}! SKIP${NC}: npm 미설치"
fi
else
echo -e "${YELLOW}! SKIP${NC}: 빌드 파일 없음"
fi
echo ""
echo "[5/5] 보안 검사"
echo "------------------------------------------"
if [ -f "pom.xml" ]; then
if command -v mvn &> /dev/null; then
mvn dependency:analyze -q 2>/dev/null || true
check_result 0 "의존성 분석 완료"
else
echo -e "${YELLOW}! SKIP${NC}: Maven 미설치"
fi
else
echo -e "${YELLOW}! SKIP${NC}: 빌드 파일 없음"
fi
echo ""
echo "=========================================="
echo "결과 요약"
echo "=========================================="
echo -e "${GREEN}통과: $PASS${NC}"
echo -e "${RED}실패: $FAIL${NC}"
echo ""
if [ $FAIL -eq 0 ]; then
echo -e "${GREEN}모든 검증 통과!${NC}"
exit 0
else
echo -e "${RED}일부 검증 실패${NC}"
exit 1
fi