|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: ["main", "master"] |
| 6 | + pull_request: |
| 7 | + branches: ["main", "master"] |
| 8 | + |
| 9 | +permissions: |
| 10 | + contents: read |
| 11 | + |
| 12 | +jobs: |
| 13 | + lint: |
| 14 | + name: Lint (Non-blocking) |
| 15 | + runs-on: ubuntu-latest |
| 16 | + continue-on-error: true # 不阻塞工作流 |
| 17 | + steps: |
| 18 | + - name: Checkout |
| 19 | + uses: actions/checkout@v4 |
| 20 | + |
| 21 | + - name: Set up Python |
| 22 | + uses: actions/setup-python@v5 |
| 23 | + with: |
| 24 | + python-version: "3.12" |
| 25 | + cache: pip |
| 26 | + cache-dependency-path: | |
| 27 | + pyproject.toml |
| 28 | + setup.py |
| 29 | +
|
| 30 | + - name: Install dependencies |
| 31 | + run: | |
| 32 | + python -m pip install --upgrade pip |
| 33 | + python -m pip install -e ".[dev]" |
| 34 | +
|
| 35 | + - name: Ruff |
| 36 | + id: ruff |
| 37 | + run: | |
| 38 | + echo "Running ruff check..." |
| 39 | + if ruff check . --output-format=github; then |
| 40 | + echo "ruff_status=passed" >> $GITHUB_OUTPUT |
| 41 | + echo "Ruff check passed" |
| 42 | + else |
| 43 | + echo "ruff_status=failed" >> $GITHUB_OUTPUT |
| 44 | + echo "::warning::Ruff found code style issues (non-blocking)" |
| 45 | + fi |
| 46 | +
|
| 47 | + - name: Mypy |
| 48 | + id: mypy |
| 49 | + run: | |
| 50 | + echo "Running mypy..." |
| 51 | + if python -m mypy ripperdoc_agent_sdk --show-error-codes; then |
| 52 | + echo "mypy_status=passed" >> $GITHUB_OUTPUT |
| 53 | + echo "Mypy check passed" |
| 54 | + else |
| 55 | + echo "mypy_status=failed" >> $GITHUB_OUTPUT |
| 56 | + echo "::warning::Mypy found type issues (non-blocking)" |
| 57 | + fi |
| 58 | +
|
| 59 | + - name: Lint Summary |
| 60 | + if: always() |
| 61 | + run: | |
| 62 | + echo "=== Lint Check Summary ===" |
| 63 | + echo "Ruff: ${{ steps.ruff.outputs.ruff_status || 'unknown' }}" |
| 64 | + echo "Mypy: ${{ steps.mypy.outputs.mypy_status || 'unknown' }}" |
| 65 | + echo "=========================" |
| 66 | + echo "Note: Lint checks are non-blocking. Focus on test results." |
| 67 | +
|
| 68 | + tests: |
| 69 | + name: Tests - Primary Check (Python ${{ matrix.python-version }}) |
| 70 | + runs-on: ubuntu-latest |
| 71 | + strategy: |
| 72 | + fail-fast: false |
| 73 | + matrix: |
| 74 | + python-version: ["3.10", "3.11", "3.12"] |
| 75 | + steps: |
| 76 | + - name: Checkout |
| 77 | + uses: actions/checkout@v4 |
| 78 | + |
| 79 | + - name: Set up Python |
| 80 | + uses: actions/setup-python@v5 |
| 81 | + with: |
| 82 | + python-version: ${{ matrix.python-version }} |
| 83 | + cache: pip |
| 84 | + cache-dependency-path: | |
| 85 | + pyproject.toml |
| 86 | + setup.py |
| 87 | +
|
| 88 | + - name: Install dependencies |
| 89 | + run: | |
| 90 | + python -m pip install --upgrade pip |
| 91 | + python -m pip install -e ".[dev]" |
| 92 | +
|
| 93 | + - name: Pytest |
| 94 | + id: pytest |
| 95 | + run: | |
| 96 | + echo "Running tests..." |
| 97 | + if pytest; then |
| 98 | + echo "pytest_status=passed" >> $GITHUB_OUTPUT |
| 99 | + echo "Tests passed" |
| 100 | + else |
| 101 | + echo "pytest_status=failed" >> $GITHUB_OUTPUT |
| 102 | + echo "::error::Tests failed" |
| 103 | + exit 1 |
| 104 | + fi |
| 105 | +
|
| 106 | + - name: Test Summary |
| 107 | + if: always() |
| 108 | + run: | |
| 109 | + echo "=== Test Results Summary ===" |
| 110 | + echo "Python ${{ matrix.python-version }}: ${{ steps.pytest.outputs.pytest_status || 'unknown' }}" |
| 111 | + echo "============================" |
| 112 | +
|
| 113 | + summary: |
| 114 | + name: Workflow Summary |
| 115 | + runs-on: ubuntu-latest |
| 116 | + needs: [lint, tests] |
| 117 | + if: always() |
| 118 | + steps: |
| 119 | + - name: Display Summary |
| 120 | + run: | |
| 121 | + echo "=== CI Workflow Summary ===" |
| 122 | + echo "" |
| 123 | + echo "Lint Checks (Non-blocking):" |
| 124 | + echo " - Ruff: ${{ needs.lint.result || 'skipped' }}" |
| 125 | + echo " - Mypy: ${{ needs.lint.result || 'skipped' }}" |
| 126 | + echo "" |
| 127 | + echo "Test Results (Primary Check):" |
| 128 | + echo " - Python 3.10: ${{ needs.tests.result == 'success' && 'passed' || 'failed' }}" |
| 129 | + echo " - Python 3.11: ${{ needs.tests.result == 'success' && 'passed' || 'failed' }}" |
| 130 | + echo " - Python 3.12: ${{ needs.tests.result == 'success' && 'passed' || 'failed' }}" |
| 131 | + echo "" |
| 132 | + echo "=== Final Status ===" |
| 133 | + echo "Workflow ${{ github.event_name == 'pull_request' && 'PR check' || 'Push check' }}: ${{ needs.tests.result == 'success' && 'PASSED' || 'FAILED' }}" |
| 134 | + echo "====================" |
| 135 | + echo "" |
| 136 | + echo "Note: Lint checks (ruff/mypy) are informational only." |
| 137 | + echo "Test results determine workflow success." |
0 commit comments