Skip to content

Commit 2e00749

Browse files
committed
feat(workflows): use nightly pybind11 with PR label
1 parent 39897df commit 2e00749

6 files changed

Lines changed: 72 additions & 8 deletions

File tree

.github/workflows/build.yml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ env:
4444
jobs:
4545
build-sdist:
4646
name: Build sdist
47-
if: github.repository == 'metaopt/optree' && (github.event_name != 'push' || startsWith(github.ref, 'refs/tags/'))
47+
if: |
48+
github.repository_owner == 'metaopt' &&
49+
(github.event_name != 'push' || startsWith(github.ref, 'refs/tags/'))
4850
runs-on: ubuntu-latest
4951
timeout-minutes: 15
5052
steps:
@@ -86,7 +88,9 @@ jobs:
8688

8789
build-wheels:
8890
name: Build wheels for Python ${{ matrix.python-version }} on ${{ matrix.runner }} (${{ matrix.archs }})
89-
if: github.repository == 'metaopt/optree' && (github.event_name != 'push' || startsWith(github.ref, 'refs/tags/'))
91+
if: |
92+
github.repository_owner == 'metaopt' &&
93+
(github.event_name != 'push' || startsWith(github.ref, 'refs/tags/'))
9094
runs-on: ${{ matrix.runner }}
9195
strategy:
9296
matrix:
@@ -241,7 +245,9 @@ jobs:
241245

242246
list-artifacts:
243247
name: List artifacts
244-
if: github.repository == 'metaopt/optree' && (github.event_name != 'push' || startsWith(github.ref, 'refs/tags/'))
248+
if: |
249+
github.repository_owner == 'metaopt' &&
250+
(github.event_name != 'push' || startsWith(github.ref, 'refs/tags/'))
245251
runs-on: ubuntu-latest
246252
needs: [build-sdist, build-wheels]
247253
timeout-minutes: 15
@@ -275,7 +281,8 @@ jobs:
275281
runs-on: ubuntu-latest
276282
needs: [list-artifacts]
277283
if: |
278-
github.repository == 'metaopt/optree' && github.event_name != 'pull_request' &&
284+
github.repository_owner == 'metaopt' &&
285+
github.event_name != 'pull_request' &&
279286
(github.event_name != 'workflow_dispatch' || github.event.inputs.task == 'build-and-publish') &&
280287
(github.event_name != 'push' || startsWith(github.ref, 'refs/tags/'))
281288
timeout-minutes: 15

.github/workflows/lint.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,18 @@ jobs:
4242
- name: Install dependencies
4343
run: |
4444
python -m pip install wheel pybind11 -r docs/requirements.txt
45-
python -m pip install --force-reinstall pybind11@git+https://github.com/pybind/pybind11.git#egg=pybind11
45+
46+
- name: Install nightly pybind11
47+
shell: bash
48+
if: |
49+
github.event_name == 'pull_request' &&
50+
contains(github.event.pull_request.labels.*.name, 'test-with-nightly-pybind11')
51+
run: |
52+
python .github/workflows/set_setup_requires.py
53+
echo "::group::pyproject.toml"
54+
cat pyproject.toml
55+
echo "::endgroup::"
56+
python -m pip install --force-reinstall 'pybind11 @ git+https://github.com/pybind/pybind11.git#egg=pybind11'
4657
4758
- name: Install OpTree
4859
run: |
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/usr/bin/env python3
2+
3+
# pylint: disable=missing-module-docstring
4+
5+
import re
6+
from pathlib import Path
7+
8+
9+
ROOT = Path(__file__).absolute().parents[2]
10+
11+
PYPROJECT_FILE = ROOT / 'pyproject.toml'
12+
13+
14+
if __name__ == '__main__':
15+
PYPROJECT_CONTENT = PYPROJECT_FILE.read_text(encoding='utf-8')
16+
17+
PYPROJECT_FILE.write_text(
18+
data=re.sub(
19+
r'(requires\s*=\s*\[.*"\s*)\bpybind11\b[^"]*(\s*".*\])',
20+
r'\g<1>pybind11 @ git+https://github.com/pybind/pybind11.git#egg=pybind11\g<2>',
21+
string=PYPROJECT_CONTENT,
22+
),
23+
encoding='utf-8',
24+
)

.github/workflows/tests-with-pydebug.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,17 @@ jobs:
284284
285285
cdb -version
286286
287+
- name: Use nightly pybind11
288+
shell: bash
289+
if: |
290+
github.event_name == 'pull_request' &&
291+
contains(github.event.pull_request.labels.*.name, 'test-with-nightly-pybind11')
292+
run: |
293+
python .github/workflows/set_setup_requires.py
294+
echo "::group::pyproject.toml"
295+
cat pyproject.toml
296+
echo "::endgroup::"
297+
287298
- name: Install OpTree
288299
run: |
289300
${{ env.PYTHON }} -m pip install -v --editable '.[test]'
@@ -311,7 +322,7 @@ jobs:
311322
find . -type f -name '*.py[cod]' -delete
312323
find . -depth -type d -name "__pycache__" -exec rm -r "{}" +
313324
if git status --ignored --porcelain | grep -qvE '/$'; then
314-
ls -alh $(git status --ignored --porcelain | grep -vE '/$' | cut -d ' ' -f2)
325+
ls -alh $(git status --ignored --porcelain | grep -vE '/$' | grep -oE '\S+$')
315326
fi
316327
317328
- name: Collect backtraces from coredumps (if any)

.github/workflows/tests.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,17 @@ jobs:
142142
143143
cdb -version
144144
145+
- name: Use nightly pybind11
146+
shell: bash
147+
if: |
148+
github.event_name == 'pull_request' &&
149+
contains(github.event.pull_request.labels.*.name, 'test-with-nightly-pybind11')
150+
run: |
151+
python .github/workflows/set_setup_requires.py
152+
echo "::group::pyproject.toml"
153+
cat pyproject.toml
154+
echo "::endgroup::"
155+
145156
- name: Test installable with C++17
146157
shell: bash
147158
if: runner.os != 'Windows'
@@ -236,7 +247,7 @@ jobs:
236247
find . -type f -name '*.py[cod]' -delete
237248
find . -depth -type d -name "__pycache__" -exec rm -r "{}" +
238249
if git status --ignored --porcelain | grep -qvE '/$'; then
239-
ls -alh $(git status --ignored --porcelain | grep -vE '/$' | cut -d ' ' -f2)
250+
ls -alh $(git status --ignored --porcelain | grep -vE '/$' | grep -oE '\S+$')
240251
fi
241252
242253
- name: Collect backtraces from coredumps (if any)

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Package ######################################################################
22

33
[build-system]
4-
requires = ["setuptools", "pybind11@git+https://github.com/pybind/pybind11.git#egg=pybind11"]
4+
requires = ["setuptools", "pybind11 >= 2.12"]
55
build-backend = "setuptools.build_meta"
66

77
[project]

0 commit comments

Comments
 (0)