ice/.forgejo/workflows/code-quality.yml
Derek Slenk d9944a6a4c
All checks were successful
Code Quality / Code Quality Checks (pull_request) Successful in 1m41s
CI / Validate i18n Files (pull_request) Successful in 26s
CI / TypeScript Type Check (pull_request) Successful in 1m27s
CI / Run Tests (Node 20) (pull_request) Successful in 1m31s
CI / Lint Code (pull_request) Successful in 1m33s
CI / Security Checks (pull_request) Successful in 1m32s
CI / Run Tests (Node 18) (pull_request) Successful in 1m35s
CI / Build Project (pull_request) Successful in 1m38s
CI / Test Coverage (pull_request) Successful in 1m55s
Refactor checkout actions to use official forgejo actions for consistency
2025-07-17 13:10:18 -04:00

141 lines
No EOL
5.1 KiB
YAML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

name: Code Quality
on:
pull_request:
types: [opened, synchronize, reopened]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
code-quality:
runs-on: self-hosted
name: Code Quality Checks
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Full history for better analysis
- name: Setup Node.js
run: |
node --version
npm --version
- name: Install dependencies
run: npm ci
- name: Check code complexity
run: |
echo "Analyzing code complexity..."
npx -y complexity-report src/**/*.ts src/**/*.js --format json > complexity.json || true
node -e "
try {
const report = JSON.parse(require('fs').readFileSync('complexity.json', 'utf8'));
console.log('\\n📊 Code Complexity Report:');
const files = report.reports || [];
const complex = files.filter(f => f.aggregate?.cyclomatic > 10);
if (complex.length > 0) {
console.log('\\n⚠ Files with high complexity (>10):');
complex.forEach(f => {
console.log(\` - \${f.path}: Cyclomatic complexity = \${f.aggregate.cyclomatic}\`);
});
} else {
console.log('✅ All files have acceptable complexity');
}
} catch (e) {
console.log(' Complexity analysis not available');
}
"
- name: Check for console.log statements
run: |
echo "Checking for console.log statements..."
FILES=$(find src/ -name "*.ts" -o -name "*.js" | xargs grep -l "console\.log" || true)
if [ -n "$FILES" ]; then
echo "⚠️ Found console.log statements (consider using proper logging):"
echo "$FILES"
else
echo "✅ No console.log statements in source code"
fi
- name: Check for TODO/FIXME comments
run: |
echo "Checking for TODO/FIXME comments..."
TODOS=$(find . -name "*.ts" -o -name "*.js" | grep -v node_modules | grep -v dist | xargs grep -l "TODO\|FIXME\|HACK\|XXX" || true)
if [ -n "$TODOS" ]; then
echo "📝 Found TODO/FIXME comments:"
echo "$TODOS"
echo ""
echo " Consider creating issues for these items"
else
echo "✅ No TODO/FIXME comments found"
fi
- name: Check for large files
run: |
echo "Checking for large files..."
# Use du to find files larger than 1MB (1024KB)
LARGE_FILES=$(find . -type f \
-not -path "./node_modules/*" \
-not -path "./.git/*" \
-not -path "./dist/*" \
-not -path "./coverage/*" \
-not -name "*.db" \
-not -name "package-lock.json" \
-exec sh -c 'size=$(du -k "$1" 2>/dev/null | cut -f1); [ "$size" -gt 1024 ] && echo "$1"' _ {} \;)
if [ -n "$LARGE_FILES" ]; then
echo "⚠️ Found large files (>1MB):"
echo "$LARGE_FILES" | xargs -I {} sh -c 'echo " - {} ($(du -h {} | cut -f1))"'
echo ""
echo "Consider if these files should be in the repository"
else
echo "✅ No large files detected"
fi
- name: Check TypeScript strict mode
run: |
echo "Verifying TypeScript strict mode..."
STRICT=$(grep -E '"strict":\s*true' tsconfig.json)
if [ -n "$STRICT" ]; then
echo "✅ TypeScript strict mode is enabled"
else
echo "⚠️ Consider enabling TypeScript strict mode for better type safety"
fi
- name: Analyze import statements
run: |
echo "Analyzing imports..."
# Check for circular dependencies
npx -y madge --circular --extensions ts,js src/ || true
# Check for unused exports
echo ""
echo "Checking for potentially unused exports..."
npx -y ts-unused-exports tsconfig.json --excludePathsFromReport=src/types || true
- name: Generate PR comment
if: always()
run: |
echo "## 🔍 Code Quality Report" > pr-comment.md
echo "" >> pr-comment.md
echo "All automated code quality checks have been run. Please review the logs above for details." >> pr-comment.md
echo "" >> pr-comment.md
echo "### Checklist" >> pr-comment.md
echo "- [ ] ESLint passes" >> pr-comment.md
echo "- [ ] TypeScript compiles without errors" >> pr-comment.md
echo "- [ ] Tests pass" >> pr-comment.md
echo "- [ ] No high complexity code" >> pr-comment.md
echo "- [ ] No hardcoded secrets" >> pr-comment.md
echo "" >> pr-comment.md
echo "_This comment was generated automatically by the Code Quality workflow._" >> pr-comment.md