|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [master, main] |
| 6 | + pull_request: |
| 7 | + branches: [master, main] |
| 8 | + |
| 9 | +defaults: |
| 10 | + run: |
| 11 | + shell: bash |
| 12 | + |
| 13 | +env: |
| 14 | + LANG: "en_US.utf-8" |
| 15 | + LC_ALL: "en_US.utf-8" |
| 16 | + PYTHONIOENCODING: "UTF-8" |
| 17 | + |
| 18 | +jobs: |
| 19 | + lint: |
| 20 | + runs-on: ubuntu-latest |
| 21 | + steps: |
| 22 | + - name: Checkout |
| 23 | + uses: actions/checkout@v4 |
| 24 | + |
| 25 | + - name: Setup Python |
| 26 | + uses: actions/setup-python@v5 |
| 27 | + with: |
| 28 | + python-version: "3.14" |
| 29 | + |
| 30 | + - name: Setup uv |
| 31 | + uses: astral-sh/setup-uv@v4 |
| 32 | + |
| 33 | + - name: Install dependencies |
| 34 | + run: uv sync --all-extras |
| 35 | + |
| 36 | + - name: Run ruff lint |
| 37 | + run: uv run ruff check src/ tests/ |
| 38 | + |
| 39 | + - name: Run ruff format check |
| 40 | + run: uv run ruff format --check src/ tests/ |
| 41 | + |
| 42 | + typecheck: |
| 43 | + runs-on: ubuntu-latest |
| 44 | + steps: |
| 45 | + - name: Checkout |
| 46 | + uses: actions/checkout@v4 |
| 47 | + |
| 48 | + - name: Setup Python |
| 49 | + uses: actions/setup-python@v5 |
| 50 | + with: |
| 51 | + python-version: "3.14" |
| 52 | + |
| 53 | + - name: Setup uv |
| 54 | + uses: astral-sh/setup-uv@v4 |
| 55 | + |
| 56 | + - name: Install dependencies |
| 57 | + run: uv sync --all-extras |
| 58 | + |
| 59 | + - name: Run mypy |
| 60 | + run: uv run mypy src/ |
| 61 | + |
| 62 | + test: |
| 63 | + strategy: |
| 64 | + matrix: |
| 65 | + python-version: ["3.11", "3.12", "3.13", "3.14"] |
| 66 | + os: [ubuntu-latest, windows-latest, macos-latest] |
| 67 | + fail-fast: false |
| 68 | + |
| 69 | + runs-on: ${{ matrix.os }} |
| 70 | + |
| 71 | + steps: |
| 72 | + - name: Checkout |
| 73 | + uses: actions/checkout@v4 |
| 74 | + |
| 75 | + - name: Setup Python |
| 76 | + uses: actions/setup-python@v5 |
| 77 | + with: |
| 78 | + python-version: ${{ matrix.python-version }} |
| 79 | + allow-prereleases: true |
| 80 | + |
| 81 | + - name: Setup uv |
| 82 | + uses: astral-sh/setup-uv@v4 |
| 83 | + with: |
| 84 | + enable-cache: true |
| 85 | + |
| 86 | + - name: Install dependencies |
| 87 | + run: uv sync --all-extras |
| 88 | + |
| 89 | + - name: Run tests |
| 90 | + run: uv run pytest tests/ -v --tb=short |
| 91 | + |
| 92 | + - name: Run tests with coverage |
| 93 | + if: matrix.python-version == '3.14' && matrix.os == 'ubuntu-latest' |
| 94 | + run: uv run pytest tests/ --cov=src/autocode_mcp --cov-report=xml --cov-report=term |
| 95 | + |
| 96 | + - name: Upload coverage |
| 97 | + if: matrix.python-version == '3.14' && matrix.os == 'ubuntu-latest' |
| 98 | + uses: codecov/codecov-action@v4 |
| 99 | + with: |
| 100 | + files: ./coverage.xml |
| 101 | + fail_ci_if_error: false |
| 102 | + |
| 103 | + # 所有检查通过后的综合状态 |
| 104 | + ci: |
| 105 | + needs: [lint, typecheck, test] |
| 106 | + runs-on: ubuntu-latest |
| 107 | + steps: |
| 108 | + - name: CI passed |
| 109 | + run: echo "All CI checks passed!" |
0 commit comments