| 1 |
name: CI |
| 2 |
|
| 3 |
on: |
| 4 |
push: |
| 5 |
branches: |
| 6 |
- main |
| 7 |
pull_request: |
| 8 |
workflow_dispatch: |
| 9 |
inputs: |
| 10 |
force: |
| 11 |
description: "Force a release of this version type (passes through to python-semantic-release)" |
| 12 |
required: false |
| 13 |
default: "" |
| 14 |
type: choice |
| 15 |
options: |
| 16 |
- "" |
| 17 |
- patch |
| 18 |
- minor |
| 19 |
- major |
| 20 |
- prerelease |
| 21 |
|
| 22 |
concurrency: |
| 23 |
group: ${{ github.head_ref || github.run_id }} |
| 24 |
cancel-in-progress: true |
| 25 |
|
| 26 |
env: |
| 27 |
POETRY_VIRTUALENVS_IN_PROJECT: "true" |
| 28 |
|
| 29 |
jobs: |
| 30 |
lint: |
| 31 |
runs-on: ubuntu-latest |
| 32 |
steps: |
| 33 |
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 |
| 34 |
- uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 |
| 35 |
with: |
| 36 |
python-version: "3.10" |
| 37 |
- uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd |
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
commitlint: |
| 42 |
name: Lint Commit Messages |
| 43 |
runs-on: ubuntu-latest |
| 44 |
steps: |
| 45 |
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 |
| 46 |
with: |
| 47 |
fetch-depth: 0 |
| 48 |
- uses: wagoid/commitlint-github-action@b948419dd99f3fd78a6548d48f94e3df7f6bf3ed |
| 49 |
|
| 50 |
test: |
| 51 |
strategy: |
| 52 |
fail-fast: false |
| 53 |
matrix: |
| 54 |
python-version: |
| 55 |
- "3.10" |
| 56 |
- "3.11" |
| 57 |
- "3.12" |
| 58 |
- "3.13" |
| 59 |
- "3.14" |
| 60 |
- "3.14t" |
| 61 |
os: |
| 62 |
- ubuntu-latest |
| 63 |
- macOS-latest |
| 64 |
- windows-latest |
| 65 |
extension: |
| 66 |
- "skip_cython" |
| 67 |
- "use_cython" |
| 68 |
runs-on: ${{ matrix.os }} |
| 69 |
steps: |
| 70 |
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 |
| 71 |
- name: Set up uv |
| 72 |
uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 |
| 73 |
with: |
| 74 |
enable-cache: true |
| 75 |
- name: Install poetry |
| 76 |
run: uv tool install poetry |
| 77 |
- name: Set up Python |
| 78 |
id: setup-python |
| 79 |
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 |
| 80 |
with: |
| 81 |
python-version: ${{ matrix.python-version }} |
| 82 |
allow-prereleases: true |
| 83 |
cache: "poetry" |
| 84 |
- name: Cache poetry venv |
| 85 |
id: cache-venv |
| 86 |
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 |
| 87 |
with: |
| 88 |
path: | |
| 89 |
.venv |
| 90 |
src/bluetooth_data_tools/**/*.so |
| 91 |
key: venv-v2-${{ runner.os }}-py${{ steps.setup-python.outputs.python-version }}-${{ matrix.extension }}-${{ hashFiles('poetry.lock', 'pyproject.toml', 'build_ext.py', 'src/bluetooth_data_tools/**/*.py', 'src/bluetooth_data_tools/**/*.pyx', 'src/bluetooth_data_tools/**/*.pxd', 'src/bluetooth_data_tools/**/*.h') }} |
| 92 |
- name: Install Dependencies |
| 93 |
if: steps.cache-venv.outputs.cache-hit != 'true' |
| 94 |
run: | |
| 95 |
if [ "${{ matrix.extension }}" = "skip_cython" ]; then |
| 96 |
SKIP_CYTHON=1 poetry install --only=main,dev |
| 97 |
else |
| 98 |
# Without this the extensions can silently fail to compile and the |
| 99 |
# job still passes -- testing the pure-Python path a second time. |
| 100 |
# Verbose so the build backend's compiler output reaches the log; |
| 101 |
# poetry otherwise reports only "Failed to install". |
| 102 |
REQUIRE_CYTHON=1 poetry install --only=main,dev -vvv |
| 103 |
fi |
| 104 |
shell: bash |
| 105 |
- name: Test with Pytest |
| 106 |
run: poetry run pytest --cov-report=xml -v -Wdefault --cov=bluetooth_data_tools --cov-report=term-missing:skip-covered tests |
| 107 |
shell: bash |
| 108 |
- name: Upload coverage to Codecov |
| 109 |
uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f |
| 110 |
with: |
| 111 |
token: ${{ secrets.CODECOV_TOKEN }} |
| 112 |
|
| 113 |
benchmark: |
| 114 |
strategy: |
| 115 |
fail-fast: false |
| 116 |
matrix: |
| 117 |
python-version: |
| 118 |
- "3.13" |
| 119 |
os: |
| 120 |
- ubuntu-latest |
| 121 |
runs-on: ${{ matrix.os }} |
| 122 |
steps: |
| 123 |
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 |
| 124 |
- name: Set up uv |
| 125 |
uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 |
| 126 |
with: |
| 127 |
enable-cache: true |
| 128 |
- name: Install poetry |
| 129 |
run: uv tool install poetry |
| 130 |
- name: Set up Python |
| 131 |
id: setup-python |
| 132 |
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 |
| 133 |
with: |
| 134 |
python-version: ${{ matrix.python-version }} |
| 135 |
cache: "poetry" |
| 136 |
- name: Cache poetry venv |
| 137 |
id: cache-venv |
| 138 |
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 |
| 139 |
with: |
| 140 |
path: | |
| 141 |
.venv |
| 142 |
src/bluetooth_data_tools/**/*.so |
| 143 |
key: venv-v2-${{ runner.os }}-benchmark-py${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('poetry.lock', 'pyproject.toml', 'build_ext.py', 'src/bluetooth_data_tools/**/*.py', 'src/bluetooth_data_tools/**/*.pyx', 'src/bluetooth_data_tools/**/*.pxd', 'src/bluetooth_data_tools/**/*.h') }} |
| 144 |
- name: Install Dependencies |
| 145 |
if: steps.cache-venv.outputs.cache-hit != 'true' |
| 146 |
run: poetry install --only=main,dev,benchmark |
| 147 |
env: |
| 148 |
REQUIRE_CYTHON: 1 |
| 149 |
- name: Run benchmarks |
| 150 |
run: | |
| 151 |
poetry run pytest bench --benchmark-autosave |
| 152 |
echo '# Benchmark Results' >> $GITHUB_STEP_SUMMARY |
| 153 |
echo '```' >> $GITHUB_STEP_SUMMARY |
| 154 |
poetry run pytest-benchmark compare --columns=mean,ops >> $GITHUB_STEP_SUMMARY |
| 155 |
echo '```' >> $GITHUB_STEP_SUMMARY |
| 156 |
shell: bash |
| 157 |
|
| 158 |
codspeed_benchmark: |
| 159 |
runs-on: ubuntu-latest |
| 160 |
steps: |
| 161 |
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 |
| 162 |
- name: Set up uv |
| 163 |
uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 |
| 164 |
with: |
| 165 |
enable-cache: true |
| 166 |
- name: Install poetry |
| 167 |
run: uv tool install poetry |
| 168 |
- name: Setup Python 3.13 |
| 169 |
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 |
| 170 |
with: |
| 171 |
python-version: 3.13 |
| 172 |
cache: "poetry" |
| 173 |
- name: Install Dependencies |
| 174 |
run: | |
| 175 |
REQUIRE_CYTHON=1 poetry install --only=main,dev |
| 176 |
shell: bash |
| 177 |
- name: Run benchmarks |
| 178 |
uses: CodSpeedHQ/action@88472375d0a4572cf70a9f1fe3a4e0ab8da1b924 |
| 179 |
with: |
| 180 |
token: ${{ secrets.CODSPEED_TOKEN }} |
| 181 |
run: poetry run pytest --no-cov -vvvvv --codspeed tests/benchmarks |
| 182 |
mode: instrumentation |
| 183 |
|
| 184 |
|
| 185 |
|
| 186 |
release-dry-run: |
| 187 |
needs: |
| 188 |
- test |
| 189 |
- lint |
| 190 |
- commitlint |
| 191 |
if: github.ref_name != 'main' |
| 192 |
runs-on: ubuntu-latest |
| 193 |
permissions: |
| 194 |
contents: read |
| 195 |
steps: |
| 196 |
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 |
| 197 |
with: |
| 198 |
fetch-depth: 0 |
| 199 |
ref: ${{ github.ref }} |
| 200 |
- name: Create local branch name |
| 201 |
env: |
| 202 |
BRANCH: ${{ github.head_ref || github.ref_name }} |
| 203 |
run: git switch -C "$BRANCH" |
| 204 |
- name: Test release |
| 205 |
uses: python-semantic-release/python-semantic-release@39dd2052f2ce8282a5d932c31d58a2ca06d2550e |
| 206 |
with: |
| 207 |
no_operation_mode: true |
| 208 |
|
| 209 |
|
| 210 |
|
| 211 |
release: |
| 212 |
needs: |
| 213 |
- test |
| 214 |
- lint |
| 215 |
- commitlint |
| 216 |
if: github.ref_name == 'main' |
| 217 |
runs-on: ubuntu-latest |
| 218 |
environment: release |
| 219 |
concurrency: |
| 220 |
group: release-${{ github.ref }} |
| 221 |
cancel-in-progress: false |
| 222 |
permissions: |
| 223 |
id-token: write |
| 224 |
contents: write |
| 225 |
outputs: |
| 226 |
released: ${{ steps.release.outputs.released }} |
| 227 |
newest_release_tag: ${{ steps.release.outputs.tag }} |
| 228 |
|
| 229 |
steps: |
| 230 |
|
| 231 |
|
| 232 |
|
| 233 |
|
| 234 |
|
| 235 |
|
| 236 |
|
| 237 |
- name: Generate release App token |
| 238 |
id: app-token |
| 239 |
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 |
| 240 |
with: |
| 241 |
app-id: ${{ secrets.RELEASE_APP_ID }} |
| 242 |
private-key: ${{ secrets.RELEASE_APP_PRIVATE_KEY }} |
| 243 |
|
| 244 |
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 |
| 245 |
with: |
| 246 |
fetch-depth: 0 |
| 247 |
ref: ${{ github.ref }} |
| 248 |
token: ${{ steps.app-token.outputs.token || github.token }} |
| 249 |
|
| 250 |
- name: Create local branch name |
| 251 |
env: |
| 252 |
BRANCH: ${{ github.ref_name }} |
| 253 |
run: git switch -C "$BRANCH" |
| 254 |
|
| 255 |
|
| 256 |
- name: Release |
| 257 |
uses: python-semantic-release/python-semantic-release@39dd2052f2ce8282a5d932c31d58a2ca06d2550e |
| 258 |
id: release |
| 259 |
with: |
| 260 |
github_token: ${{ steps.app-token.outputs.token }} |
| 261 |
force: ${{ inputs.force }} |
| 262 |
|
| 263 |
- name: Publish package distributions to PyPI |
| 264 |
uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 |
| 265 |
if: steps.release.outputs.released == 'true' |
| 266 |
|
| 267 |
- name: Publish package distributions to GitHub Releases |
| 268 |
uses: python-semantic-release/upload-to-gh-release@0a92b5d7ebfc15a84f9801ebd1bf706343d43711 |
| 269 |
if: steps.release.outputs.released == 'true' |
| 270 |
with: |
| 271 |
github_token: ${{ steps.app-token.outputs.token }} |
| 272 |
|
| 273 |
build_wheels: |
| 274 |
needs: [release] |
| 275 |
if: needs.release.outputs.released == 'true' |
| 276 |
name: Wheels for ${{ matrix.os }} (${{ matrix.musl == 'musllinux' && 'musllinux' || 'manylinux' }}) ${{ matrix.qemu }} ${{ matrix.pyver }} |
| 277 |
runs-on: ${{ matrix.os }} |
| 278 |
strategy: |
| 279 |
|
| 280 |
|
| 281 |
fail-fast: false |
| 282 |
matrix: |
| 283 |
os: |
| 284 |
[ |
| 285 |
windows-latest, |
| 286 |
ubuntu-24.04-arm, |
| 287 |
ubuntu-latest, |
| 288 |
macos-15-intel, |
| 289 |
macos-latest, |
| 290 |
] |
| 291 |
qemu: [""] |
| 292 |
musl: [""] |
| 293 |
pyver: [""] |
| 294 |
include: |
| 295 |
- os: ubuntu-latest |
| 296 |
musl: "musllinux" |
| 297 |
- os: ubuntu-24.04-arm |
| 298 |
musl: "musllinux" |
| 299 |
|
| 300 |
|
| 301 |
- os: ubuntu-latest |
| 302 |
qemu: armv7l |
| 303 |
musl: "musllinux" |
| 304 |
pyver: cp310 |
| 305 |
- os: ubuntu-latest |
| 306 |
qemu: armv7l |
| 307 |
musl: "musllinux" |
| 308 |
pyver: cp311 |
| 309 |
- os: ubuntu-latest |
| 310 |
qemu: armv7l |
| 311 |
musl: "musllinux" |
| 312 |
pyver: cp312 |
| 313 |
- os: ubuntu-latest |
| 314 |
qemu: armv7l |
| 315 |
musl: "musllinux" |
| 316 |
pyver: cp313 |
| 317 |
- os: ubuntu-latest |
| 318 |
qemu: armv7l |
| 319 |
musl: "musllinux" |
| 320 |
pyver: cp314 |
| 321 |
- os: ubuntu-latest |
| 322 |
qemu: armv7l |
| 323 |
musl: "musllinux" |
| 324 |
pyver: cp314t |
| 325 |
|
| 326 |
|
| 327 |
- os: ubuntu-latest |
| 328 |
qemu: armv7l |
| 329 |
musl: "" |
| 330 |
pyver: cp310 |
| 331 |
- os: ubuntu-latest |
| 332 |
qemu: armv7l |
| 333 |
musl: "" |
| 334 |
pyver: cp311 |
| 335 |
- os: ubuntu-latest |
| 336 |
qemu: armv7l |
| 337 |
musl: "" |
| 338 |
pyver: cp312 |
| 339 |
- os: ubuntu-latest |
| 340 |
qemu: armv7l |
| 341 |
musl: "" |
| 342 |
pyver: cp313 |
| 343 |
- os: ubuntu-latest |
| 344 |
qemu: armv7l |
| 345 |
musl: "" |
| 346 |
pyver: cp314 |
| 347 |
- os: ubuntu-latest |
| 348 |
qemu: armv7l |
| 349 |
musl: "" |
| 350 |
pyver: cp314t |
| 351 |
steps: |
| 352 |
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 |
| 353 |
with: |
| 354 |
ref: ${{ needs.release.outputs.newest_release_tag }} |
| 355 |
fetch-depth: 0 |
| 356 |
|
| 357 |
- name: Set up Python |
| 358 |
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 |
| 359 |
with: |
| 360 |
python-version: "3.12" |
| 361 |
- name: Set up QEMU |
| 362 |
if: ${{ matrix.qemu }} |
| 363 |
uses: docker/setup-qemu-action@96fe6ef7f33517b61c61be40b68a1882f3264fb8 |
| 364 |
with: |
| 365 |
platforms: all |
| 366 |
|
| 367 |
|
| 368 |
|
| 369 |
image: tonistiigi/binfmt:qemu-v8.1.5 |
| 370 |
id: qemu |
| 371 |
- name: Prepare emulation |
| 372 |
if: ${{ matrix.qemu }} |
| 373 |
run: | |
| 374 |
if [[ -n "${{ matrix.qemu }}" ]]; then |
| 375 |
# Build emulated architectures only if QEMU is set, |
| 376 |
# use default "auto" otherwise |
| 377 |
echo "CIBW_ARCHS_LINUX=${{ matrix.qemu }}" >> $GITHUB_ENV |
| 378 |
fi |
| 379 |
- name: Limit to a specific Python version on slow QEMU |
| 380 |
if: ${{ matrix.pyver }} |
| 381 |
run: | |
| 382 |
if [[ -n "${{ matrix.pyver }}" ]]; then |
| 383 |
echo "CIBW_BUILD=${{ matrix.pyver }}*" >> $GITHUB_ENV |
| 384 |
fi |
| 385 |
- name: Build wheels |
| 386 |
uses: pypa/cibuildwheel@4726cd35bb13f7bde50cf2761f2499ac7b3aa32c |
| 387 |
env: |
| 388 |
CIBW_SKIP: cp36-* cp37-* cp38-* cp39-* pp* ${{ matrix.musl == 'musllinux' && '*manylinux*' || '*musllinux*' }} |
| 389 |
REQUIRE_CYTHON: 1 |
| 390 |
|
| 391 |
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a |
| 392 |
with: |
| 393 |
name: wheels-${{ matrix.os }}-${{ matrix.musl }}-${{ matrix.pyver }}-${{ matrix.qemu }} |
| 394 |
path: ./wheelhouse/*.whl |
| 395 |
|
| 396 |
upload_pypi: |
| 397 |
needs: [build_wheels] |
| 398 |
runs-on: ubuntu-latest |
| 399 |
environment: release |
| 400 |
permissions: |
| 401 |
id-token: write |
| 402 |
|
| 403 |
steps: |
| 404 |
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c |
| 405 |
with: |
| 406 |
|
| 407 |
|
| 408 |
path: dist |
| 409 |
pattern: wheels-* |
| 410 |
merge-multiple: true |
| 411 |
|
| 412 |
- uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 |
| 413 |
|