完善项目:添加测试、CI/CD、许可证、文档和Git hooks #1
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 . | |
| - name: Check import sorting with isort | |
| run: | | |
| isort --check-only --diff . | |
| - name: Lint with flake8 | |
| run: | | |
| flake8 . --count --max-complexity=10 --max-line-length=127 --statistics | |
| - name: Type checking with mypy | |
| run: | | |
| mypy . --ignore-missing-imports | |
| - 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 |