Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .github/actions/test-python/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Test one Python version
description: Run the kernel suite against one Python version and the selected JS host

inputs:
python-version:
description: Python version for actions/setup-python
required: true
runtime-kind:
description: node or bun
required: true

runs:
using: composite
steps:
- uses: actions/setup-python@v7
with:
python-version: ${{ inputs.python-version }}

- name: Report Python
shell: bash
run: python --version

- name: Test under Node
if: inputs.runtime-kind == 'node'
shell: bash
run: npm test
env:
PI_PYTHON_TEST_INTERPRETER: python

- name: Test under Bun
if: inputs.runtime-kind == 'bun'
shell: bash
run: npm run test:bun
env:
PI_PYTHON_TEST_INTERPRETER: python
119 changes: 103 additions & 16 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,37 +15,124 @@ concurrency:

jobs:
check:
name: node ${{ matrix.node }} / python ${{ matrix.python }}
runs-on: ubuntu-latest
name: ${{ matrix.runtime.name }} / ${{ matrix.os }}
runs-on: ${{ matrix.os }}
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
# Lower bound is what pi core requires; upper bound is current LTS.
node: ["22.19", "24"]
# Lower bound is the oldest interpreter runner.py supports.
python: ["3.9", "3.13"]
# The three hosted OS families, all on x64 so Python 3.9 is available
# (macos-latest is arm64 and has no Python 3.9 build).
os: [ubuntu-latest, macos-26-intel, windows-latest]
runtime:
# Node 22.19 is pi's minimum, 22.x is the current maintenance patch,
# 24.x is Active LTS, and 26.x is Current.
- { name: node-22.19, kind: node, version: "22.19" }
- { name: node-22.x, kind: node, version: "22.x" }
- { name: node-24.x, kind: node, version: "24.x" }
- { name: node-26.x, kind: node, version: "26.x" }
# Semver ranges select the latest patch in each modern Bun line.
- { name: bun-1.3.x, kind: bun, version: "1.3.x" }
- { name: bun-1.4.x, kind: bun, version: "1.4.x" }

steps:
- uses: actions/checkout@v7

- uses: actions/setup-node@v7
- name: Set up Node
if: matrix.runtime.kind == 'node'
uses: actions/setup-node@v7
with:
node-version: ${{ matrix.runtime.version }}
cache: npm

# npm and tsc still use Node when Bun is the host under test.
- name: Set up Node for dependencies
if: matrix.runtime.kind == 'bun'
uses: actions/setup-node@v7
with:
node-version: ${{ matrix.node }}
node-version: "24.x"
cache: npm

- uses: actions/setup-python@v7
- name: Set up Bun
if: matrix.runtime.kind == 'bun'
uses: oven-sh/setup-bun@v2
with:
python-version: ${{ matrix.python }}
bun-version: ${{ matrix.runtime.version }}

# The kernel resolves `python3` from PATH when no override is set,
# so confirm the matrix leg's interpreter is the one under test.
- name: Report interpreter
run: python3 --version
- name: Report JS runtime
shell: bash
run: |
if [ "${{ matrix.runtime.kind }}" = "node" ]; then
node --version
else
bun --version
fi

- run: npm ci

- name: Typecheck
run: npm run check

- name: Test
run: npm test
# Keep Python versions as steps rather than a matrix axis: this yields
# one check per JS runtime/OS pair (18 total), not 108 separate checks.
# continue-on-error lets every version run; the aggregate step below
# still fails the job if any one of them failed.
- id: py39
name: Python 3.9
continue-on-error: true
uses: ./.github/actions/test-python
with: { python-version: "3.9", runtime-kind: "${{ matrix.runtime.kind }}" }
- id: py310
name: Python 3.10
continue-on-error: true
uses: ./.github/actions/test-python
with: { python-version: "3.10", runtime-kind: "${{ matrix.runtime.kind }}" }
- id: py311
name: Python 3.11
continue-on-error: true
uses: ./.github/actions/test-python
with: { python-version: "3.11", runtime-kind: "${{ matrix.runtime.kind }}" }
- id: py312
name: Python 3.12
continue-on-error: true
uses: ./.github/actions/test-python
with: { python-version: "3.12", runtime-kind: "${{ matrix.runtime.kind }}" }
- id: py313
name: Python 3.13
continue-on-error: true
uses: ./.github/actions/test-python
with: { python-version: "3.13", runtime-kind: "${{ matrix.runtime.kind }}" }
- id: py314
name: Python 3.14
continue-on-error: true
uses: ./.github/actions/test-python
with: { python-version: "3.14", runtime-kind: "${{ matrix.runtime.kind }}" }

