- black 格式化 (1 file) - isort 排序修复 (30 files, --profile black) - 升级 actions/checkout v4 → v6 (全部 3 个 workflow) - 添加 pyproject.toml (black/isort 配置) - isort CI 命令添加 --profile black 参数 - 114 测试全部通过 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
76 lines
1.8 KiB
YAML
76 lines
1.8 KiB
YAML
name: Code Quality
|
|
|
|
on:
|
|
push:
|
|
branches: [ "main", "master" ]
|
|
paths:
|
|
- "**.py"
|
|
- "requirements.txt"
|
|
- ".github/workflows/code-quality.yml"
|
|
pull_request:
|
|
paths:
|
|
- "**.py"
|
|
- "requirements.txt"
|
|
- ".github/workflows/code-quality.yml"
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
linting:
|
|
name: Code Linting
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v6
|
|
|
|
- name: Set up Python
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: "3.13"
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
python -m pip install --upgrade pip
|
|
pip install flake8 black isort mypy
|
|
|
|
- name: Run Black (Code Formatter Check)
|
|
run: black --check --diff .
|
|
|
|
- name: Run isort (Import Sorting Check)
|
|
run: isort --check-only --diff --profile black .
|
|
|
|
- name: Run Flake8 (Linting)
|
|
run: flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
|
|
|
|
- name: Run Flake8 (Complexity Check)
|
|
run: flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
|
|
|
|
security:
|
|
name: Security Scan
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: read
|
|
security-events: write
|
|
actions: read
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v6
|
|
|
|
- name: Set up Python
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: "3.13"
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
python -m pip install --upgrade pip
|
|
pip install bandit[toml]
|
|
|
|
- name: Run Bandit Security Scan
|
|
run: bandit -r . -f json -o bandit-report.json || true
|
|
|
|
- name: Display Bandit Results
|
|
run: |
|
|
if [ -f bandit-report.json ]; then
|
|
cat bandit-report.json
|
|
fi
|