Interrupt support #182
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 | |
on: | |
workflow_dispatch: | |
release: | |
types: [published] | |
pull_request: | |
branches: [master] | |
paths: | |
- "src/*.h" | |
- "src/*.cpp" | |
- "src/**/*.pyi" | |
- "src/CMakeLists.txt" | |
- "src/cmake/**" | |
- "src/utility/CMakeLists.txt" | |
- "src/utility/linux_kernel/*" | |
- ".github/workflows/build_python.yml" | |
push: | |
branches: [master] | |
paths: | |
- "src/*.h" | |
- "src/*.cpp" | |
- "src/**/*.pyi" | |
- "src/CMakeLists.txt" | |
- "src/cmake/**" | |
- "src/utility/CMakeLists.txt" | |
- "src/utility/linux_kernel/*" | |
- ".github/workflows/build_python.yml" | |
jobs: | |
lint: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Set up Python | |
id: python-setup | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.x | |
- name: Checkout Current Repo | |
uses: actions/checkout@v4 | |
with: | |
submodules: true | |
fetch-depth: 0 | |
- name: Install pre-commit and lib stubs | |
run: pip install pre-commit . | |
- name: Cache pre-commit venv | |
uses: actions/cache@v4 | |
with: | |
key: pre-commit-${{ hashFiles('.pre-commit-config.yaml') }} | |
path: '~/.cache/pre-commit' | |
- name: run pre-commit on all files | |
run: pre-commit run --all-files | |
source-dist: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Set up Python | |
id: python-setup | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.x | |
- name: Checkout Current Repo | |
uses: actions/checkout@v4 | |
with: | |
submodules: true | |
fetch-depth: 0 | |
- name: Install twine and build | |
run: pip install twine build | |
- name: Create source distribution | |
run: python -m build -s | |
- name: Checks distributable with twine | |
shell: bash | |
run: twine check dist/* | |
- name: Save distributable source as artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: "cirque_pinnacle-dist_source" | |
path: ${{ github.workspace }}/dist | |
- name: Try install from source distributable | |
run: pip install dist/*.tar.gz -v | |
bin-matrix: | |
runs-on: ubuntu-latest | |
outputs: | |
version-matrix: ${{ steps.matrix-out.outputs.versions }} | |
steps: | |
- name: create matrix | |
id: matrix-out | |
shell: python | |
run: | | |
from os import environ | |
import json | |
versions = ["cp313"] | |
if "${{github.event_name != 'pull_request'}}" == "true": | |
versions.extend(["cp37", "cp38", "cp39", "cp310", "cp311", "cp312"]) | |
with open(environ["GITHUB_OUTPUT"], mode="a", encoding="utf-8") as gh_out: | |
gh_out.write(f'versions={json.dumps(versions)}\n') | |
linux-wheels: | |
runs-on: ubuntu-latest | |
needs: [bin-matrix] | |
strategy: | |
fail-fast: false | |
matrix: | |
platform: [native, aarch64, armv7l] | |
python: ${{ fromJSON(needs.bin-matrix.outputs.version-matrix) }} | |
tag: [manylinux, musllinux] | |
steps: | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.x | |
- name: Install dependencies | |
run: | | |
sudo apt-get install python3-dev | |
python3 -m pip install --upgrade pip | |
python3 -m pip install twine | |
- name: Checkout Current Repo | |
uses: actions/checkout@v4 | |
with: | |
submodules: true | |
fetch-depth: 0 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
if: matrix.platform == 'aarch64' || matrix.platform == 'armv7l' | |
with: | |
# cached image is enabled by default. | |
# This option to disable caching doesn't exist before docker/setup-qemu-action@v3.3 | |
# cache-image: false | |
# NOTE: the default tag `tonistiigi/binfmt:latest` is old and uses qemu v6.2.0 | |
# See also https://github.com/tonistiigi/binfmt/issues/215 | |
image: docker.io/tonistiigi/binfmt:qemu-v8.1.5 | |
- name: Build binary wheels with cibuildwheels | |
uses: pypa/cibuildwheel@v2.23.2 | |
env: | |
CIBW_ARCHS_LINUX: ${{ matrix.platform }} | |
CIBW_SKIP: pp* *ppc64le *s390x | |
CIBW_BUILD_VERBOSITY: 1 | |
CIBW_BUILD: '${{ matrix.python }}*${{ matrix.tag }}*' | |
- name: Move cross-compiled wheels to dist folder | |
run: | | |
mkdir -p dist | |
mv ./wheelhouse/*.whl ${{ github.workspace }}/dist/ | |
- name: checks distributable with twine | |
run: python3 -m twine check dist/* | |
- name: Save distributable wheels as artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: "cirque_pinnacle-dist_${{ matrix.platform }}_${{ matrix.python }}_${{ matrix.tag }}" | |
path: ${{ github.workspace }}/dist | |
release: | |
runs-on: ubuntu-latest | |
if: github.event_name == 'release' || github.event_name == 'workflow_dispatch' | |
needs: [lint, source-dist, linux-wheels] | |
permissions: | |
id-token: write | |
steps: | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.x | |
- name: Fetch built distribution artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
pattern: "cirque_pinnacle-dist*" | |
path: ${{ github.workspace }}/dist | |
merge-multiple: true | |
- name: Publish package (to TestPyPI) | |
if: github.event_name == 'workflow_dispatch' | |
uses: pypa/gh-action-pypi-publish@v1.12.4 | |
with: | |
repository-url: https://test.pypi.org/legacy/ | |
- name: Publish to PyPi | |
# only upload distributions to PyPi when triggered by a published release | |
if: github.event_name == 'release' | |
uses: pypa/gh-action-pypi-publish@v1.12.4 |