| 1 |
name: CI |
| 2 |
|
| 3 |
on: |
| 4 |
push: |
| 5 |
branches: |
| 6 |
- main |
| 7 |
pull_request: |
| 8 |
|
| 9 |
concurrency: |
| 10 |
group: ${{ github.head_ref || github.run_id }} |
| 11 |
cancel-in-progress: true |
| 12 |
|
| 13 |
jobs: |
| 14 |
lint: |
| 15 |
runs-on: ubuntu-latest |
| 16 |
steps: |
| 17 |
- uses: actions/checkout@v6 |
| 18 |
- uses: actions/setup-python@v6 |
| 19 |
with: |
| 20 |
python-version: "3.11" |
| 21 |
- uses: pre-commit/[email protected] |
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
commitlint: |
| 26 |
name: Lint Commit Messages |
| 27 |
runs-on: ubuntu-latest |
| 28 |
steps: |
| 29 |
- uses: actions/checkout@v6 |
| 30 |
with: |
| 31 |
fetch-depth: 0 |
| 32 |
- uses: wagoid/[email protected] |
| 33 |
|
| 34 |
test: |
| 35 |
strategy: |
| 36 |
fail-fast: false |
| 37 |
matrix: |
| 38 |
python-version: |
| 39 |
- "3.11" |
| 40 |
- "3.12" |
| 41 |
- "3.13" |
| 42 |
- "3.14" |
| 43 |
- "3.14t" |
| 44 |
|
| 45 |
os: |
| 46 |
- ubuntu-latest |
| 47 |
- macOS-latest |
| 48 |
extension: |
| 49 |
- "skip_extension" |
| 50 |
- "use_extension" |
| 51 |
include: |
| 52 |
- python-version: "3.13" |
| 53 |
os: windows-latest |
| 54 |
extension: "skip_extension" |
| 55 |
- python-version: "3.13" |
| 56 |
os: windows-latest |
| 57 |
extension: "use_extension" |
| 58 |
runs-on: ${{ matrix.os }} |
| 59 |
env: |
| 60 |
POETRY_VIRTUALENVS_IN_PROJECT: "true" |
| 61 |
steps: |
| 62 |
- uses: actions/checkout@v6 |
| 63 |
- name: Set up uv |
| 64 |
id: setup-uv |
| 65 |
uses: astral-sh/[email protected] |
| 66 |
with: |
| 67 |
enable-cache: true |
| 68 |
python-version: ${{ matrix.python-version }} |
| 69 |
- name: Install poetry |
| 70 |
run: uv tool install poetry |
| 71 |
- name: Cache poetry virtualenv |
| 72 |
uses: actions/cache@v4 |
| 73 |
with: |
| 74 |
path: .venv |
| 75 |
key: poetry-${{ runner.os }}-${{ steps.setup-uv.outputs.python-version }}-${{ matrix.extension }}-${{ hashFiles('poetry.lock') }} |
| 76 |
- name: Install Dependencies |
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
run: | |
| 81 |
pip install --no-cache -v -e . |
| 82 |
poetry install --only=main,dev |
| 83 |
shell: bash |
| 84 |
env: |
| 85 |
REQUIRE_EXTENSION: ${{ matrix.extension == 'use_extension' }} |
| 86 |
SKIP_EXTENSION: ${{ matrix.extension == 'skip_extension' }} |
| 87 |
- name: Test with Pytest |
| 88 |
run: poetry run pytest -v -Wdefault --cov=ulid_transform --cov-report=term-missing:skip-covered --cov-report=xml tests |
| 89 |
shell: bash |
| 90 |
env: |
| 91 |
REQUIRE_EXTENSION: ${{ matrix.extension == 'use_extension' }} |
| 92 |
- name: Upload coverage to Codecov |
| 93 |
uses: codecov/codecov-action@v6 |
| 94 |
with: |
| 95 |
token: ${{ secrets.CODECOV_TOKEN }} |
| 96 |
|
| 97 |
test32bit: |
| 98 |
name: "Test on 32-bit Alpine Linux" |
| 99 |
runs-on: ubuntu-latest |
| 100 |
steps: |
| 101 |
- uses: actions/checkout@v6 |
| 102 |
- name: Setup Alpine Linux v3.22 for x86 |
| 103 |
id: setup-alpine |
| 104 |
continue-on-error: true |
| 105 |
uses: jirutka/setup-alpine@v1 |
| 106 |
with: |
| 107 |
arch: x86 |
| 108 |
branch: v3.22 |
| 109 |
- name: Retry Setup Alpine Linux v3.22 for x86 |
| 110 |
if: steps.setup-alpine.outcome == 'failure' |
| 111 |
uses: jirutka/setup-alpine@v1 |
| 112 |
with: |
| 113 |
arch: x86 |
| 114 |
branch: v3.22 |
| 115 |
- name: Set up Python |
| 116 |
run: | |
| 117 |
apk add gcc g++ musl-dev python3-dev py3-pip poetry libffi-dev |
| 118 |
shell: alpine.sh --root {0} |
| 119 |
- name: Install Dependencies |
| 120 |
run: | |
| 121 |
REQUIRE_EXTENSION=1 poetry -vvv install --only=main,dev |
| 122 |
shell: alpine.sh --root {0} |
| 123 |
- name: Test with Pytest |
| 124 |
run: poetry run pytest -v -Wdefault --cov=ulid_transform --cov-report=term-missing:skip-covered --cov-report=xml tests |
| 125 |
shell: alpine.sh --root {0} |
| 126 |
|
| 127 |
sdist_safe_path: |
| 128 |
name: "sdist install under PYTHONSAFEPATH" |
| 129 |
runs-on: ubuntu-latest |
| 130 |
steps: |
| 131 |
- uses: actions/checkout@v6 |
| 132 |
- name: Set up Python |
| 133 |
uses: actions/setup-python@v6 |
| 134 |
with: |
| 135 |
python-version: "3.13" |
| 136 |
- name: Build sdist |
| 137 |
run: | |
| 138 |
pip install poetry |
| 139 |
poetry build -f sdist |
| 140 |
shell: bash |
| 141 |
- name: Install sdist under PYTHONSAFEPATH (regression guard for |
| 142 |
run: | |
| 143 |
PYTHONSAFEPATH=1 REQUIRE_EXTENSION=1 pip install -v dist/*.tar.gz |
| 144 |
shell: bash |
| 145 |
- name: Verify the C extension imports |
| 146 |
run: | |
| 147 |
PYTHONSAFEPATH=1 python -c "import ulid_transform._ulid_impl; from ulid_transform import ulid_now; print(ulid_now())" |
| 148 |
shell: bash |
| 149 |
|
| 150 |
benchmark: |
| 151 |
strategy: |
| 152 |
fail-fast: false |
| 153 |
matrix: |
| 154 |
python-version: |
| 155 |
- "3.13" |
| 156 |
os: |
| 157 |
- ubuntu-latest |
| 158 |
runs-on: ${{ matrix.os }} |
| 159 |
env: |
| 160 |
POETRY_VIRTUALENVS_IN_PROJECT: "true" |
| 161 |
steps: |
| 162 |
- uses: actions/checkout@v6 |
| 163 |
- name: Set up uv |
| 164 |
id: setup-uv |
| 165 |
uses: astral-sh/[email protected] |
| 166 |
with: |
| 167 |
enable-cache: true |
| 168 |
python-version: ${{ matrix.python-version }} |
| 169 |
- name: Install poetry |
| 170 |
run: uv tool install poetry |
| 171 |
- name: Cache poetry virtualenv |
| 172 |
uses: actions/cache@v4 |
| 173 |
with: |
| 174 |
path: .venv |
| 175 |
key: poetry-${{ runner.os }}-${{ steps.setup-uv.outputs.python-version }}-benchmark-${{ hashFiles('poetry.lock') }} |
| 176 |
- name: Install Dependencies |
| 177 |
run: poetry install --only=main,dev,benchmark |
| 178 |
env: |
| 179 |
REQUIRE_EXTENSION: 1 |
| 180 |
- name: Run benchmarks |
| 181 |
run: | |
| 182 |
poetry run pytest bench --benchmark-autosave |
| 183 |
echo '# Benchmark Results' >> $GITHUB_STEP_SUMMARY |
| 184 |
echo '```' >> $GITHUB_STEP_SUMMARY |
| 185 |
poetry run pytest-benchmark compare --columns=mean,ops >> $GITHUB_STEP_SUMMARY |
| 186 |
echo '```' >> $GITHUB_STEP_SUMMARY |
| 187 |
shell: bash |
| 188 |
|
| 189 |
codspeed_benchmark: |
| 190 |
runs-on: ubuntu-latest |
| 191 |
steps: |
| 192 |
- uses: actions/checkout@v6 |
| 193 |
- name: Set up uv |
| 194 |
uses: astral-sh/[email protected] |
| 195 |
with: |
| 196 |
enable-cache: true |
| 197 |
- name: Install poetry |
| 198 |
run: uv tool install poetry |
| 199 |
- name: Setup Python 3.13 |
| 200 |
uses: actions/setup-python@v6 |
| 201 |
with: |
| 202 |
python-version: 3.13 |
| 203 |
cache: "poetry" |
| 204 |
- name: Install Dependencies |
| 205 |
run: | |
| 206 |
REQUIRE_EXTENSION=1 poetry install --only=main,dev |
| 207 |
shell: bash |
| 208 |
- name: Run benchmarks |
| 209 |
uses: CodSpeedHQ/action@v4 |
| 210 |
with: |
| 211 |
token: ${{ secrets.CODSPEED_TOKEN }} |
| 212 |
run: poetry run pytest --no-cov -vvvvv --codspeed tests/benchmarks |
| 213 |
mode: instrumentation |
| 214 |
|
| 215 |
release: |
| 216 |
needs: |
| 217 |
- test |
| 218 |
- lint |
| 219 |
- test32bit |
| 220 |
- commitlint |
| 221 |
- sdist_safe_path |
| 222 |
|
| 223 |
runs-on: ubuntu-latest |
| 224 |
environment: release |
| 225 |
concurrency: |
| 226 |
group: release-${{ github.ref }} |
| 227 |
cancel-in-progress: false |
| 228 |
permissions: |
| 229 |
id-token: write |
| 230 |
contents: write |
| 231 |
outputs: |
| 232 |
released: ${{ steps.release.outputs.released }} |
| 233 |
newest_release_tag: ${{ steps.release.outputs.tag }} |
| 234 |
|
| 235 |
steps: |
| 236 |
- uses: actions/checkout@v6 |
| 237 |
with: |
| 238 |
fetch-depth: 0 |
| 239 |
ref: ${{ github.event.pull_request.head.sha || github.ref_name }} |
| 240 |
|
| 241 |
|
| 242 |
- name: Create local branch for PSR dry run |
| 243 |
if: github.event_name == 'pull_request' |
| 244 |
run: git switch -c "pr-${{ github.event.pull_request.number }}" |
| 245 |
|
| 246 |
|
| 247 |
- name: Test release |
| 248 |
uses: python-semantic-release/[email protected] |
| 249 |
if: github.ref_name != 'main' |
| 250 |
with: |
| 251 |
no_operation_mode: true |
| 252 |
|
| 253 |
|
| 254 |
- name: Release |
| 255 |
uses: python-semantic-release/[email protected] |
| 256 |
id: release |
| 257 |
if: github.ref_name == 'main' |
| 258 |
with: |
| 259 |
github_token: ${{ secrets.GITHUB_TOKEN }} |
| 260 |
|
| 261 |
- name: Publish package distributions to PyPI |
| 262 |
uses: pypa/gh-action-pypi-publish@release/v1 |
| 263 |
if: steps.release.outputs.released == 'true' |
| 264 |
|
| 265 |
- name: Publish package distributions to GitHub Releases |
| 266 |
uses: python-semantic-release/upload-to-gh-release@main |
| 267 |
if: steps.release.outputs.released == 'true' |
| 268 |
with: |
| 269 |
github_token: ${{ secrets.GITHUB_TOKEN }} |
| 270 |
|
| 271 |
build_wheels: |
| 272 |
needs: [release] |
| 273 |
if: needs.release.outputs.released == 'true' |
| 274 |
name: Wheels for ${{ matrix.os }} (${{ matrix.musl == 'musllinux' && 'musllinux' || 'manylinux' }}) ${{ matrix.qemu }} ${{ matrix.pyver }} |
| 275 |
runs-on: ${{ matrix.os }} |
| 276 |
strategy: |
| 277 |
matrix: |
| 278 |
os: [windows-latest, ubuntu-24.04-arm, ubuntu-latest, macos-latest] |
| 279 |
qemu: [""] |
| 280 |
musl: [""] |
| 281 |
pyver: [""] |
| 282 |
include: |
| 283 |
- os: ubuntu-latest |
| 284 |
musl: "musllinux" |
| 285 |
- os: ubuntu-24.04-arm |
| 286 |
musl: "musllinux" |
| 287 |
|
| 288 |
|
| 289 |
- os: ubuntu-24.04-arm |
| 290 |
qemu: armv7l |
| 291 |
musl: "musllinux" |
| 292 |
pyver: cp311 |
| 293 |
- os: ubuntu-24.04-arm |
| 294 |
qemu: armv7l |
| 295 |
musl: "musllinux" |
| 296 |
pyver: cp312 |
| 297 |
- os: ubuntu-24.04-arm |
| 298 |
qemu: armv7l |
| 299 |
musl: "musllinux" |
| 300 |
pyver: cp313 |
| 301 |
- os: ubuntu-24.04-arm |
| 302 |
qemu: armv7l |
| 303 |
musl: "musllinux" |
| 304 |
pyver: cp314 |
| 305 |
- os: ubuntu-24.04-arm |
| 306 |
qemu: armv7l |
| 307 |
musl: "musllinux" |
| 308 |
pyver: cp314t |
| 309 |
|
| 310 |
|
| 311 |
- os: ubuntu-24.04-arm |
| 312 |
qemu: armv7l |
| 313 |
musl: "" |
| 314 |
pyver: cp311 |
| 315 |
- os: ubuntu-24.04-arm |
| 316 |
qemu: armv7l |
| 317 |
musl: "" |
| 318 |
pyver: cp312 |
| 319 |
- os: ubuntu-24.04-arm |
| 320 |
qemu: armv7l |
| 321 |
musl: "" |
| 322 |
pyver: cp313 |
| 323 |
- os: ubuntu-24.04-arm |
| 324 |
qemu: armv7l |
| 325 |
musl: "" |
| 326 |
pyver: cp314 |
| 327 |
- os: ubuntu-24.04-arm |
| 328 |
qemu: armv7l |
| 329 |
musl: "" |
| 330 |
pyver: cp314t |
| 331 |
steps: |
| 332 |
- uses: actions/checkout@v6 |
| 333 |
with: |
| 334 |
ref: ${{ needs.release.outputs.newest_release_tag }} |
| 335 |
fetch-depth: 0 |
| 336 |
|
| 337 |
- name: Set up Python |
| 338 |
uses: actions/setup-python@v6 |
| 339 |
with: |
| 340 |
python-version: "3.12" |
| 341 |
- name: Set up QEMU |
| 342 |
if: ${{ matrix.qemu }} |
| 343 |
uses: docker/setup-qemu-action@v4 |
| 344 |
with: |
| 345 |
platforms: all |
| 346 |
|
| 347 |
|
| 348 |
|
| 349 |
image: tonistiigi/binfmt:qemu-v8.1.5 |
| 350 |
id: qemu |
| 351 |
- name: Prepare emulation |
| 352 |
if: ${{ matrix.qemu }} |
| 353 |
run: | |
| 354 |
if [[ -n "${{ matrix.qemu }}" ]]; then |
| 355 |
# Build emulated architectures only if QEMU is set, |
| 356 |
# use default "auto" otherwise |
| 357 |
echo "CIBW_ARCHS_LINUX=${{ matrix.qemu }}" >> $GITHUB_ENV |
| 358 |
fi |
| 359 |
- name: Limit to a specific Python version on slow QEMU |
| 360 |
if: ${{ matrix.pyver }} |
| 361 |
run: | |
| 362 |
if [[ -n "${{ matrix.pyver }}" ]]; then |
| 363 |
echo "CIBW_BUILD=${{ matrix.pyver }}*" >> $GITHUB_ENV |
| 364 |
fi |
| 365 |
- name: Build wheels |
| 366 |
uses: pypa/[email protected] |
| 367 |
env: |
| 368 |
CIBW_SKIP: cp36-* cp37-* cp38-* cp39-* cp310-* pp* ${{ matrix.musl == 'musllinux' && '*manylinux*' || '*musllinux*' }} |
| 369 |
REQUIRE_EXTENSION: 1 |
| 370 |
|
| 371 |
- uses: actions/upload-artifact@v7 |
| 372 |
with: |
| 373 |
name: wheels-${{ matrix.os }}-${{ matrix.musl }}-${{ matrix.pyver }}-${{ matrix.qemu }} |
| 374 |
path: ./wheelhouse/*.whl |
| 375 |
|
| 376 |
upload_pypi: |
| 377 |
needs: [build_wheels] |
| 378 |
runs-on: ubuntu-latest |
| 379 |
environment: release |
| 380 |
permissions: |
| 381 |
id-token: write |
| 382 |
|
| 383 |
steps: |
| 384 |
- uses: actions/download-artifact@v8 |
| 385 |
with: |
| 386 |
|
| 387 |
|
| 388 |
path: dist |
| 389 |
pattern: wheels-* |
| 390 |
merge-multiple: true |
| 391 |
|
| 392 |
- uses: |
| 393 |
pypa/[email protected] |
| 394 |
|
| 395 |
|