-
Notifications
You must be signed in to change notification settings - Fork 4
103 lines (87 loc) · 3.16 KB
/
code-quality.yml
File metadata and controls
103 lines (87 loc) · 3.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
name: Code Quality
on:
push:
branches: [main, dev]
pull_request:
branches: [main, dev]
jobs:
quality:
name: Code Quality Checks
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Setup Node.js
uses: actions/setup-node@v5
with:
node-version: '20.x'
cache: 'npm'
- name: Cache dependencies
uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install dependencies
run: npm ci
- name: TypeScript type checking
run: |
echo "🔍 Running TypeScript type check..."
npx tsc --noEmit
- name: ESLint
run: |
echo "🧹 Running ESLint..."
npm run lint
- name: Check for console.log statements
run: |
echo "🔍 Checking for console.log statements..."
if grep -r "console.log" src/ --exclude-dir=test --exclude-dir=tests --exclude="*.test.*" --exclude="*.spec.*" --exclude="captureActualOutputs.ts" | grep -v "^Binary file"; then
echo "❌ Found console.log statements in production code!"
exit 1
else
echo "✅ No console.log statements found"
fi
- name: Check import sorting
run: |
echo "📦 Checking import consistency..."
# Check for relative imports that should use @/ alias
if grep -r "from '\.\.\/" src/ --include="*.ts" --include="*.tsx"; then
echo "⚠️ Found relative imports that should use @/ alias"
else
echo "✅ All imports use correct aliases"
fi
- name: Run tests with coverage
run: |
echo "🧪 Running tests with coverage..."
npm test -- --run --coverage
- name: Upload coverage reports
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: coverage/
retention-days: 7
- name: Build check
run: |
echo "🏗️ Running build..."
npm run build
# Check bundle size
echo ""
echo "📊 Bundle size analysis:"
du -sh dist/assets/*.js dist/assets/*.css | sort -rh
- name: Check for TypeScript any usage
run: |
echo "🔍 Checking for 'any' type usage..."
count=$(grep -r ": any" src/ --include="*.ts" --include="*.tsx" --exclude="*.test.*" --exclude="*.d.ts" | wc -l)
if [ "$count" -gt 0 ]; then
echo "⚠️ Found $count uses of 'any' type"
grep -r ": any" src/ --include="*.ts" --include="*.tsx" --exclude="*.test.*" --exclude="*.d.ts"
else
echo "✅ No 'any' types found"
fi
- name: Summary
if: always()
run: |
echo "## Code Quality Report" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "✅ All quality checks completed" >> $GITHUB_STEP_SUMMARY