|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - main |
| 8 | + pull_request: |
| 9 | + branches: |
| 10 | + - main |
| 11 | + |
| 12 | +concurrency: |
| 13 | + group: pr-${{ github.head_ref || github.sha }} |
| 14 | + cancel-in-progress: true |
| 15 | + |
| 16 | +jobs: |
| 17 | + lint: |
| 18 | + name: Lint (ruff) |
| 19 | + runs-on: ubuntu-latest |
| 20 | + |
| 21 | + steps: |
| 22 | + - uses: actions/checkout@v4 |
| 23 | + |
| 24 | + - name: Set up Python |
| 25 | + uses: actions/setup-python@v5 |
| 26 | + with: |
| 27 | + python-version: "3.10" |
| 28 | + |
| 29 | + - name: Install Poetry |
| 30 | + run: pipx install poetry |
| 31 | + |
| 32 | + - name: Configure Poetry |
| 33 | + run: poetry config virtualenvs.in-project true |
| 34 | + |
| 35 | + - name: Cache virtualenv |
| 36 | + uses: actions/cache@v4 |
| 37 | + with: |
| 38 | + path: .venv |
| 39 | + key: venv-lint-${{ runner.os }}-3.10-${{ hashFiles('poetry.lock') }} |
| 40 | + |
| 41 | + - name: Install dependencies |
| 42 | + run: poetry install --with dev |
| 43 | + |
| 44 | + - name: Run ruff check |
| 45 | + run: poetry run ruff check . |
| 46 | + |
| 47 | + - name: Run ruff format check |
| 48 | + run: poetry run ruff format --check . |
| 49 | + |
| 50 | + typecheck: |
| 51 | + name: Type check (pyright) |
| 52 | + runs-on: ubuntu-latest |
| 53 | + |
| 54 | + steps: |
| 55 | + - uses: actions/checkout@v4 |
| 56 | + |
| 57 | + - name: Set up Python |
| 58 | + uses: actions/setup-python@v5 |
| 59 | + with: |
| 60 | + python-version: "3.10" |
| 61 | + |
| 62 | + - name: Install Poetry |
| 63 | + run: pipx install poetry |
| 64 | + |
| 65 | + - name: Configure Poetry |
| 66 | + run: poetry config virtualenvs.in-project true |
| 67 | + |
| 68 | + - name: Cache virtualenv |
| 69 | + uses: actions/cache@v4 |
| 70 | + with: |
| 71 | + path: .venv |
| 72 | + key: venv-typecheck-${{ runner.os }}-3.10-${{ hashFiles('poetry.lock') }} |
| 73 | + |
| 74 | + - name: Install dependencies |
| 75 | + run: poetry install --with dev |
| 76 | + |
| 77 | + - name: Run pyright |
| 78 | + run: poetry run pyright |
| 79 | + |
| 80 | + build: |
| 81 | + name: Build package |
| 82 | + runs-on: ubuntu-latest |
| 83 | + |
| 84 | + steps: |
| 85 | + - uses: actions/checkout@v4 |
| 86 | + |
| 87 | + - name: Set up Python |
| 88 | + uses: actions/setup-python@v5 |
| 89 | + with: |
| 90 | + python-version: "3.10" |
| 91 | + |
| 92 | + - name: Install Poetry |
| 93 | + run: pipx install poetry |
| 94 | + |
| 95 | + - name: Configure Poetry |
| 96 | + run: poetry config virtualenvs.in-project true |
| 97 | + |
| 98 | + - name: Cache virtualenv |
| 99 | + uses: actions/cache@v4 |
| 100 | + with: |
| 101 | + path: .venv |
| 102 | + key: venv-build-${{ runner.os }}-3.10-${{ hashFiles('poetry.lock') }} |
| 103 | + |
| 104 | + - name: Install dependencies |
| 105 | + run: poetry install --only main |
| 106 | + |
| 107 | + - name: Build package |
| 108 | + run: poetry build |
| 109 | + |
| 110 | + - name: Check package |
| 111 | + run: | |
| 112 | + python -m pip install --upgrade twine |
| 113 | + twine check dist/* |
| 114 | +
|
| 115 | + tests: |
| 116 | + name: Tests (Python ${{ matrix.python-version }}, ${{ matrix.os }}) |
| 117 | + runs-on: ${{ matrix.os }} |
| 118 | + strategy: |
| 119 | + fail-fast: false |
| 120 | + matrix: |
| 121 | + os: [ubuntu-latest, windows-latest, macos-latest] |
| 122 | + python-version: ["3.10", "3.11", "3.12", "3.13"] |
| 123 | + |
| 124 | + steps: |
| 125 | + - uses: actions/checkout@v4 |
| 126 | + |
| 127 | + - name: Set up Python |
| 128 | + uses: actions/setup-python@v5 |
| 129 | + with: |
| 130 | + python-version: ${{ matrix.python-version }} |
| 131 | + |
| 132 | + - name: Install Poetry |
| 133 | + run: pipx install poetry |
| 134 | + |
| 135 | + - name: Configure Poetry |
| 136 | + run: poetry config virtualenvs.in-project true |
| 137 | + |
| 138 | + - name: Cache virtualenv |
| 139 | + uses: actions/cache@v4 |
| 140 | + with: |
| 141 | + path: .venv |
| 142 | + key: venv-tests-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('poetry.lock') }} |
| 143 | + |
| 144 | + - name: Install dependencies |
| 145 | + run: poetry install |
| 146 | + |
| 147 | + - name: Run unit tests |
| 148 | + run: poetry run pytest tests/ -v |
0 commit comments