-
Notifications
You must be signed in to change notification settings - Fork 72
196 lines (169 loc) · 7.7 KB
/
ci.yml
File metadata and controls
196 lines (169 loc) · 7.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
name: CI
on:
workflow_dispatch:
pull_request:
push:
branches:
- master
tags:
- 'v*'
jobs:
build:
name: Build wheel
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: actions/setup-python@v5
with:
python-version: "3.13"
- name: Install build
run: python -m pip --disable-pip-version-check install build
- name: Build sdist + wheel
run: python -m build
- name: Upload build artifacts
uses: actions/upload-artifact@v6
with:
name: dist
path: dist
format:
name: Format code
runs-on: ubuntu-latest
steps:
- name: Setup Python 3.13
uses: actions/setup-python@v5
with:
python-version: "3.13"
- name: Checkout
uses: actions/checkout@v5
- name: Install requirements
run: pip install -r requirements-dev.txt
- name: Run isort
run: isort --check --profile=black --diff ./pybind11_stubgen
if: ${{ failure() || success() }}
- name: Run black
run: black --diff ./pybind11_stubgen
if: ${{ failure() || success() }}
- name: Run flake8
run: |
flake8 \
--max-line-length=88 \
--extend-ignore=E203 \
--extend-exclude=venv/,.pytest_cache/,.ipynb_checkpoints/,tests/,tmp/,build/
if: ${{ failure() || success() }}
tests:
name: "Test 🐍 ${{ matrix.config.python }} • pybind-${{ matrix.config.pybind11-branch }} • ${{ matrix.config.numpy-format }}"
runs-on: ubuntu-latest
needs: [build]
strategy:
fail-fast: false
matrix:
config: [
{ pybind11-branch: "v2.13", python: "3.13", numpy-format: "numpy-array-use-type-var"},
{ pybind11-branch: "v2.13", python: "3.13", numpy-format: "numpy-array-wrap-with-annotated"},
{ pybind11-branch: "v2.13", python: "3.12", numpy-format: "numpy-array-wrap-with-annotated"},
{ pybind11-branch: "v2.13", python: "3.11", numpy-format: "numpy-array-wrap-with-annotated"},
{ pybind11-branch: "v2.13", python: "3.10", numpy-format: "numpy-array-wrap-with-annotated"},
{ pybind11-branch: "v2.12", python: "3.13", numpy-format: "numpy-array-wrap-with-annotated"},
{ pybind11-branch: "v2.11", python: "3.13", numpy-format: "numpy-array-wrap-with-annotated"},
{ pybind11-branch: "v2.9", python: "3.13", numpy-format: "numpy-array-wrap-with-annotated"},
]
steps:
- uses: actions/checkout@v5
- name: Download build artifacts
uses: actions/download-artifact@v6
with:
name: dist
path: dist
- name: Setup Python ${{ matrix.config.python }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.config.python }}
- name: Update CMake
uses: jwlawson/actions-setup-cmake@v2
with:
# https://github.com/pybind/pybind11/blob/914c06fb252b6cc3727d0eedab6736e88a3fcb01/CMakeLists.txt#L13C34-L13C38
cmake-version: '3.22.x'
- name: Setup annotations on Linux
if: runner.os == 'Linux'
run: python -m pip install pytest-github-actions-annotate-failures
- name: Install requirements
run: pip install -r "./tests/stubs/python-${{ matrix.config.python }}/requirements.txt"
- name: Install
shell: bash
working-directory: dist
run: python -m pip --disable-pip-version-check install *.whl
- name: Install demo module
shell: bash
run: ./tests/install-demo-module.sh --pybind11-branch "${{ matrix.config.pybind11-branch }}"
- name: Check stubs generation
shell: bash
run: ./tests/check-demo-stubs-generation.sh --stubs-sub-dir "stubs/python-${{ matrix.config.python }}/pybind11-${{ matrix.config.pybind11-branch }}/${{ matrix.config.numpy-format }}" --${{ matrix.config.numpy-format }}
- name: Archive patch
uses: actions/upload-artifact@v6
if: failure()
with:
name: "python-${{ matrix.config.python }}-pybind-${{ matrix.config.pybind11-branch }}-${{ matrix.config.numpy-format }}.patch"
path: "./tests/stubs/python-${{ matrix.config.python }}/pybind11-${{ matrix.config.pybind11-branch }}/${{ matrix.config.numpy-format }}.patch"
retention-days: 30
if-no-files-found: ignore
- name: Check error generation
shell: bash
run: ./tests/check-demo-errors-generation.sh
test-cli-options:
name: "Runs on 🐍 ${{ matrix.python }} • ${{ matrix.test-package }}"
runs-on: ubuntu-latest
needs: [build]
strategy:
fail-fast: false
matrix:
test-package: [ "gemmi" ]
python:
- "3.13"
- "3.12"
- "3.11"
- "3.10"
steps:
- uses: actions/checkout@v5
- name: Setup Python ${{ matrix.python }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
- name: Download build artifacts
uses: actions/download-artifact@v6
with:
name: dist
path: dist
- name: Setup annotations on Linux
if: runner.os == 'Linux'
run: python -m pip install pytest-github-actions-annotate-failures
- name: Install
shell: bash
working-directory: dist
run: python -m pip --disable-pip-version-check install *.whl
- name: "Install ${{ matrix.test-package }}"
shell: bash
run: pip install "${{ matrix.test-package }}"
- name: Generate stubs
shell: bash
run: |
pybind11-stubgen "${{ matrix.test-package }}" -o flavour-1 --numpy-array-wrap-with-annotated
pybind11-stubgen "${{ matrix.test-package }}" -o flavour-2 --numpy-array-remove-parameters
pybind11-stubgen "${{ matrix.test-package }}" -o flavour-3 --print-invalid-expressions-as-is
pybind11-stubgen "${{ matrix.test-package }}" -o flavour-4 --numpy-array-use-type-var
pybind11-stubgen "${{ matrix.test-package }}" --dry-run
publish:
name: Publish distribution
needs : [build, format, tests, test-cli-options]
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
runs-on: ubuntu-latest
permissions:
# IMPORTANT: this permission is mandatory for Trusted Publishing
id-token: write
steps:
- name: Download build artifacts
uses: actions/download-artifact@v6
with:
name: dist
path: dist
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1