-
Notifications
You must be signed in to change notification settings - Fork 3
167 lines (137 loc) · 4.25 KB
/
python.yml
File metadata and controls
167 lines (137 loc) · 4.25 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
# CI for bashkit Python package
# Builds the native extension via maturin and runs pytest on each PR.
# Complements publish-python.yml (release-only) with per-PR validation.
name: Python
on:
push:
branches: [main]
paths:
- "crates/bashkit-python/**"
- "crates/bashkit/**"
- "Cargo.toml"
- "Cargo.lock"
- ".github/workflows/python.yml"
pull_request:
branches: [main]
paths:
- "crates/bashkit-python/**"
- "crates/bashkit/**"
- "Cargo.toml"
- "Cargo.lock"
- ".github/workflows/python.yml"
workflow_call:
permissions:
contents: read
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
jobs:
lint:
name: Lint & Format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: astral-sh/setup-uv@v7
- name: Ruff check
run: uvx ruff check crates/bashkit-python
- name: Ruff format
run: uvx ruff format --check crates/bashkit-python
- uses: actions/setup-python@v6
with:
python-version: "3.12"
- name: Mypy type check
run: |
pip install mypy
mypy crates/bashkit-python/bashkit/ --ignore-missing-imports
test:
name: Test (Python ${{ matrix.python-version }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.12", "3.13"]
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: Build wheel
uses: PyO3/maturin-action@v1
with:
command: build
args: --release --out dist -i python${{ matrix.python-version }}
rust-toolchain: stable
working-directory: crates/bashkit-python
- name: Install wheel and test dependencies
run: |
pip install bashkit --no-index --find-links crates/bashkit-python/dist --force-reinstall
pip install pytest pytest-asyncio
- name: Run tests
working-directory: crates/bashkit-python
run: pytest tests/ -v
examples:
name: Examples
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: "3.12"
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: Build wheel
uses: PyO3/maturin-action@v1
with:
command: build
args: --release --out dist -i python3.12
rust-toolchain: stable
working-directory: crates/bashkit-python
- name: Install wheel
run: pip install bashkit --no-index --find-links crates/bashkit-python/dist --force-reinstall
- name: Run examples
run: python crates/bashkit-python/examples/bash_basics.py
# Verify wheel builds and passes twine check
build-wheel:
name: Build wheel
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: "3.12"
- name: Build wheel
uses: PyO3/maturin-action@v1
with:
command: build
args: --release --out dist
rust-toolchain: stable
working-directory: crates/bashkit-python
- name: Verify wheel metadata
run: |
pip install twine
twine check crates/bashkit-python/dist/*
- uses: actions/upload-artifact@v7
with:
name: python-wheel
path: crates/bashkit-python/dist
retention-days: 5
# Gate job for branch protection
python-check:
name: Python Check
if: always()
needs: [lint, test, examples, build-wheel]
runs-on: ubuntu-latest
steps:
- name: Verify all jobs passed
run: |
if [[ "${{ needs.lint.result }}" != "success" ]] || \
[[ "${{ needs.test.result }}" != "success" ]] || \
[[ "${{ needs.examples.result }}" != "success" ]] || \
[[ "${{ needs.build-wheel.result }}" != "success" ]]; then
echo "One or more Python CI jobs failed"
exit 1
fi