python tests #34
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: python tests | |
| run-name: python tests | |
| permissions: | |
| contents: read | |
| on: | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - '**.py' | |
| - 'pyproject.toml' | |
| - 'uv.lock' | |
| - '.github/workflows/python-tests.yaml' | |
| pull_request: | |
| paths: | |
| - '**.py' | |
| - 'pyproject.toml' | |
| - 'uv.lock' | |
| - '.github/workflows/python-tests.yaml' | |
| workflow_dispatch: | |
| jobs: | |
| lint: | |
| name: Lint and Type Check | |
| if: > | |
| !( | |
| contains(github.event.head_commit.message || '', '[skip tests]') || | |
| contains(github.event.pull_request.title || '', '[skip tests]') || | |
| contains(github.event.pull_request.body || '', '[skip tests]') | |
| ) | |
| runs-on: ubuntu-latest | |
| env: | |
| UV_CACHE_DIR: /tmp/.uv-cache | |
| UV_LINK_MODE: copy | |
| PYTHON_VERSION: 3.14 | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v7 | |
| - name: Set up Python | |
| uses: actions/setup-python@v6.2.0 | |
| with: | |
| python-version: ${{ env.PYTHON_VERSION }} | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v7 | |
| - name: Restore uv cache | |
| uses: actions/cache@v5.0.5 | |
| with: | |
| path: ${{ env.UV_CACHE_DIR }} | |
| key: uv-${{ runner.os }}-python${{ env.PYTHON_VERSION }}-${{ hashFiles('uv.lock') }} | |
| restore-keys: | | |
| uv-${{ runner.os }}-python${{ env.PYTHON_VERSION }}- | |
| - name: Lint check | |
| run: uv run --locked --extra dev ruff check | |
| - name: Type check | |
| run: uv run --locked --extra dev pyrefly check | |
| test: | |
| name: Test with Python ${{ matrix.python-version }} | |
| needs: lint | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| python-version: | |
| - "3.10" | |
| - "3.11" | |
| - "3.12" | |
| - "3.13" | |
| - "3.14" | |
| env: | |
| UV_CACHE_DIR: /tmp/.uv-cache | |
| UV_LINK_MODE: copy | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v7 | |
| - name: Set up Python | |
| uses: actions/setup-python@v6.2.0 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v7 | |
| - name: Restore uv cache | |
| uses: actions/cache@v5.0.5 | |
| with: | |
| path: ${{ env.UV_CACHE_DIR }} | |
| key: uv-${{ runner.os }}-python${{ matrix.python-version }}-${{ hashFiles('uv.lock') }} | |
| restore-keys: | | |
| uv-${{ runner.os }}-python${{ matrix.python-version }}- | |
| uv-${{ runner.os }}- | |
| - name: Run tests | |
| run: uv run --locked --extra dev pytest |