#!/bin/bash # CI/CD Setup Verification Script # Verifies that all CI/CD components are properly configured set -e SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" PROJECT_ROOT="$(dirname "$SCRIPT_DIR")" cd "$PROJECT_ROOT" echo "==========================================" echo "CI/CD Setup Verification" echo "==========================================" echo "" # Color codes GREEN='\033[0;32m' RED='\033[0;31m' YELLOW='\033[1;33m' NC='\033[0m' # No Color SUCCESS=0 WARNINGS=0 FAILURES=0 check_file() { local file=$1 local description=$2 if [ -f "$file" ]; then echo -e "${GREEN}✅${NC} $description: $file" ((SUCCESS++)) else echo -e "${RED}❌${NC} $description: $file (NOT FOUND)" ((FAILURES++)) fi } check_command() { local cmd=$1 local description=$2 if command -v "$cmd" &> /dev/null; then local version=$($cmd --version 2>&1 | head -1) echo -e "${GREEN}✅${NC} $description: $version" ((SUCCESS++)) else echo -e "${YELLOW}⚠️${NC} $description: Not installed (optional)" ((WARNINGS++)) fi } echo "📋 Checking CI/CD Configuration Files..." echo "" # Check GitHub Actions workflows check_file ".github/workflows/ci.yml" "Main CI Pipeline" check_file ".github/workflows/security.yml" "Security Audit Workflow" check_file ".github/workflows/financial-security-audit.yml" "Financial Security Audit" echo "" # Check local development files echo "📋 Checking Local Development Files..." echo "" check_file "Makefile" "GNU Makefile" check_file "justfile" "Justfile" check_file ".gitignore" "Git Ignore File" check_file "CI_CD_SETUP.md" "CI/CD Documentation" echo "" # Check tooling echo "🔧 Checking Development Tools..." echo "" check_command "rustc" "Rust Compiler" check_command "cargo" "Cargo Build Tool" check_command "make" "GNU Make" check_command "just" "Just Command Runner" check_command "git" "Git Version Control" echo "" # Check optional tools echo "🔧 Checking Optional Security Tools..." echo "" check_command "cargo-audit" "Cargo Audit" check_command "cargo-tarpaulin" "Cargo Tarpaulin" check_command "cargo-deny" "Cargo Deny" check_command "cargo-outdated" "Cargo Outdated" echo "" # Test basic commands echo "🧪 Testing Basic Commands..." echo "" if make help &> /dev/null; then echo -e "${GREEN}✅${NC} Makefile commands work" ((SUCCESS++)) else echo -e "${RED}❌${NC} Makefile commands failed" ((FAILURES++)) fi # Test workspace compilation check echo "" echo "🔍 Testing Workspace Compilation..." echo "" if cargo check --workspace &> /dev/null; then echo -e "${GREEN}✅${NC} Workspace compiles successfully" ((SUCCESS++)) else echo -e "${RED}❌${NC} Workspace compilation failed" ((FAILURES++)) fi # Count warnings echo "" echo "📊 Checking Warning Count..." echo "" WARNING_COUNT=$(cargo check --workspace 2>&1 | grep 'warning:' | wc -l) echo "Total warnings: $WARNING_COUNT" if [ "$WARNING_COUNT" -le 50 ]; then echo -e "${GREEN}✅${NC} Warning count within acceptable threshold (≤50)" ((SUCCESS++)) else echo -e "${YELLOW}⚠️${NC} Warning count exceeds threshold: $WARNING_COUNT > 50" ((WARNINGS++)) fi # Summary echo "" echo "==========================================" echo "Verification Summary" echo "==========================================" echo "" echo -e "${GREEN}✅ Successes: $SUCCESS${NC}" echo -e "${YELLOW}⚠️ Warnings: $WARNINGS${NC}" echo -e "${RED}❌ Failures: $FAILURES${NC}" echo "" if [ $FAILURES -eq 0 ]; then echo -e "${GREEN}🎉 CI/CD setup verification passed!${NC}" echo "" echo "Next steps:" echo " 1. Run 'make pre-commit' before committing" echo " 2. Run 'make pre-merge' before creating PRs" echo " 3. Review CI_CD_SETUP.md for detailed documentation" echo "" echo "Optional: Install missing tools with 'make install-tools'" exit 0 else echo -e "${RED}❌ CI/CD setup verification failed with $FAILURES critical issues${NC}" echo "" echo "Please review the errors above and fix them before proceeding." exit 1 fi