-
Notifications
You must be signed in to change notification settings - Fork 0
229 lines (192 loc) · 6.1 KB
/
ci.yml
File metadata and controls
229 lines (192 loc) · 6.1 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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
name: Python SDK CI/CD
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main ]
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
jobs:
# ============================================
# Job 1: Code Quality & Unit Tests
# ============================================
quality:
name: Code Quality (Rust)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust Toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- name: Cache Cargo Dependencies
uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.lock') }}
- name: Run rustfmt
run: cargo fmt --all -- --check
- name: Run clippy
run: cargo clippy --all-targets --all-features -- -D warnings
- name: Run Rust tests
run: cargo test --verbose
# ============================================
# Job 2: Python Tests (Multi-version)
# ============================================
test:
name: Python Tests (${{ matrix.python-version }})
runs-on: ubuntu-latest
needs: quality
strategy:
fail-fast: false
matrix:
python-version: ['3.9', '3.10', '3.11', '3.12']
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install Rust Toolchain
uses: dtolnay/rust-toolchain@stable
- name: Cache Cargo Dependencies
uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
sdk/python/target/
key: ${{ runner.os }}-cargo-${{ hashFiles('sdk/python/Cargo.lock') }}
- name: Install Python Dependencies
run: |
python -m pip install --upgrade pip
pip install maturin pytest pytest-cov
- name: Build Extension
run: |
maturin build --release --out dist
pip install dist/*.whl --force-reinstall
- name: Run Python Tests
run: |
mkdir test_run
cd test_run
pytest ../tests/ -v --cov=lnmp --cov-report=xml
cd ..
mv test_run/coverage.xml .
- name: Upload Coverage
if: matrix.python-version == '3.11'
uses: codecov/codecov-action@v3
with:
file: ./coverage.xml
flags: python-sdk
# ============================================
# Job 3: Build Wheels (Multi-platform)
# ============================================
build:
name: Build Wheels (${{ matrix.target }})
runs-on: ${{ matrix.os }}
needs: test
if: github.event_name == 'workflow_dispatch'
strategy:
matrix:
include:
# Linux
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
name: linux-x86_64
- os: ubuntu-latest
target: aarch64-unknown-linux-gnu
name: linux-aarch64
# macOS
- os: macos-latest
target: x86_64-apple-darwin
name: macos-x86_64
- os: macos-latest
target: aarch64-apple-darwin
name: macos-arm64
# Windows
- os: windows-latest
target: x86_64-pc-windows-msvc
name: windows-x86_64
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install Rust Toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Install Maturin
run: pip install maturin
- name: Build Wheels
run: maturin build --release --target ${{ matrix.target }} --out dist
- name: Upload Wheels
uses: actions/upload-artifact@v4
with:
name: wheels-${{ matrix.name }}
path: dist/*.whl
# ============================================
# Job 4: Publish to PyPI
# ============================================
publish:
name: Publish to PyPI
runs-on: ubuntu-latest
needs: build
if: github.event_name == 'workflow_dispatch'
environment:
name: pypi
url: https://pypi.org/p/lnmp
permissions:
id-token: write
steps:
- name: Download All Wheels
uses: actions/download-artifact@v4
with:
path: dist
- name: Flatten Dist Directory
run: |
mkdir -p final-dist
find dist -name '*.whl' -exec cp {} final-dist/ \;
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: final-dist/
skip-existing: true
# ============================================
# Job 5: Benchmarks (Optional)
# ============================================
benchmark:
name: Performance Benchmarks
runs-on: ubuntu-latest
needs: quality
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install Rust Toolchain
uses: dtolnay/rust-toolchain@stable
- name: Install Dependencies
run: |
pip install maturin
maturin build --release --out dist
pip install dist/*.whl --force-reinstall
- name: Run Benchmarks
run: python benchmarks/run_benchmarks.py
- name: Upload Benchmark Results
uses: actions/upload-artifact@v4
with:
name: benchmarks
path: BENCHMARKS.md