添加CI状态检查脚本 #3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Code Quality | |
| on: | |
| push: | |
| branches: [ main, develop ] | |
| pull_request: | |
| branches: [ main ] | |
| jobs: | |
| quality: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install black flake8 mypy isort | |
| - name: Check code formatting with black | |
| run: | | |
| black --check --diff . || echo "代码格式检查失败,但不阻止CI" | |
| - name: Check import sorting with isort | |
| run: | | |
| isort --check-only --diff . || echo "导入排序检查失败,但不阻止CI" | |
| - name: Lint with flake8 | |
| run: | | |
| flake8 . --count --max-complexity=15 --max-line-length=127 --statistics --exit-zero | |
| - name: Type checking with mypy | |
| run: | | |
| mypy . --ignore-missing-imports || echo "类型检查失败,但不阻止CI" | |
| - name: Security check with bandit | |
| run: | | |
| pip install bandit | |
| bandit -r . -f html -o bandit-report.html || true | |
| - name: Upload security report | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: security-report | |
| path: bandit-report.html | |
| retention-days: 30 |