Skip to content

Commit 25b132b

Browse files
authored
🧪 Add Github action CI and Deployment (#1)
1 parent 7a824ea commit 25b132b

File tree

9 files changed

+265
-3
lines changed

9 files changed

+265
-3
lines changed

.github/dependabot.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# To get started with Dependabot version updates, you'll need to specify which
2+
# package ecosystems to update and where the package manifests are located.
3+
# Please see the documentation for all configuration options:
4+
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5+
6+
version: 2
7+
updates:
8+
- package-ecosystem: github-actions
9+
directory: /
10+
commit-message:
11+
prefix: ⬆️
12+
schedule:
13+
interval: weekly
14+
- package-ecosystem: pip
15+
directory: /
16+
commit-message:
17+
prefix: ⬆️
18+
schedule:
19+
interval: weekly
20+
- package-ecosystem: cargo
21+
directory: /
22+
commit-message:
23+
prefix: ⬆️
24+
schedule:
25+
interval: weekly

.github/workflows/CI.yml

Lines changed: 221 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,221 @@
1+
# This file is autogenerated by maturin v1.0.1
2+
# To update, run
3+
#
4+
# maturin generate-ci github --pytest
5+
#
6+
name: CI
7+
8+
on:
9+
push:
10+
branches:
11+
- main
12+
tags:
13+
- 'v*'
14+
pull_request:
15+
workflow_dispatch:
16+
17+
permissions:
18+
contents: read
19+
20+
jobs:
21+
22+
pre-commit:
23+
runs-on: ubuntu-latest
24+
steps:
25+
- uses: actions/checkout@v3
26+
- uses: actions/setup-python@v4
27+
with:
28+
python-version: "3.9"
29+
- uses: pre-commit/action@v3.0.0
30+
31+
test-python:
32+
33+
runs-on: ubuntu-latest
34+
strategy:
35+
fail-fast: false
36+
matrix:
37+
python-version:
38+
- '3.9'
39+
- '3.10'
40+
- '3.11'
41+
- '3.12'
42+
- 'pypy3.9'
43+
steps:
44+
- uses: actions/checkout@v3
45+
- name: install rust stable
46+
uses: dtolnay/rust-toolchain@stable
47+
- name: cache rust
48+
uses: Swatinem/rust-cache@v2
49+
with:
50+
key: test-v1
51+
- name: set up python
52+
uses: actions/setup-python@v4
53+
with:
54+
python-version: ${{ matrix.python-version }}
55+
- run: pip install -e .[testing]
56+
env:
57+
RUST_BACKTRACE: 1
58+
- run: pip freeze
59+
# - run: pytest
60+
61+
linux:
62+
runs-on: ubuntu-latest
63+
strategy:
64+
fail-fast: false
65+
matrix:
66+
target:
67+
- x86_64
68+
- x86
69+
- aarch64
70+
- armv7
71+
- s390x # TODO build fails: "error: failed to run custom build command for `psm v0.1.21`""
72+
- ppc64le
73+
steps:
74+
- uses: actions/checkout@v3
75+
- uses: actions/setup-python@v4
76+
with:
77+
python-version: "3.10"
78+
- name: Build wheels
79+
uses: PyO3/maturin-action@v1
80+
with:
81+
target: ${{ matrix.target }}
82+
args: --release --out dist --find-interpreter
83+
sccache: 'true'
84+
manylinux: auto
85+
- name: Upload wheels
86+
uses: actions/upload-artifact@v3
87+
with:
88+
name: wheels
89+
path: dist
90+
# - name: pytest
91+
# if: ${{ startsWith(matrix.target, 'x86_64') }}
92+
# shell: bash
93+
# run: |
94+
# set -e
95+
# pip install --upgrade pip
96+
# pip install sphinx_rust --find-links dist --force-reinstall
97+
# pip install pytest pytest-param-files
98+
# pytest
99+
# - name: pytest
100+
# if: ${{ !startsWith(matrix.target, 'x86') && matrix.target != 'ppc64' }}
101+
# uses: uraimo/run-on-arch-action@v2.5.0
102+
# with:
103+
# arch: ${{ matrix.target }}
104+
# distro: ubuntu22.04
105+
# githubToken: ${{ github.token }}
106+
# install: |
107+
# apt-get update
108+
# apt-get install -y --no-install-recommends python3-dev python3-pip build-essential
109+
# pip3 install -U pip pytest pytest-param-files
110+
# run: |
111+
# set -e
112+
# pip3 install sphinx_rust --find-links dist --force-reinstall
113+
# pytest
114+
115+
windows:
116+
runs-on: windows-latest
117+
strategy:
118+
fail-fast: false
119+
matrix:
120+
target: [x64, x86]
121+
steps:
122+
- uses: actions/checkout@v3
123+
- uses: actions/setup-python@v4
124+
with:
125+
python-version: '3.10'
126+
architecture: ${{ matrix.target }}
127+
- name: Build wheels
128+
uses: PyO3/maturin-action@v1
129+
with:
130+
target: ${{ matrix.target }}
131+
args: --release --out dist --find-interpreter
132+
sccache: 'true'
133+
- name: Upload wheels
134+
uses: actions/upload-artifact@v3
135+
with:
136+
name: wheels
137+
path: dist
138+
# - name: pytest
139+
# if: ${{ !startsWith(matrix.target, 'aarch64') }}
140+
# shell: bash
141+
# run: |
142+
# set -e
143+
# pip install --upgrade pip
144+
# pip install sphinx_rust --find-links dist --force-reinstall
145+
# pip install pytest pytest-param-files
146+
# pytest
147+
148+
macos:
149+
runs-on: macos-latest
150+
strategy:
151+
fail-fast: false
152+
matrix:
153+
target: [x86_64, aarch64]
154+
steps:
155+
- uses: actions/checkout@v3
156+
- uses: actions/setup-python@v4
157+
with:
158+
python-version: '3.10'
159+
- name: Build wheels
160+
uses: PyO3/maturin-action@v1
161+
with:
162+
target: ${{ matrix.target }}
163+
args: --release --out dist --find-interpreter
164+
sccache: 'true'
165+
- name: Upload wheels
166+
uses: actions/upload-artifact@v3
167+
with:
168+
name: wheels
169+
path: dist
170+
# - name: pytest
171+
# if: ${{ !startsWith(matrix.target, 'aarch64') }}
172+
# shell: bash
173+
# run: |
174+
# set -e
175+
# pip install --upgrade pip
176+
# pip install sphinx_rust --find-links dist --force-reinstall
177+
# pip install pytest pytest-param-files
178+
# pytest
179+
180+
sdist:
181+
runs-on: ubuntu-latest
182+
steps:
183+
- uses: actions/checkout@v3
184+
- name: Build sdist
185+
uses: PyO3/maturin-action@v1
186+
with:
187+
command: sdist
188+
args: --out dist
189+
- name: Upload sdist
190+
uses: actions/upload-artifact@v3
191+
with:
192+
name: wheels
193+
path: dist
194+
195+
# https://github.com/marketplace/actions/alls-green#why used for branch protection checks
196+
check:
197+
if: always()
198+
needs: [pre-commit, test-python, linux, windows, macos, sdist]
199+
runs-on: ubuntu-latest
200+
steps:
201+
- name: Decide whether the needed jobs succeeded or failed
202+
uses: re-actors/alls-green@release/v1
203+
with:
204+
jobs: ${{ toJSON(needs) }}
205+
allowed-failures: coverage
206+
207+
release:
208+
runs-on: ubuntu-latest
209+
if: "startsWith(github.ref, 'refs/tags/')"
210+
needs: [pre-commit, test-python, linux, windows, macos, sdist]
211+
steps:
212+
- uses: actions/download-artifact@v3
213+
with:
214+
name: wheels
215+
- name: Publish to PyPI
216+
uses: PyO3/maturin-action@v1
217+
env:
218+
MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
219+
with:
220+
command: upload
221+
args: --skip-existing *

.pre-commit-config.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# See https://pre-commit.com for more information
22
# See https://pre-commit.com/hooks.html for more hooks
3+
4+
ci:
5+
skip: [cargo-check, cargo-clippy] # failing on pre-commit.ci (wrong rust version?)
6+
37
repos:
48
- repo: https://github.com/pre-commit/pre-commit-hooks
59
rev: v4.6.0

python/sphinx_rust/directives/_core.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
from typing import TYPE_CHECKING
24

35
from docutils import nodes, utils
@@ -28,7 +30,7 @@ def doc(self) -> nodes.document:
2830
return self.state.document # type: ignore[no-any-return]
2931

3032
@property
31-
def rust_domain(self) -> "RustDomain":
33+
def rust_domain(self) -> RustDomain:
3234
# avoid circular import
3335
from sphinx_rust.domain import RustDomain # noqa: PLC0415
3436

@@ -81,7 +83,7 @@ def create_summary_table(
8183

8284

8385
def parse_docstring(
84-
env: "BuildEnvironment",
86+
env: BuildEnvironment,
8587
doc: nodes.document,
8688
docstring: str,
8789
/,
@@ -105,7 +107,7 @@ def parse_docstring(
105107

106108

107109
def create_xref(
108-
docname: str, ident: str, objtype: "ObjType", *, warn_dangling: bool = False
110+
docname: str, ident: str, objtype: ObjType, *, warn_dangling: bool = False
109111
) -> addnodes.pending_xref:
110112
"""Create a cross-reference node."""
111113
options = {

python/sphinx_rust/directives/crate.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
from typing import TYPE_CHECKING
24

35
from docutils import nodes

python/sphinx_rust/directives/enum.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
from typing import TYPE_CHECKING
24

35
from docutils import nodes

python/sphinx_rust/directives/module.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
from typing import TYPE_CHECKING
24

35
from docutils import nodes

python/sphinx_rust/directives/struct.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
from typing import TYPE_CHECKING
24

35
from docutils import nodes

python/sphinx_rust/roles.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
from sphinx.roles import XRefRole
24

35

0 commit comments

Comments
 (0)