|
| 1 | +name: Python - Code Quality |
| 2 | +on: |
| 3 | + merge_group: |
| 4 | + workflow_dispatch: |
| 5 | + pull_request: |
| 6 | + branches: ["main"] |
| 7 | + paths: |
| 8 | + - "python/**" |
| 9 | + - "!python/AGENTS.md" |
| 10 | + - "!python/**/AGENTS.md" |
| 11 | + - "!python/.github/skills/*" |
| 12 | + - "!python/.github/skills/**" |
| 13 | + |
| 14 | +env: |
| 15 | + # Configure a constant location for the uv cache |
| 16 | + UV_CACHE_DIR: /tmp/.uv-cache |
| 17 | + |
| 18 | +jobs: |
| 19 | + pre-commit-hooks: |
| 20 | + name: Pre-commit Hooks |
| 21 | + if: "!cancelled()" |
| 22 | + strategy: |
| 23 | + fail-fast: false |
| 24 | + matrix: |
| 25 | + python-version: ["3.11"] |
| 26 | + runs-on: ubuntu-latest |
| 27 | + continue-on-error: true |
| 28 | + defaults: |
| 29 | + run: |
| 30 | + working-directory: ./python |
| 31 | + env: |
| 32 | + UV_PYTHON: ${{ matrix.python-version }} |
| 33 | + steps: |
| 34 | + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 35 | + with: |
| 36 | + fetch-depth: 0 |
| 37 | + - name: Set up python and install the project |
| 38 | + id: python-setup |
| 39 | + uses: ./.github/actions/python-setup |
| 40 | + with: |
| 41 | + python-version: ${{ matrix.python-version }} |
| 42 | + os: ${{ runner.os }} |
| 43 | + env: |
| 44 | + UV_CACHE_DIR: /tmp/.uv-cache |
| 45 | + - uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 |
| 46 | + with: |
| 47 | + path: ~/.cache/prek |
| 48 | + key: prek|${{ matrix.python-version }}|${{ hashFiles('python/.pre-commit-config.yaml') }} |
| 49 | + - uses: j178/prek-action@bdca6f102f98e2b4c7029491a53dfd366469e33d # v2.0.4 |
| 50 | + name: Run Pre-commit Hooks (excluding poe-check) |
| 51 | + env: |
| 52 | + SKIP: poe-check |
| 53 | + with: |
| 54 | + extra-args: --cd python --all-files |
| 55 | + |
| 56 | + package-checks: |
| 57 | + name: Package Checks |
| 58 | + if: "!cancelled()" |
| 59 | + strategy: |
| 60 | + fail-fast: false |
| 61 | + matrix: |
| 62 | + python-version: ["3.11"] |
| 63 | + runs-on: ubuntu-latest |
| 64 | + continue-on-error: true |
| 65 | + defaults: |
| 66 | + run: |
| 67 | + working-directory: ./python |
| 68 | + env: |
| 69 | + UV_PYTHON: ${{ matrix.python-version }} |
| 70 | + steps: |
| 71 | + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 72 | + with: |
| 73 | + fetch-depth: 0 |
| 74 | + - name: Set up python and install the project |
| 75 | + id: python-setup |
| 76 | + uses: ./.github/actions/python-setup |
| 77 | + with: |
| 78 | + python-version: ${{ matrix.python-version }} |
| 79 | + os: ${{ runner.os }} |
| 80 | + env: |
| 81 | + UV_CACHE_DIR: /tmp/.uv-cache |
| 82 | + - name: Run syntax and pyright across packages |
| 83 | + run: uv run poe check-packages |
| 84 | + |
| 85 | + dependency-bounds: |
| 86 | + name: Dependency Bounds |
| 87 | + if: "!cancelled()" |
| 88 | + runs-on: ubuntu-latest |
| 89 | + env: |
| 90 | + UV_PYTHON: "3.13" |
| 91 | + BASE_REF: ${{ github.event.pull_request.base.sha || github.event.merge_group.base_sha || 'origin/main' }} |
| 92 | + steps: |
| 93 | + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 |
| 94 | + with: |
| 95 | + fetch-depth: 0 |
| 96 | + - name: Detect package metadata changes |
| 97 | + id: package-metadata |
| 98 | + shell: bash |
| 99 | + run: | |
| 100 | + if git diff --quiet "${BASE_REF}" HEAD -- 'python/pyproject.toml' 'python/packages/*/pyproject.toml'; then |
| 101 | + echo "changed=false" >> "${GITHUB_OUTPUT}" |
| 102 | + else |
| 103 | + echo "changed=true" >> "${GITHUB_OUTPUT}" |
| 104 | + fi |
| 105 | + - name: Set up python and install the project |
| 106 | + if: steps.package-metadata.outputs.changed == 'true' |
| 107 | + uses: ./.github/actions/python-setup |
| 108 | + with: |
| 109 | + python-version: ${{ env.UV_PYTHON }} |
| 110 | + os: ${{ runner.os }} |
| 111 | + env: |
| 112 | + UV_CACHE_DIR: /tmp/.uv-cache |
| 113 | + - name: Validate dependency bounds for changed packages |
| 114 | + if: steps.package-metadata.outputs.changed == 'true' |
| 115 | + run: uv run poe validate-python-release --base-ref "${BASE_REF}" |
| 116 | + working-directory: ./python |
| 117 | + |
| 118 | + samples-markdown: |
| 119 | + name: Samples & Markdown |
| 120 | + if: "!cancelled()" |
| 121 | + strategy: |
| 122 | + fail-fast: false |
| 123 | + matrix: |
| 124 | + python-version: ["3.11"] |
| 125 | + runs-on: ubuntu-latest |
| 126 | + continue-on-error: true |
| 127 | + defaults: |
| 128 | + run: |
| 129 | + working-directory: ./python |
| 130 | + env: |
| 131 | + UV_PYTHON: ${{ matrix.python-version }} |
| 132 | + steps: |
| 133 | + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 134 | + with: |
| 135 | + fetch-depth: 0 |
| 136 | + - name: Set up python and install the project |
| 137 | + id: python-setup |
| 138 | + uses: ./.github/actions/python-setup |
| 139 | + with: |
| 140 | + python-version: ${{ matrix.python-version }} |
| 141 | + os: ${{ runner.os }} |
| 142 | + env: |
| 143 | + UV_CACHE_DIR: /tmp/.uv-cache |
| 144 | + - name: Run samples checks |
| 145 | + run: uv run poe check -S |
| 146 | + - name: Run markdown code lint |
| 147 | + run: uv run poe markdown-code-lint |
| 148 | + |
| 149 | + test-typing: |
| 150 | + name: Test Typing Checks |
| 151 | + if: "!cancelled()" |
| 152 | + strategy: |
| 153 | + fail-fast: false |
| 154 | + matrix: |
| 155 | + python-version: ["3.11"] |
| 156 | + runs-on: ubuntu-latest |
| 157 | + continue-on-error: true |
| 158 | + defaults: |
| 159 | + run: |
| 160 | + working-directory: ./python |
| 161 | + env: |
| 162 | + UV_PYTHON: ${{ matrix.python-version }} |
| 163 | + steps: |
| 164 | + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 165 | + with: |
| 166 | + fetch-depth: 0 |
| 167 | + - name: Set up python and install the project |
| 168 | + id: python-setup |
| 169 | + uses: ./.github/actions/python-setup |
| 170 | + with: |
| 171 | + python-version: ${{ matrix.python-version }} |
| 172 | + os: ${{ runner.os }} |
| 173 | + env: |
| 174 | + UV_CACHE_DIR: /tmp/.uv-cache |
| 175 | + - name: Run tests/samples type checkers (mypy, pyrefly, ty) |
| 176 | + run: uv run python scripts/workspace_poe_tasks.py ci-test-typing |
0 commit comments