Skip to content

Commit

Permalink
Fix job skip condition by contains() check (#47)
Browse files Browse the repository at this point in the history
This PR changes the CI pipeline to be based on uv. It also disables abi3audit properly for all Python versions earlier than 3.12 by checking if the version from the CI job matrix is in the abi3audit candidate list.

It seems that Windows jobs take longer now than before, though, which warrants an investigation.

Also for the moment disables the recursive stubgen in the nanobind_example again with a git patch, since that hasn't landed yet.
  • Loading branch information
nicholasjng authored Dec 18, 2024
1 parent b2df97e commit d378ffc
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 26 deletions.
44 changes: 18 additions & 26 deletions .github/workflows/lint-and-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,59 +12,51 @@ jobs:
buildifier:
name: Lint Bazel files with buildifier
runs-on: ubuntu-latest
env:
PRE_COMMIT_HOME: "${{ github.workspace }}/.cache/pre-commit"
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python and dependencies
uses: actions/setup-python@v5
with:
python-version: 3.12
- name: Install pre-commit
run: pip install --upgrade pre-commit
- name: Cache pre-commit tools
uses: actions/cache@v4
with:
path: ${{ env.PRE_COMMIT_HOME }}
key: ${{ hashFiles('.pre-commit-config.yaml') }}-linter-cache
- name: Install uv
uses: astral-sh/setup-uv@v4
- name: Run pre-commit checks
run: pre-commit run --all-files --verbose --show-diff-on-failure
run: uvx pre-commit run --all-files --verbose --show-diff-on-failure
test:
name: Test nanobind_example on ${{ matrix.os }} w/ Python ${{ matrix.py }}
name: Test nanobind_example on ${{ matrix.os }} w/ Python ${{ matrix.python-version }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
py: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.py }} on ${{ matrix.os }}
uses: actions/setup-python@v5
- name: Install uv
uses: astral-sh/setup-uv@v4
with:
python-version: ${{ matrix.py }}
- run: python -m pip install build
python-version: ${{ matrix.python-version }}
- name: Check out nanobind example repo
uses: actions/checkout@v4
with:
repository: wjakob/nanobind_example
path: nanobind_example
ref: bazel
- name: Patch nanobind_example stubgen target
run: git apply ${{github.workspace }}/stubgen.patch
working-directory: ${{ github.workspace }}/nanobind_example

- name: Override nanobind_bazel pin in MODULE.bazel
run: python fixup_module_bazel.py ${{ github.workspace}}/nanobind_example
- name: Build and test nanobind_example on ${{ matrix.os }}
# --no-sync is required so that uv does not remove the .so file again.
run: |
python -m build . -w
python -m pip install --find-links=dist/ nanobind_example
python -c "import nanobind_example; assert nanobind_example.add(1, 2) == 3"
uv sync --no-editable
uv run --no-sync -- python -c "import nanobind_example; assert nanobind_example.add(1, 2) == 3"
working-directory: ${{ github.workspace }}/nanobind_example
- name: Check ${{ matrix.os }} CPython>=3.12 wheels for stable ABI violations
if: matrix.py >= 3.12
if: ${{ contains(fromJSON('["3.12", "3.13"]'), matrix.python-version) }}
run: |
python -m pip install --upgrade abi3audit
python -m abi3audit dist/*.whl --verbose
uv pip install abi3audit
uv build --wheel
uv run --no-sync abi3audit dist/*.whl --verbose --summary
shell: bash
working-directory: ${{ github.workspace }}/nanobind_example
13 changes: 13 additions & 0 deletions stubgen.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/src/BUILD b/src/BUILD
index 5562dca..95e210e 100644
--- a/src/BUILD
+++ b/src/BUILD
@@ -20,6 +20,6 @@ nanobind_stubgen(
name = "nanobind_example_ext_stubgen",
module = ":nanobind_example_ext",
marker_file = "src/py.typed",
- output_directory = "src",
- recursive = True,
+# output_directory = "src",
+# recursive = True,
)

0 comments on commit d378ffc

Please sign in to comment.