|
| 1 | +name: Tests |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + pull_request: |
| 7 | + workflow_dispatch: |
| 8 | + |
| 9 | +# Cancel superseded runs on the same ref (saves CI minutes on rapid pushes). |
| 10 | +concurrency: |
| 11 | + group: tests-${{ github.ref }} |
| 12 | + cancel-in-progress: true |
| 13 | + |
| 14 | +defaults: |
| 15 | + run: |
| 16 | + # The installable project lives in the tsapython/ subdirectory (the one with |
| 17 | + # pyproject.toml, the pytest config, and the `hardware` marker). |
| 18 | + working-directory: tsapython |
| 19 | + |
| 20 | +jobs: |
| 21 | + test: |
| 22 | + name: pytest (${{ matrix.os }}, py${{ matrix.python-version }}) |
| 23 | + runs-on: ${{ matrix.os }} |
| 24 | + strategy: |
| 25 | + fail-fast: false |
| 26 | + matrix: |
| 27 | + # The library is pyserial-based and developed on Windows, lightly |
| 28 | + # tested on Linux -- so both matter; macOS is cheap to include. |
| 29 | + os: [windows-latest, ubuntu-latest, macos-latest] |
| 30 | + python-version: ["3.10", "3.11", "3.12", "3.13"] |
| 31 | + |
| 32 | + steps: |
| 33 | + - uses: actions/checkout@v4 |
| 34 | + |
| 35 | + - name: Install uv |
| 36 | + uses: astral-sh/setup-uv@v5 |
| 37 | + with: |
| 38 | + enable-cache: true |
| 39 | + python-version: ${{ matrix.python-version }} |
| 40 | + |
| 41 | + - name: Sync environment (deps + dev group, editable install) |
| 42 | + run: uv sync |
| 43 | + |
| 44 | + - name: Run test suite (hardware tests deselected) |
| 45 | + run: uv run pytest -m "not hardware" --cov=tsapython --cov-report=xml --cov-report=term-missing |
| 46 | + |
| 47 | + - name: Upload coverage to Codecov |
| 48 | + # Optional: only does anything once the repo is linked at |
| 49 | + # https://codecov.io. Tokenless for public repos. Safe to leave in |
| 50 | + # before linking -- it soft-fails. |
| 51 | + if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.12' |
| 52 | + uses: codecov/codecov-action@v5 |
| 53 | + with: |
| 54 | + files: tsapython/coverage.xml |
| 55 | + fail_ci_if_error: false |
| 56 | + |
| 57 | + lint: |
| 58 | + name: ruff + mypy |
| 59 | + runs-on: ubuntu-latest |
| 60 | + steps: |
| 61 | + - uses: actions/checkout@v4 |
| 62 | + |
| 63 | + - name: Install uv |
| 64 | + uses: astral-sh/setup-uv@v5 |
| 65 | + with: |
| 66 | + enable-cache: true |
| 67 | + python-version: "3.12" |
| 68 | + |
| 69 | + - name: Sync environment |
| 70 | + run: uv sync |
| 71 | + |
| 72 | + - name: Ruff lint |
| 73 | + # Blocking ruleset is E9 + F only (see [tool.ruff.lint] in |
| 74 | + # pyproject.toml); style rules are a planned follow-up cleanup. |
| 75 | + run: uv run ruff check . |
| 76 | + |
| 77 | + - name: Mypy |
| 78 | + # Blocking. The package ships a py.typed marker, which promises |
| 79 | + # downstream type-checkers that these annotations are real; this gate |
| 80 | + # is what keeps that promise true. |
| 81 | + run: uv run mypy |
| 82 | + |
| 83 | + build: |
| 84 | + name: package builds |
| 85 | + runs-on: ubuntu-latest |
| 86 | + steps: |
| 87 | + - uses: actions/checkout@v4 |
| 88 | + |
| 89 | + - name: Install uv |
| 90 | + uses: astral-sh/setup-uv@v5 |
| 91 | + |
| 92 | + - name: Build sdist + wheel |
| 93 | + # Catches packaging breakage on every push instead of at release time. |
| 94 | + # release.yml does the same build when publishing. |
| 95 | + run: uv build |
0 commit comments