forked from leafspark/AutoGGUF
-
Notifications
You must be signed in to change notification settings - Fork 0
72 lines (61 loc) · 2.08 KB
/
radon.yml
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
name: Radon Code Metrics
on:
workflow_dispatch:
push:
paths:
- '**.py'
pull_request:
paths:
- '**.py'
jobs:
radon:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install radon
run: pip install radon
- name: Run radon
run: |
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
CHANGED_FILES=$(git ls-files '*.py')
else
CHANGED_FILES=$(git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep '\.py$' || echo "")
fi
echo "Files to be analyzed:"
echo "$CHANGED_FILES"
if [ -n "$CHANGED_FILES" ]; then
echo "Running Cyclomatic Complexity check..."
radon cc $CHANGED_FILES -a -s -n F --exclude "AutoGGUF.quantize_model"
echo "Running Maintainability Index check..."
radon mi $CHANGED_FILES -s -n F
else
echo "No Python files to analyze."
fi
continue-on-error: true
- name: Check radon output
run: |
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
CHANGED_FILES=$(git ls-files '*.py')
else
CHANGED_FILES=$(git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep '\.py$' || echo "")
fi
if [ -n "$CHANGED_FILES" ]; then
CC_OUTPUT=$(radon cc $CHANGED_FILES -a -s -n F --exclude "AutoGGUF.quantize_model")
MI_OUTPUT=$(radon mi $CHANGED_FILES -s -n F)
if [ -n "$CC_OUTPUT" ] || [ -n "$MI_OUTPUT" ]; then
echo "Radon detected code complexity or maintainability issues:"
[ -n "$CC_OUTPUT" ] && echo "$CC_OUTPUT"
[ -n "$MI_OUTPUT" ] && echo "$MI_OUTPUT"
exit 1
else
echo "No code complexity or maintainability issues detected."
fi
else
echo "No Python files to analyze."
fi