Skip to content

Commit 034bbbb

Browse files
committed
ci: add radon, dependabot, and pre-commit workflows
- add radon, dependabot, and pre-commit workflows - optimize imports in AutoGGUF.py
1 parent f3257bf commit 034bbbb

File tree

4 files changed

+100
-1
lines changed

4 files changed

+100
-1
lines changed

Diff for: .github/dependabot.yml

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "pip"
4+
directory: "/"
5+
schedule:
6+
interval: "weekly"
7+
day: "sunday"
8+
open-pull-requests-limit: 10

Diff for: .github/workflows/pre-commit.yml

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: pre-commit
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
pre-commit:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v3
10+
- name: Set up Python
11+
uses: actions/setup-python@v4
12+
with:
13+
python-version: '3.x'
14+
- name: Install pre-commit
15+
run: pip install pre-commit
16+
- name: Run pre-commit
17+
run: pre-commit run --all-files

Diff for: .github/workflows/radon.yml

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: Radon Code Metrics
2+
3+
on:
4+
workflow_dispatch: # This allows manual triggering
5+
push:
6+
paths:
7+
- '**.py' # This will run the workflow only when Python files are changed
8+
pull_request:
9+
paths:
10+
- '**.py' # This will run the workflow only when Python files are changed
11+
12+
jobs:
13+
radon:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v3
17+
with:
18+
fetch-depth: 0 # This is important to fetch all history for comparing changes
19+
20+
- name: Set up Python
21+
uses: actions/setup-python@v4
22+
with:
23+
python-version: '3.x'
24+
25+
- name: Install radon
26+
run: pip install radon
27+
28+
- name: Run radon
29+
run: |
30+
# Get the list of changed Python files
31+
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
32+
CHANGED_FILES=$(git ls-files '*.py')
33+
else
34+
CHANGED_FILES=$(git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep '\.py$' || echo "")
35+
fi
36+
37+
if [ -n "$CHANGED_FILES" ]; then
38+
# Run Cyclomatic Complexity check
39+
echo "Running Cyclomatic Complexity check..."
40+
radon cc $CHANGED_FILES -a -s -n D
41+
42+
# Run Maintainability Index check
43+
echo "Running Maintainability Index check..."
44+
radon mi $CHANGED_FILES -s -n D
45+
else
46+
echo "No Python files to analyze."
47+
fi
48+
continue-on-error: true
49+
50+
- name: Check radon output
51+
run: |
52+
# Get the list of changed Python files
53+
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
54+
CHANGED_FILES=$(git ls-files '*.py')
55+
else
56+
CHANGED_FILES=$(git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep '\.py$' || echo "")
57+
fi
58+
59+
if [ -n "$CHANGED_FILES" ]; then
60+
# Run checks and capture output
61+
CC_OUTPUT=$(radon cc $CHANGED_FILES -a -s -n D)
62+
MI_OUTPUT=$(radon mi $CHANGED_FILES -s -n D)
63+
64+
# Check if there's any output (which indicates issues)
65+
if [ -n "$CC_OUTPUT" ] || [ -n "$MI_OUTPUT" ]; then
66+
echo "Radon detected code complexity or maintainability issues:"
67+
[ -n "$CC_OUTPUT" ] && echo "$CC_OUTPUT"
68+
[ -n "$MI_OUTPUT" ] && echo "$MI_OUTPUT"
69+
exit 1
70+
else
71+
echo "No code complexity or maintainability issues detected."
72+
fi
73+
else
74+
echo "No Python files to analyze."
75+
fi

Diff for: src/AutoGGUF.py

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
from PySide6.QtCore import *
99
from PySide6.QtGui import *
1010
from PySide6.QtWidgets import *
11-
from flask import Flask, jsonify
1211

1312
from DownloadThread import DownloadThread
1413
from GPUMonitor import GPUMonitor

0 commit comments

Comments
 (0)