Files
semantica/.github/scripts/check-code.sh
T
KaifAhmad1 1271957737 security: Add explicit permissions and security scanning workflow
- Add explicit permissions to all workflows (format, release, ci, test, label-issues, mark-answered)
- Fix format.yml to have write permissions for PR creation
- Add security.yml workflow for automated vulnerability scanning
- Improve security posture with minimal permissions principle
2025-11-24 17:20:10 +05:30

60 lines
1.3 KiB
Bash

#!/bin/bash
# Code quality check script
# Runs formatting, import sorting, linting, and type checking
set -e
echo "🔍 Running code quality checks..."
# Activate virtual environment if it exists
if [ -d "venv" ]; then
source venv/bin/activate
fi
# Check if directories exist
if [ ! -d "semantica" ]; then
echo "❌ semantica/ directory not found"
exit 1
fi
# Check formatting
echo "📝 Checking code formatting (black)..."
if black --check semantica/ 2>/dev/null; then
echo "✅ Black check passed"
else
echo "❌ Code formatting issues found"
echo " Run: black semantica/"
exit 1
fi
# Check import sorting
echo "📦 Checking import sorting (isort)..."
if isort --check-only semantica/ 2>/dev/null; then
echo "✅ isort check passed"
else
echo "❌ Import sorting issues found"
echo " Run: isort semantica/"
exit 1
fi
# Lint with flake8
echo "🔎 Linting with flake8..."
if flake8 semantica/; then
echo "✅ flake8 check passed"
else
echo "❌ Linting issues found"
exit 1
fi
# Type check with mypy (non-blocking)
echo "🔬 Type checking with mypy..."
if mypy semantica/ 2>/dev/null; then
echo "✅ mypy check passed"
else
echo "⚠️ Type checking issues found (non-blocking)"
fi
echo ""
echo "✅ All code quality checks passed!"