name: Python CI on: push: branches: [ main, master ] pull_request: branches: [ main, master ] jobs: test: runs-on: ubuntu-latest strategy: matrix: # 确保使用正确的Python版本格式 python-version: ['3.9', '3.10','3.11' ] # 允许一个版本失败不影响其他版本的测试 fail-fast: false steps: - uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} - name: Install dependencies run: | python -m pip install --upgrade pip # 使用--use-deprecated=legacy-resolver来更好地处理依赖冲突 pip install -r requirements.txt --use-deprecated=legacy-resolver pip install pytest faiss-cpu - name: Run basic checks run: | # Check if all Python files can be imported python -m compileall -f . # Run tests with pytest python -m pytest tests/ -v lint: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - name: Set up Python uses: actions/setup-python@v4 with: python-version: '3.9' - name: Install linting tools run: | python -m pip install --upgrade pip pip install flake8 pylint - name: Lint with flake8 run: | # Stop the build if there are Python syntax errors or undefined names flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics # Exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics