Skip to content

Commit b900b0f

Browse files
authored
Test CLI options on CI (#130)
1 parent 10ebca3 commit b900b0f

File tree

3 files changed

+160
-121
lines changed

3 files changed

+160
-121
lines changed

.github/workflows/ci.yml

Lines changed: 120 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1,87 +1,126 @@
11
name: CI
22

33
on:
4-
workflow_dispatch:
5-
pull_request:
6-
push:
7-
branches:
8-
- master
4+
workflow_dispatch:
5+
pull_request:
6+
push:
7+
branches:
8+
- master
99

1010
jobs:
1111

12-
format:
13-
name: Format code
14-
runs-on: ubuntu-latest
15-
steps:
16-
- name: Setup Python
17-
uses: actions/setup-python@v4
18-
with:
19-
python-version: '3.11'
20-
- name: Checkout
21-
uses: actions/checkout@v3
22-
- name: Install requirements
23-
run: pip install -r requirements-dev.txt
24-
- name: Run isort
25-
run: isort --check --profile=black --diff ./pybind11_stubgen
26-
if: ${{ failure() || success() }}
27-
- name: Run black
28-
run: black --diff ./pybind11_stubgen
29-
if: ${{ failure() || success() }}
30-
- name: Run flake8
31-
run: |
32-
flake8 \
33-
--max-line-length=88 \
34-
--extend-ignore=E203 \
35-
--extend-exclude=venv/,.pytest_cache/,.ipynb_checkpoints/,tests/,tmp/,build/
36-
if: ${{ failure() || success() }}
37-
38-
tests:
39-
name: "🐍 ${{ matrix.python }} • pybind-${{ matrix.pybind11-branch }}"
40-
runs-on: ubuntu-latest
41-
strategy:
42-
fail-fast: false
43-
matrix:
44-
pybind11-branch: [ "master" ]
45-
python:
46-
- "3.11"
47-
- "3.10"
48-
- "3.9"
49-
- "3.8"
50-
- "3.7"
51-
steps:
52-
- uses: actions/checkout@v3
53-
54-
- name: Setup Python ${{ matrix.python }}
55-
uses: actions/setup-python@v4
56-
with:
57-
python-version: ${{ matrix.python }}
58-
59-
- name: Update CMake
60-
uses: jwlawson/[email protected]
61-
62-
- name: Setup annotations on Linux
63-
if: runner.os == 'Linux'
64-
run: python -m pip install pytest-github-actions-annotate-failures
65-
66-
- name: Install requirements
67-
run: pip install -r "./tests/stubs/python-${{ matrix.python }}/requirements.txt"
68-
69-
- name: Install pybind11-stubgen
70-
run: pip install .
71-
72-
- name: Install demo module
73-
shell: bash
74-
run: ./tests/install-demo-module.sh --pybind11-branch "${{ matrix.pybind11-branch }}"
75-
76-
- name: Check stubs generation
77-
shell: bash
78-
run: ./tests/check-demo-stubs-generation.sh --stubs-sub-dir "stubs/python-${{ matrix.python }}/pybind11-${{ matrix.pybind11-branch }}"
79-
80-
- name: Archive patch
81-
uses: actions/upload-artifact@v3
82-
if: failure()
83-
with:
84-
name: "python-${{ matrix.python }}-pybind-${{ matrix.pybind11-branch }}.patch"
85-
path: "./tests/stubs/python-${{ matrix.python }}/pybind11-${{ matrix.pybind11-branch }}.patch"
86-
retention-days: 30
87-
if-no-files-found: ignore
12+
format:
13+
name: Format code
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Setup Python
17+
uses: actions/setup-python@v4
18+
with:
19+
python-version: '3.11'
20+
- name: Checkout
21+
uses: actions/checkout@v3
22+
- name: Install requirements
23+
run: pip install -r requirements-dev.txt
24+
- name: Run isort
25+
run: isort --check --profile=black --diff ./pybind11_stubgen
26+
if: ${{ failure() || success() }}
27+
- name: Run black
28+
run: black --diff ./pybind11_stubgen
29+
if: ${{ failure() || success() }}
30+
- name: Run flake8
31+
run: |
32+
flake8 \
33+
--max-line-length=88 \
34+
--extend-ignore=E203 \
35+
--extend-exclude=venv/,.pytest_cache/,.ipynb_checkpoints/,tests/,tmp/,build/
36+
if: ${{ failure() || success() }}
37+
38+
tests:
39+
name: "Test 🐍 ${{ matrix.python }} • pybind-${{ matrix.pybind11-branch }}"
40+
runs-on: ubuntu-latest
41+
strategy:
42+
fail-fast: false
43+
matrix:
44+
pybind11-branch: [ "master" ]
45+
python:
46+
- "3.11"
47+
- "3.10"
48+
- "3.9"
49+
- "3.8"
50+
- "3.7"
51+
steps:
52+
- uses: actions/checkout@v3
53+
54+
- name: Setup Python ${{ matrix.python }}
55+
uses: actions/setup-python@v4
56+
with:
57+
python-version: ${{ matrix.python }}
58+
59+
- name: Update CMake
60+
uses: jwlawson/[email protected]
61+
62+
- name: Setup annotations on Linux
63+
if: runner.os == 'Linux'
64+
run: python -m pip install pytest-github-actions-annotate-failures
65+
66+
- name: Install requirements
67+
run: pip install -r "./tests/stubs/python-${{ matrix.python }}/requirements.txt"
68+
69+
- name: Install pybind11-stubgen
70+
run: pip install .
71+
72+
- name: Install demo module
73+
shell: bash
74+
run: ./tests/install-demo-module.sh --pybind11-branch "${{ matrix.pybind11-branch }}"
75+
76+
- name: Check stubs generation
77+
shell: bash
78+
run: ./tests/check-demo-stubs-generation.sh --stubs-sub-dir "stubs/python-${{ matrix.python }}/pybind11-${{ matrix.pybind11-branch }}"
79+
80+
- name: Archive patch
81+
uses: actions/upload-artifact@v3
82+
if: failure()
83+
with:
84+
name: "python-${{ matrix.python }}-pybind-${{ matrix.pybind11-branch }}.patch"
85+
path: "./tests/stubs/python-${{ matrix.python }}/pybind11-${{ matrix.pybind11-branch }}.patch"
86+
retention-days: 30
87+
if-no-files-found: ignore
88+
test-cli-options:
89+
name: "Runs on 🐍 ${{ matrix.python }} • ${{ matrix.test-package }}"
90+
runs-on: ubuntu-latest
91+
strategy:
92+
fail-fast: false
93+
matrix:
94+
test-package: [ "gemmi" ]
95+
python:
96+
- "3.11"
97+
- "3.10"
98+
- "3.9"
99+
- "3.8"
100+
- "3.7"
101+
steps:
102+
- uses: actions/checkout@v3
103+
104+
- name: Setup Python ${{ matrix.python }}
105+
uses: actions/setup-python@v4
106+
with:
107+
python-version: ${{ matrix.python }}
108+
109+
- name: Setup annotations on Linux
110+
if: runner.os == 'Linux'
111+
run: python -m pip install pytest-github-actions-annotate-failures
112+
113+
- name: Install pybind11-stubgen
114+
run: pip install .
115+
116+
- name: "Install ${{ matrix.test-package }}"
117+
shell: bash
118+
run: pip install "${{ matrix.test-package }}"
119+
120+
- name: Generate stubs
121+
shell: bash
122+
run: |
123+
pybind11-stubgen "${{ matrix.test-package }}" -o flavour-1 --numpy-array-wrap-with-annotated
124+
pybind11-stubgen "${{ matrix.test-package }}" -o flavour-2 --numpy-array-remove-parameters
125+
pybind11-stubgen "${{ matrix.test-package }}" -o flavour-3 --print-invalid-expressions-as-is
126+
pybind11-stubgen "${{ matrix.test-package }}" --dry-run

.github/workflows/deploy.yml

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,45 @@
11
name: Build and upload to PyPI
22

33
on:
4-
workflow_dispatch:
5-
push:
6-
branches:
7-
- master
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- master
88

99
jobs:
1010

11-
build_dist:
12-
name: Build distributions
13-
runs-on: ubuntu-latest
14-
15-
steps:
16-
- uses: actions/checkout@v2
17-
18-
- name: Setup Python ${{ matrix.python }}
19-
uses: actions/setup-python@v2
20-
with:
21-
python-version: "3.10"
22-
23-
- name: Build dist
24-
run: pipx run build --sdist --wheel
25-
26-
- uses: actions/upload-artifact@v2
27-
with:
28-
path: |
29-
dist/*.tar.gz
30-
dist/*.whl
31-
32-
upload_pypi:
33-
needs: [build_dist]
34-
runs-on: ubuntu-latest
35-
36-
steps:
37-
- uses: actions/download-artifact@v2
38-
with:
39-
name: artifact
40-
path: dist
41-
42-
- uses: pypa/[email protected]
43-
with:
44-
user: __token__
45-
password: ${{ secrets.PYPI_API_TOKEN }}
11+
build_dist:
12+
name: Build distributions
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- uses: actions/checkout@v3
17+
18+
- name: Setup Python ${{ matrix.python }}
19+
uses: actions/setup-python@v2
20+
with:
21+
python-version: "3.10"
22+
23+
- name: Build dist
24+
run: pipx run build --sdist --wheel
25+
26+
- uses: actions/upload-artifact@v2
27+
with:
28+
path: |
29+
dist/*.tar.gz
30+
dist/*.whl
31+
32+
upload_pypi:
33+
needs: [ build_dist ]
34+
runs-on: ubuntu-latest
35+
36+
steps:
37+
- uses: actions/download-artifact@v2
38+
with:
39+
name: artifact
40+
path: dist
41+
42+
- uses: pypa/[email protected]
43+
with:
44+
user: __token__
45+
password: ${{ secrets.PYPI_API_TOKEN }}

pybind11_stubgen/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def regex(pattern_str: str) -> re.Pattern:
113113
default=False,
114114
action="store_true",
115115
help="Replace numpy/scipy arrays of "
116-
"'ARRAY_T[<TYPE>, [*DIMS], *FLAGS]' format with "
116+
"'ARRAY_T[TYPE, [*DIMS], *FLAGS]' format with "
117117
"'Annotated[ARRAY_T, TYPE, FixedSize|DynamicSize(*DIMS), *FLAGS]'",
118118
)
119119

0 commit comments

Comments
 (0)