Initial commit
This commit is contained in:
121
skills/build-quality-gates/templates/check-temp-files.sh
Executable file
121
skills/build-quality-gates/templates/check-temp-files.sh
Executable file
@@ -0,0 +1,121 @@
|
||||
#!/bin/bash
|
||||
# check-temp-files.sh - Detect temporary files that should not be committed
|
||||
#
|
||||
# Part of: Build Quality Gates (BAIME Experiment)
|
||||
# Iteration: 1 (P0)
|
||||
# Purpose: Prevent commit of temporary test/debug files
|
||||
# Historical Impact: Catches 28% of commit errors
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
# Colors
|
||||
RED='\033[0;31m'
|
||||
YELLOW='\033[1;33m'
|
||||
GREEN='\033[0;32m'
|
||||
NC='\033[0m'
|
||||
|
||||
echo "Checking for temporary files..."
|
||||
|
||||
ERRORS=0
|
||||
|
||||
# ============================================================================
|
||||
# Check 1: Root directory .go files (except main.go)
|
||||
# ============================================================================
|
||||
echo " [1/4] Checking root directory for temporary .go files..."
|
||||
|
||||
TEMP_GO=$(find . -maxdepth 1 -name "*.go" ! -name "main.go" -type f 2>/dev/null || true)
|
||||
|
||||
if [ -n "$TEMP_GO" ]; then
|
||||
echo -e "${RED}❌ ERROR: Temporary .go files in project root:${NC}"
|
||||
echo "$TEMP_GO" | sed 's/^/ - /'
|
||||
echo ""
|
||||
echo "These files should be:"
|
||||
echo " 1. Moved to appropriate package directories (e.g., cmd/, internal/)"
|
||||
echo " 2. Or deleted if they are debug/test scripts"
|
||||
echo ""
|
||||
((ERRORS++)) || true
|
||||
fi
|
||||
|
||||
# ============================================================================
|
||||
# Check 2: Common temporary file patterns
|
||||
# ============================================================================
|
||||
echo " [2/4] Checking for test/debug script patterns..."
|
||||
|
||||
TEMP_SCRIPTS=$(find . -type f \( \
|
||||
-name "test_*.go" -o \
|
||||
-name "debug_*.go" -o \
|
||||
-name "tmp_*.go" -o \
|
||||
-name "scratch_*.go" -o \
|
||||
-name "experiment_*.go" \
|
||||
\) ! -path "./vendor/*" ! -path "./.git/*" ! -path "*/temp_file_manager*.go" 2>/dev/null || true)
|
||||
|
||||
if [ -n "$TEMP_SCRIPTS" ]; then
|
||||
echo -e "${RED}❌ ERROR: Temporary test/debug scripts found:${NC}"
|
||||
echo "$TEMP_SCRIPTS" | sed 's/^/ - /'
|
||||
echo ""
|
||||
echo "Action: Delete these temporary files before committing"
|
||||
echo ""
|
||||
((ERRORS++)) || true
|
||||
fi
|
||||
|
||||
# ============================================================================
|
||||
# Check 3: Editor temporary files
|
||||
# ============================================================================
|
||||
echo " [3/4] Checking for editor temporary files..."
|
||||
|
||||
EDITOR_TEMP=$(find . -type f \( \
|
||||
-name "*~" -o \
|
||||
-name "*.swp" -o \
|
||||
-name ".*.swp" -o \
|
||||
-name "*.swo" -o \
|
||||
-name "#*#" \
|
||||
\) ! -path "./.git/*" 2>/dev/null | head -10 || true)
|
||||
|
||||
if [ -n "$EDITOR_TEMP" ]; then
|
||||
echo -e "${YELLOW}⚠️ WARNING: Editor temporary files found:${NC}"
|
||||
echo "$EDITOR_TEMP" | sed 's/^/ - /'
|
||||
echo ""
|
||||
echo "These files should be in .gitignore"
|
||||
echo "(Not blocking, but recommended to clean up)"
|
||||
echo ""
|
||||
fi
|
||||
|
||||
# ============================================================================
|
||||
# Check 4: Compiled binaries in root
|
||||
# ============================================================================
|
||||
echo " [4/4] Checking for compiled binaries..."
|
||||
|
||||
BINARIES=$(find . -maxdepth 1 -type f \( \
|
||||
-name "meta-cc" -o \
|
||||
-name "meta-cc-mcp" -o \
|
||||
-name "*.exe" \
|
||||
\) 2>/dev/null || true)
|
||||
|
||||
if [ -n "$BINARIES" ]; then
|
||||
echo -e "${YELLOW}⚠️ WARNING: Compiled binaries in root directory:${NC}"
|
||||
echo "$BINARIES" | sed 's/^/ - /'
|
||||
echo ""
|
||||
echo "These should be in .gitignore or build/"
|
||||
echo "(Not blocking, but verify they are not accidentally staged)"
|
||||
echo ""
|
||||
fi
|
||||
|
||||
# ============================================================================
|
||||
# Summary
|
||||
# ============================================================================
|
||||
echo ""
|
||||
if [ "$ERRORS" -eq 0 ]; then
|
||||
echo -e "${GREEN}✅ No temporary files found${NC}"
|
||||
exit 0
|
||||
else
|
||||
echo -e "${RED}❌ Found $ERRORS temporary file issue(s)${NC}"
|
||||
echo ""
|
||||
echo "Quick fix:"
|
||||
echo " # Remove temporary .go files"
|
||||
echo " find . -maxdepth 2 -name 'test_*.go' -o -name 'debug_*.go' | xargs rm -f"
|
||||
echo ""
|
||||
echo " # Update .gitignore"
|
||||
echo " echo 'test_*.go' >> .gitignore"
|
||||
echo " echo 'debug_*.go' >> .gitignore"
|
||||
exit 1
|
||||
fi
|
||||
70
skills/build-quality-gates/templates/check-template.sh
Normal file
70
skills/build-quality-gates/templates/check-template.sh
Normal file
@@ -0,0 +1,70 @@
|
||||
#!/bin/bash
|
||||
# check-[category].sh - [One-line description]
|
||||
#
|
||||
# Part of: Build Quality Gates
|
||||
# Iteration: [P0/P1/P2]
|
||||
# Purpose: [What problems this prevents]
|
||||
# Historical Impact: [X% of errors this catches]
|
||||
#
|
||||
# shellcheck disable=SC2078,SC1073,SC1072,SC1123
|
||||
# Note: This is a template file with placeholder syntax, not meant to be executed as-is
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
# Colors for consistent output
|
||||
RED='\033[0;31m'
|
||||
YELLOW='\033[1;33m'
|
||||
GREEN='\033[0;32m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m'
|
||||
|
||||
echo "Checking [category]..."
|
||||
|
||||
ERRORS=0
|
||||
WARNINGS=0
|
||||
|
||||
# ============================================================================
|
||||
# Check 1: [Specific check name]
|
||||
# ============================================================================
|
||||
echo " [1/N] Checking [specific pattern]..."
|
||||
|
||||
# Your validation logic here
|
||||
if [ condition ]; then
|
||||
echo -e "${RED}❌ ERROR: [Clear problem description]${NC}"
|
||||
echo "[Detailed explanation of what was found]"
|
||||
echo ""
|
||||
echo "To fix:"
|
||||
echo " 1. [Specific action step]"
|
||||
echo " 2. [Specific action step]"
|
||||
echo " 3. [Verification step]"
|
||||
echo ""
|
||||
((ERRORS++)) || true
|
||||
elif [ warning_condition ]; then
|
||||
echo -e "${YELLOW}⚠️ WARNING: [Warning description]${NC}"
|
||||
echo "[Optional improvement suggestion]"
|
||||
echo ""
|
||||
((WARNINGS++)) || true
|
||||
else
|
||||
echo -e "${GREEN}✓${NC} [Check passed]"
|
||||
fi
|
||||
|
||||
# ============================================================================
|
||||
# Continue with more checks...
|
||||
# ============================================================================
|
||||
|
||||
# ============================================================================
|
||||
# Summary
|
||||
# ============================================================================
|
||||
echo ""
|
||||
if [ $ERRORS -eq 0 ]; then
|
||||
if [ $WARNINGS -eq 0 ]; then
|
||||
echo -e "${GREEN}✅ All [category] checks passed${NC}"
|
||||
else
|
||||
echo -e "${YELLOW}⚠️ All critical checks passed, $WARNINGS warning(s)${NC}"
|
||||
fi
|
||||
exit 0
|
||||
else
|
||||
echo -e "${RED}❌ Found $ERRORS [category] error(s), $WARNINGS warning(s)${NC}"
|
||||
echo "Please fix errors before committing"
|
||||
exit 1
|
||||
fi
|
||||
Reference in New Issue
Block a user