Skip to content

fix(test): platform-conditional socket path assertion for Windows #1075

fix(test): platform-conditional socket path assertion for Windows

fix(test): platform-conditional socket path assertion for Windows #1075

Workflow file for this run

# Build and publish Python packages (runtimed + nteract).
#
# runtimed: PyO3 bindings for the daemon client, bundles the runtimed binary.
# nteract: Pure-Python MCP server that depends on runtimed.
#
# To publish: push a tag matching `python-v*` (e.g. `python-v0.1.0`).
name: Python Package
on:
push:
tags:
- "python-v*"
pull_request:
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
permissions:
contents: read
env:
CARGO_TERM_COLOR: always
jobs:
# Detect whether Python/Rust sources changed. When they haven't
# (e.g. a docs-only or .gitignore PR), the expensive jobs are
# skipped but still report a passing status so required checks
# don't block the merge queue.
changes:
runs-on: ubuntu-latest
permissions:
pull-requests: read
outputs:
python: ${{ steps.filter.outputs.python }}
steps:
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
python:
- 'pyproject.toml'
- 'python/runtimed/**'
- 'python/nteract/**'
- 'python/gremlin/**'
- 'crates/runtimed-py/**'
- 'crates/runtimed/**'
- '.github/workflows/python-package.yml'
python-lint-and-test:
name: Python Lint & Unit Tests
needs: changes
if: needs.changes.outputs.python == 'true' || github.event_name == 'push' || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Install rust
uses: dsherret/rust-toolchain-file@v1
- uses: Swatinem/rust-cache@v2
with:
shared-key: python-x86_64-unknown-linux-gnu
- name: Install uv
uses: astral-sh/setup-uv@v7
- name: Set up Python
run: uv python install 3.12
- name: Build and stage runtimed binary
run: |
cargo build -p runtimed
cp target/debug/runtimed python/runtimed/src/runtimed/_bin/
- name: Sync workspace
run: uv sync
- name: Ruff check
run: uv run ruff check --config pyproject.toml python/nteract/src/ python/runtimed/src/ python/runtimed/tests/
- name: Ruff format check
run: uv run ruff format --check --config pyproject.toml python/nteract/src/ python/runtimed/src/ python/runtimed/tests/
- name: Type check
run: uv run ty check python/
- name: Run runtimed-py unit tests
working-directory: python/runtimed
run: uv run pytest tests/test_session_unit.py tests/test_binary.py tests/test_ipython_bridge.py -v --tb=short
python-lint-and-test-skip:
name: Python Lint & Unit Tests
needs: changes
if: needs.changes.outputs.python != 'true' && github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- run: echo "Skipped — no Python/Rust changes"
nteract-test:
needs: changes
if: needs.changes.outputs.python == 'true' || github.event_name == 'push' || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Install uv
uses: astral-sh/setup-uv@v7
- name: Set up Python
run: uv python install 3.12
- name: Install dependencies
run: uv sync --dev --no-sources
working-directory: python/nteract
- name: Run smoke tests
run: uv run pytest --ignore=tests/test_mcp_integration.py
working-directory: python/nteract
nteract-test-skip:
name: nteract-test
needs: changes
if: needs.changes.outputs.python != 'true' && github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- run: echo "Skipped — no Python/Rust changes"
macos:
needs: changes
if: needs.changes.outputs.python == 'true' || github.event_name == 'push' || github.event_name == 'workflow_dispatch'
runs-on: ${{ matrix.platform.runner }}
strategy:
matrix:
platform:
- runner: macos-latest
target: aarch64-apple-darwin
- runner: macos-latest
target: x86_64-apple-darwin
steps:
- uses: actions/checkout@v6
- name: Set up Rust
uses: dsherret/rust-toolchain-file@v1
- name: Install cross-compilation target
if: matrix.platform.target == 'x86_64-apple-darwin'
run: rustup target add x86_64-apple-darwin
- uses: Swatinem/rust-cache@v2
with:
shared-key: "python-${{ matrix.platform.target }}"
- name: Build runtimed binary
run: |
cargo build --release --target ${{ matrix.platform.target }} -p runtimed
cp target/${{ matrix.platform.target }}/release/runtimed python/runtimed/src/runtimed/_bin/
chmod +x python/runtimed/src/runtimed/_bin/runtimed
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.platform.target }}
args: --release --out dist
working-directory: python/runtimed
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
maturin-version: "v1.11.5"
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-macos-${{ matrix.platform.target }}
path: python/runtimed/dist
linux:
needs: changes
if: needs.changes.outputs.python == 'true' || github.event_name == 'push' || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Set up Rust
uses: dsherret/rust-toolchain-file@v1
- uses: Swatinem/rust-cache@v2
with:
shared-key: "python-x86_64-unknown-linux-gnu"
- name: Build runtimed binary
run: |
cargo build --release --target x86_64-unknown-linux-gnu -p runtimed
cp target/x86_64-unknown-linux-gnu/release/runtimed python/runtimed/src/runtimed/_bin/
chmod +x python/runtimed/src/runtimed/_bin/runtimed
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: x86_64
args: --release --out dist
working-directory: python/runtimed
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
maturin-version: "v1.11.5"
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-linux-x86_64
path: python/runtimed/dist
nteract-build:
name: Build nteract sdist + wheel
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/checkout@v6
- name: Install uv
uses: astral-sh/setup-uv@v7
- name: Set up Python
run: uv python install 3.12
- name: Set dev version
run: |
CURRENT_VERSION=$(python -c "import tomllib; print(tomllib.load(open('pyproject.toml','rb'))['project']['version'])")
MAJOR_MINOR=$(echo "$CURRENT_VERSION" | sed 's/\.[0-9]*$//')
PATCH=$(echo "$CURRENT_VERSION" | grep -o '[0-9]*$')
NEXT_PATCH=$((PATCH + 1))
TIMESTAMP=$(date -u +%Y%m%d%H%M)
DEV_VERSION="${MAJOR_MINOR}.${NEXT_PATCH}a${TIMESTAMP}"
echo "Setting nteract version to: ${DEV_VERSION}"
sed -i "s/^version = .*/version = \"${DEV_VERSION}\"/" pyproject.toml
# Pin runtimed dep to the same prerelease series
sed -i "s/runtimed>=[^,]*/runtimed>=${DEV_VERSION}/" pyproject.toml
working-directory: python/nteract
- name: Build
run: uv build --no-sources
working-directory: python/nteract
- name: Upload dist
uses: actions/upload-artifact@v4
with:
name: nteract-dist
path: dist
release:
name: Release
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
needs: [macos, linux, nteract-build]
permissions:
id-token: write
contents: write
attestations: write
steps:
- uses: actions/download-artifact@v4
- name: Generate artifact attestation
uses: actions/attest-build-provenance@v4
with:
subject-path: "wheels-*/*"
- name: Install uv
uses: astral-sh/setup-uv@v7
- name: Publish runtimed to PyPI
run: uv publish --trusted-publishing always --check-url https://pypi.org/simple/runtimed/ 'wheels-*/*'
- name: Publish nteract to PyPI
run: uv publish --trusted-publishing always --check-url https://pypi.org/simple/nteract/ 'nteract-dist/*'
- name: Upload to GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.ref_name }}
make_latest: false
files: |
wheels-*/*
nteract-dist/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}