- name: Require every Python version
if: always()
shell: bash
env:
PY39: ${{ steps.py39.outcome }}
PY310: ${{ steps.py310.outcome }}
PY311: ${{ steps.py311.outcome }}
PY312: ${{ steps.py312.outcome }}
PY313: ${{ steps.py313.outcome }}
PY314: ${{ steps.py314.outcome }}
run: |
printf '3.9=%s 3.10=%s 3.11=%s 3.12=%s 3.13=%s 3.14=%s\n' \
"$PY39" "$PY310" "$PY311" "$PY312" "$PY313" "$PY314"
test "$PY39 $PY310 $PY311 $PY312 $PY313 $PY314" = \
"success success success success success success"

# Branch protection requires this stable context. It turns red unless all
# 18 runtime/OS jobs (and therefore all 108 combinations) succeeded.
gate:
name: CI gate
if: always()
needs: check
runs-on: ubuntu-latest
steps:
- name: Require the full matrix
env:
MATRIX_RESULT: ${{ needs.check.result }}
run: test "$MATRIX_RESULT" = success
37 changes: 24 additions & 13 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
## Local setup

```bash
npm install
npm ci
npm run check # tsc --noEmit
npm test # drives a real PythonKernel, no mocks
```
Expand All @@ -23,26 +23,35 @@ pi -e ./index.ts

* Node ≥ 22.19 (pi core's floor; the test script needs
`--experimental-transform-types`).
* Bun ≥ 1.3 when using Bun as the TypeScript host.
* Python ≥ 3.9 for `runner.py`, stdlib only.

CI runs the matrix ends: Node 22.19 and 24, each against Python 3.9 and
3.13. If you rely on a newer Python feature in `runner.py`, raise the floor
in the CI matrix, `README.md`, and this file in the same commit.
CI cross-products every claimed Python version (3.9–3.14), every modern
supported Node line (22, 24, 26, plus the exact 22.19 floor), Bun 1.3 and
1.4, and all three GitHub-hosted OS families (Linux, macOS, Windows): 108
combinations. Python versions run sequentially inside each runtime/OS job,
so GitHub shows 18 matrix checks rather than 108. Python 3.9 remains
despite upstream EOL because it is still the documented floor.

When changing a runtime floor or support range, update `package.json`, the
CI matrix, `README.md`, and this file together.

## Commit messages

[Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) are
required, because releases are generated from them. The type drives the
version bump and the changelog:
Commits landing on `main` must use [Conventional
Commits](https://www.conventionalcommits.org/en/v1.0.0/), because
release-please generates versions and changelogs from them. For squash
merges, the PR title becomes that commit message and must follow the
convention. The type drives the version bump and changelog section:

| Prefix | Changelog section | Bump (pre-1.0) |
| --- | --- | --- |
| `feat:` | Features | minor |
| `feat:` | Features | patch |
| `fix:` | Bug Fixes | patch |
| `perf:` | Performance | patch |
| `refactor:` | Refactoring | patch |
| `docs:` | Documentation | patch |
| `test:`, `build:`, `ci:`, `chore:` | hidden | patch |
| `test:`, `build:`, `ci:`, `chore:` | hidden | no release on their own |
| any type with `!` or `BREAKING CHANGE:` | Breaking | minor while 0.x |

Write the body for someone who has to touch the same code in a year.
Expand All @@ -53,8 +62,9 @@ justified the change. The existing history is the style reference.

`main` requires a PR (0 approvals — review is encouraged, not enforced for
a project this size), a linear history, resolved conversations, and the
four CI legs passing. Force pushes and deletion are blocked. Admins are
not bound by the rules, deliberately: see the release caveat below.
`CI gate` check. That stable gate succeeds only when the entire dynamic
runtime/OS matrix passes. Force pushes and deletion are blocked. Admins
are not bound by the rules, deliberately: see the release caveat below.

Because linear history is required, merge commits are disabled repo-wide.
Squash and rebase merges both work.
Expand Down Expand Up @@ -87,15 +97,16 @@ PR therefore shows a CI run stuck at `action_required` with no jobs, and
the required checks never report. Two ways through:

* Open the run in the Actions tab and click *Approve and run*, then merge
normally once the four legs pass.
normally once the full matrix and `CI gate` pass.
* Or merge it as an admin, which the protection rules allow.

Neither skips testing: the publish job re-runs the typecheck and the full
kernel suite against the tagged commit before it publishes, so an
unapproved release PR cannot ship untested code.

Wiring a PAT into release-please would make checks run on its PR, at the
cost of a long-lived credential in the repository. Not worth it here.
cost of maintaining a long-lived repository secret. One explicit approval
per release is the simpler tradeoff here.

## What counts as breaking

Expand Down
Loading
Loading