feat: add reusable maturin prerelease workflow for multi-platform builds#17
Conversation
625f54c to
c0628c4
Compare
| { "os": "ubuntu-latest", "target": "x86_64-unknown-linux-gnu", "manylinux": "auto" }, | ||
| { "os": "ubuntu-latest", "target": "aarch64-unknown-linux-gnu", "manylinux": "auto" }, | ||
| { "os": "windows-latest", "target": "x86_64-pc-windows-msvc" }, | ||
| { "os": "windows-11-arm", "target": "aarch64-pc-windows-msvc" }, |
There was a problem hiding this comment.
Interesting that Github has this! Or is this cross compilation. ( only a note, not a comment or anything )
There was a problem hiding this comment.
Yeah this is a build matrix, we can choose different platforms to run our actions on. It's the same way we run the unit tests on multiple platforms
| uses: PyO3/maturin-action@v1 | ||
| with: | ||
| command: sdist | ||
| args: --out dist |
There was a problem hiding this comment.
3. No --locked flag on maturin-action build
args: --release --out dist
Without --locked, Cargo may resolve newer dependency versions than what's in Cargo.lock. For reproducible release builds, you should pass --locked to ensure the lock file is respected:
This one seems interesting and important. We want to use the package version lock.
There was a problem hiding this comment.
Hmm this is causing issues in the build: https://github.com/jericht/openjd-model-for-python/actions/runs/28043947356/job/83017094879
Let me look into what the flag does.
There was a problem hiding this comment.
Here is the CLI help text for maturin build --sdist
--locked
Require Cargo.lock is up to date
Apparently this is actually a cargo option (source)
Relevant cargo docs (source):
--locked
Asserts that the exact same dependencies and versions are used as when the existing Cargo.lock file was originally generated. Cargo will exit with an error when either of the following scenarios arises:The lock file is missing.
Cargo attempted to change the lock file due to a different dependency resolution.
It may be used in environments where deterministic builds are desired, such as in CI pipelines.
So I think we do want --locked, just not sure why it's failing. Let me look into it
There was a problem hiding this comment.
Oh I think I may have added a Cargo.lock at the root of the repo when it should be in rust-bindings
There was a problem hiding this comment.
I just needed to tag the latest commit and give the workflow the new tag. Fixed
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 |
There was a problem hiding this comment.
nit - seems the other PR uses v6, do we need to upgrade?
| default: "pip install setuptools_scm && python scripts/maturin_build.py --version-only" | ||
|
|
||
| jobs: | ||
| BuildWheels: |
There was a problem hiding this comment.
- No timeout on jobs
The matrix build runs across 6 platform runners. If a runner hangs (particularly cross-compilation for aarch64-unknown-linux-gnu via QEMU in maturin-action), there's no timeout-minutes. Default GitHub timeout is
6 hours per job. Adding timeout-minutes: 30 (or similar) would prevent stuck releases from burning Actions minutes.
c169ef9 to
95f0134
Compare
Adds reusable_maturin_prerelease.yml — a drop-in replacement for
reusable_prerelease.yml for packages that use PyO3/maturin instead of
hatch. Builds native wheels on a configurable platform matrix (defaults
to all 6 platforms: linux x86_64/aarch64, windows x86_64/aarch64, macOS
arm64/x86_64), plus sdist, and collects them into a single
build-artifact upload matching the format reusable_release.yml expects.
Inputs:
- tag (required): git tag to build from
- platforms (optional): JSON array of {os, target, manylinux} objects
- version-script (optional): shell command to inject VCS version
Signed-off-by: jericht <68654047+jericht@users.noreply.github.com>
95f0134 to
962ae40
Compare
|
Tested latest revision in: https://github.com/jericht/openjd-model-for-python/actions/runs/28047586860 |
| - name: Set up Python | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: "3.12" |
There was a problem hiding this comment.
Does the python version specified here mean that these wheels will only work for 3.12 and above ? Or is this something else
There was a problem hiding this comment.
This is the Python version used by the GitHub Action runner. It's used to run the build (maturin). This version shouldn't matter since it's only used by the machine building. Let me double check maturin docs
Sufficient approvals, addressed comments
See description for OpenJobDescription/openjd-model-for-python#281
This PR just has the reusable workflows for above PR, will be reused in openjd-sessions package too
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.