| 1 |
name: CI |
| 2 |
|
| 3 |
on: |
| 4 |
push: |
| 5 |
branches: |
| 6 |
- main |
| 7 |
tags: |
| 8 |
- '**' |
| 9 |
pull_request: |
| 10 |
|
| 11 |
permissions: |
| 12 |
contents: read |
| 13 |
|
| 14 |
env: |
| 15 |
FORCE_COLOR: 1 |
| 16 |
|
| 17 |
jobs: |
| 18 |
lint: |
| 19 |
runs-on: ubuntu-latest |
| 20 |
continue-on-error: true |
| 21 |
|
| 22 |
steps: |
| 23 |
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 24 |
with: |
| 25 |
persist-credentials: false |
| 26 |
|
| 27 |
- uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 # v9.0.0 |
| 28 |
with: |
| 29 |
python-version: '3.14' |
| 30 |
enable-cache: true # zizmor: ignore[cache-poisoning] -- Job does not produce release artifacts and does not have sensitive permissions |
| 31 |
|
| 32 |
- name: Install dependencies |
| 33 |
# Install pip for pre-commit |
| 34 |
run: | |
| 35 |
uv sync --group lint |
| 36 |
uv pip install pip |
| 37 |
|
| 38 |
- name: Run Ruff formatter |
| 39 |
run: make format-diff |
| 40 |
|
| 41 |
- name: Run Ruff linter |
| 42 |
run: make lint-github |
| 43 |
|
| 44 |
- name: Run Pyright |
| 45 |
run: make typecheck |
| 46 |
|
| 47 |
- name: Run pre-commit |
| 48 |
uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1 |
| 49 |
with: |
| 50 |
extra_args: --all-files --verbose |
| 51 |
env: |
| 52 |
# https://pre-commit.com/#temporarily-disabling-hooks: |
| 53 |
SKIP: no-commit-to-branch |
| 54 |
UV_NO_PROGRESS: '1' |
| 55 |
|
| 56 |
test: |
| 57 |
name: Run tests |
| 58 |
strategy: |
| 59 |
fail-fast: false |
| 60 |
matrix: |
| 61 |
python-version: ['3.10', '3.11', '3.12', '3.13', '3.14', '3.15'] |
| 62 |
os: [ubuntu-latest, macos-latest, windows-latest] |
| 63 |
|
| 64 |
runs-on: ${{ matrix.os }} |
| 65 |
|
| 66 |
steps: |
| 67 |
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 68 |
with: |
| 69 |
persist-credentials: false |
| 70 |
|
| 71 |
- uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 # v9.0.0 |
| 72 |
with: |
| 73 |
python-version: ${{ matrix.python-version }} |
| 74 |
enable-cache: true # zizmor: ignore[cache-poisoning] -- Job does not produce release artifacts and does not have sensitive permissions |
| 75 |
|
| 76 |
- name: Install dependencies |
| 77 |
run: uv sync --group tests |
| 78 |
- name: Run tests |
| 79 |
run: make test |
| 80 |
env: |
| 81 |
COVERAGE_FILE: coverage/.coverage.${{ runner.os }}-py${{ matrix.python-version }} |
| 82 |
|
| 83 |
- name: Store coverage files |
| 84 |
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 |
| 85 |
with: |
| 86 |
name: coverage-${{ matrix.os }}-${{ matrix.python-version }} |
| 87 |
path: coverage |
| 88 |
include-hidden-files: true |
| 89 |
|
| 90 |
test-typing-extensions: |
| 91 |
name: Run test on typing-extensions |
| 92 |
runs-on: ubuntu-latest |
| 93 |
strategy: |
| 94 |
fail-fast: false |
| 95 |
matrix: |
| 96 |
typing-extensions: [main, lowest] |
| 97 |
python-version: ['3.10', '3.11', '3.12', '3.13', '3.14', '3.15'] |
| 98 |
|
| 99 |
steps: |
| 100 |
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 101 |
with: |
| 102 |
persist-credentials: false |
| 103 |
|
| 104 |
- uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 # v9.0.0 |
| 105 |
with: |
| 106 |
python-version: ${{ matrix.python-version }} |
| 107 |
enable-cache: true # zizmor: ignore[cache-poisoning] -- Job does not produce release artifacts and does not have sensitive permissions |
| 108 |
|
| 109 |
- name: Install dependencies and typing-extensions main |
| 110 |
run: | |
| 111 |
uv sync --group tests |
| 112 |
uv pip install 'typing-extensions @ git+https://github.com/python/typing_extensions.git' |
| 113 |
if: matrix.typing-extensions == 'main' |
| 114 |
|
| 115 |
- name: Install lowest dependencies |
| 116 |
run: uv sync --group tests --resolution lowest-direct |
| 117 |
if: matrix.typing-extensions == 'lowest' |
| 118 |
|
| 119 |
- name: Run tests |
| 120 |
run: make test |
| 121 |
|
| 122 |
docs: |
| 123 |
name: Build and check documentation |
| 124 |
runs-on: ubuntu-latest |
| 125 |
|
| 126 |
steps: |
| 127 |
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 128 |
with: |
| 129 |
persist-credentials: false |
| 130 |
|
| 131 |
- uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 # v9.0.0 |
| 132 |
with: |
| 133 |
python-version: '3.13' |
| 134 |
enable-cache: true # zizmor: ignore[cache-poisoning] -- Job does not produce release artifacts and does not have sensitive permissions |
| 135 |
|
| 136 |
- name: Install dependencies |
| 137 |
run: uv sync --group docs |
| 138 |
|
| 139 |
- run: uv run mkdocs build |
| 140 |
|
| 141 |
coverage-combine: |
| 142 |
needs: test |
| 143 |
runs-on: ubuntu-latest |
| 144 |
|
| 145 |
steps: |
| 146 |
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 147 |
with: |
| 148 |
persist-credentials: false |
| 149 |
|
| 150 |
- uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 # v9.0.0 |
| 151 |
with: |
| 152 |
python-version: '3.14' |
| 153 |
enable-cache: true # zizmor: ignore[cache-poisoning] -- Job does not produce release artifacts and does not have sensitive permissions |
| 154 |
|
| 155 |
- name: Install dependencies |
| 156 |
run: uv sync --no-install-project --only-group tests |
| 157 |
|
| 158 |
- name: Get coverage files |
| 159 |
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 |
| 160 |
with: |
| 161 |
merge-multiple: true |
| 162 |
pattern: coverage-* |
| 163 |
path: coverage |
| 164 |
|
| 165 |
- run: | |
| 166 |
ls -la coverage/ |
| 167 |
uv run coverage combine coverage/ |
| 168 |
uv run coverage report |
| 169 |
uv run coverage html --show-contexts --title "typing-inspection coverage for ${{ github.sha }}" |
| 170 |
env: |
| 171 |
UV_NO_SYNC: '1' |
| 172 |
|
| 173 |
- name: Store coverage data |
| 174 |
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 |
| 175 |
with: |
| 176 |
name: coverage-data |
| 177 |
path: .coverage |
| 178 |
include-hidden-files: true |
| 179 |
|
| 180 |
- name: Store coverage HTML |
| 181 |
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 |
| 182 |
with: |
| 183 |
name: coverage-html |
| 184 |
path: htmlcov |
| 185 |
|
| 186 |
coverage-pr-comment: |
| 187 |
needs: coverage-combine |
| 188 |
runs-on: ubuntu-latest |
| 189 |
if: github.event_name == 'pull_request' |
| 190 |
permissions: |
| 191 |
pull-requests: write |
| 192 |
contents: write |
| 193 |
|
| 194 |
steps: |
| 195 |
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 196 |
with: |
| 197 |
persist-credentials: false |
| 198 |
|
| 199 |
- name: Download coverage data |
| 200 |
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 |
| 201 |
with: |
| 202 |
name: coverage-data |
| 203 |
|
| 204 |
- name: Generate coverage comment |
| 205 |
id: coverage-comment |
| 206 |
uses: py-cov-action/python-coverage-comment-action@5d8df5979747514c914e1c5a12335a7cf9a2745f # v4.1 |
| 207 |
with: |
| 208 |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 209 |
|
| 210 |
- name: Store coverage comment |
| 211 |
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 |
| 212 |
if: steps.coverage-comment.outputs.COMMENT_FILE_WRITTEN == 'true' |
| 213 |
with: |
| 214 |
name: python-coverage-comment-action |
| 215 |
path: python-coverage-comment-action.txt |
| 216 |
|
| 217 |
check: |
| 218 |
if: always() |
| 219 |
outputs: |
| 220 |
result: ${{ steps.all-green.outputs.result }} |
| 221 |
needs: |
| 222 |
- lint |
| 223 |
- test |
| 224 |
- docs |
| 225 |
- test-typing-extensions |
| 226 |
- coverage-combine |
| 227 |
runs-on: ubuntu-latest |
| 228 |
steps: |
| 229 |
- name: Decide whether the needed jobs succeeded or failed |
| 230 |
uses: re-actors/alls-green@05ac9388f0aebcb5727afa17fcccfecd6f8ec5fe # v1.2.2 |
| 231 |
id: all-green |
| 232 |
with: |
| 233 |
jobs: ${{ toJSON(needs) }} |
| 234 |
|
| 235 |
release: |
| 236 |
needs: check |
| 237 |
if: needs.check.outputs.result == 'success' && startsWith(github.ref, 'refs/tags/') |
| 238 |
runs-on: ubuntu-latest |
| 239 |
environment: release |
| 240 |
|
| 241 |
permissions: |
| 242 |
id-token: write |
| 243 |
|
| 244 |
steps: |
| 245 |
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 246 |
with: |
| 247 |
persist-credentials: false |
| 248 |
|
| 249 |
- uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 # v9.0.0 |
| 250 |
with: |
| 251 |
python-version: '3.14' |
| 252 |
enable-cache: false |
| 253 |
|
| 254 |
- run: uv sync --no-install-project --only-group build |
| 255 |
|
| 256 |
- name: Check version |
| 257 |
uses: samuelcolvin/check-python-version@ee87cddb8049d2694cc03badc8569765a05cef00 # v5 |
| 258 |
with: |
| 259 |
version_file_path: pyproject.toml |
| 260 |
|
| 261 |
- name: Build library |
| 262 |
run: uv run --no-sync python -m build |
| 263 |
|
| 264 |
- name: Upload package to PyPI |
| 265 |
uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # v1.14.2 |