Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix job skip condition by interpreting Python version as int #47

Merged
merged 12 commits into from
Dec 18, 2024
Merged
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,
)
Loading