Skip to content

Commit 59dd50a

Browse files
author
amiya
committed
Update CI.yml
1 parent 2522687 commit 59dd50a

1 file changed

Lines changed: 62 additions & 91 deletions

File tree

.github/workflows/CI.yml

Lines changed: 62 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# CI/CD workflow for vjson
2-
# - Runs tests and linting on PRs and pushes
3-
# - Builds wheels for all platforms
1+
# CI/CD workflow for vjson (PyO3/Maturin)
2+
# - Runs tests on PRs and pushes
3+
# - Builds wheels for all platforms using maturin-action
44
# - Auto-tags and publishes to PyPI on main branch
55

66
name: CI
@@ -12,7 +12,7 @@ on:
1212
- master
1313
- develop
1414
tags:
15-
- "*"
15+
- "v*"
1616
pull_request:
1717
branches:
1818
- main
@@ -26,81 +26,86 @@ permissions:
2626

2727
env:
2828
CARGO_TERM_COLOR: always
29-
PYTHON_VERSION: "3.12"
29+
CARGO_INCREMENTAL: 0
30+
RUSTFLAGS: "-D warnings"
3031

3132
jobs:
3233
# ============================================================
33-
# Test & Lint
34+
# Test (Rust + Python)
3435
# ============================================================
3536
test:
36-
name: Test & Lint
37-
runs-on: ubuntu-latest
37+
name: Test
38+
runs-on: ${{ matrix.os }}
39+
strategy:
40+
fail-fast: false
41+
matrix:
42+
os: [ubuntu-latest, macos-latest, windows-latest]
43+
python-version: ["3.9", "3.12"]
3844
steps:
3945
- uses: actions/checkout@v4
4046

4147
- name: Install Rust toolchain
4248
uses: dtolnay/rust-toolchain@stable
43-
with:
44-
components: rustfmt, clippy
4549

46-
- name: Cache cargo
47-
uses: actions/cache@v4
50+
- name: Rust cache
51+
uses: Swatinem/rust-cache@v2
4852
with:
49-
path: |
50-
~/.cargo/bin/
51-
~/.cargo/registry/index/
52-
~/.cargo/registry/cache/
53-
~/.cargo/git/db/
54-
target/
55-
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
56-
57-
- name: Run clippy
58-
run: cargo clippy --all-features -- -D warnings
53+
workspaces: ". -> target"
5954

6055
- name: Run Rust tests
6156
run: cargo test --all-features
6257

63-
- name: Set up Python
58+
- name: Set up Python ${{ matrix.python-version }}
6459
uses: actions/setup-python@v5
6560
with:
66-
python-version: ${{ env.PYTHON_VERSION }}
67-
68-
- name: Install dependencies
69-
run: |
70-
pip install maturin pytest numpy
61+
python-version: ${{ matrix.python-version }}
7162

72-
- name: Build and install
73-
run: maturin develop
63+
- name: Install uv
64+
uses: astral-sh/setup-uv@v4
7465

75-
- name: Run Python tests
76-
run: pytest tests/ -v --ignore=tests/test_simple.py || true
66+
- name: Build and test with maturin
67+
run: |
68+
uv pip install --system maturin pytest numpy
69+
maturin build --release
70+
uv pip install --system target/wheels/*.whl --force-reinstall
71+
pytest tests/ -v --ignore=tests/test_simple.py
7772
7873
# ============================================================
7974
# Build wheels for Linux (manylinux)
8075
# ============================================================
8176
linux:
8277
name: Linux - ${{ matrix.target }}
8378
needs: [test]
84-
runs-on: ubuntu-latest
79+
runs-on: ${{ matrix.runner }}
8580
strategy:
8681
fail-fast: false
8782
matrix:
88-
target:
89-
- x86_64
90-
- aarch64
83+
include:
84+
- target: x86_64-unknown-linux-gnu
85+
runner: ubuntu-latest
86+
- target: x86_64-unknown-linux-musl
87+
runner: ubuntu-latest
88+
- target: aarch64-unknown-linux-gnu
89+
runner: ubuntu-latest
90+
- target: aarch64-unknown-linux-musl
91+
runner: ubuntu-latest
92+
- target: i686-unknown-linux-gnu
93+
runner: ubuntu-latest
94+
- target: armv7-unknown-linux-gnueabihf
95+
runner: ubuntu-latest
9196
steps:
9297
- uses: actions/checkout@v4
9398

9499
- uses: actions/setup-python@v5
95100
with:
96-
python-version: ${{ env.PYTHON_VERSION }}
101+
python-version: "3.12"
97102

98103
- name: Build wheels
99104
uses: PyO3/maturin-action@v1
100105
with:
101106
target: ${{ matrix.target }}
102-
args: --release --out dist --find-interpreter
103-
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
107+
args: --release --out dist
108+
sccache: "true"
104109
manylinux: auto
105110

106111
- name: Upload wheels
@@ -110,41 +115,6 @@ jobs:
110115
path: dist/*.whl
111116
if-no-files-found: error
112117

113-
# ============================================================
114-
# Build wheels for Linux (musllinux)
115-
# ============================================================
116-
musllinux:
117-
name: Musllinux - ${{ matrix.target }}
118-
needs: [test]
119-
runs-on: ubuntu-latest
120-
strategy:
121-
fail-fast: false
122-
matrix:
123-
target:
124-
- x86_64
125-
- aarch64
126-
steps:
127-
- uses: actions/checkout@v4
128-
129-
- uses: actions/setup-python@v5
130-
with:
131-
python-version: ${{ env.PYTHON_VERSION }}
132-
133-
- name: Build wheels
134-
uses: PyO3/maturin-action@v1
135-
with:
136-
target: ${{ matrix.target }}
137-
args: --release --out dist --find-interpreter
138-
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
139-
manylinux: musllinux_1_2
140-
141-
- name: Upload wheels
142-
uses: actions/upload-artifact@v4
143-
with:
144-
name: wheels-musllinux-${{ matrix.target }}
145-
path: dist/*.whl
146-
if-no-files-found: error
147-
148118
# ============================================================
149119
# Build wheels for Windows
150120
# ============================================================
@@ -156,21 +126,21 @@ jobs:
156126
fail-fast: false
157127
matrix:
158128
target:
159-
- x64
129+
- x86_64-pc-windows-msvc
130+
- i686-pc-windows-msvc
160131
steps:
161132
- uses: actions/checkout@v4
162133

163134
- uses: actions/setup-python@v5
164135
with:
165-
python-version: ${{ env.PYTHON_VERSION }}
166-
architecture: ${{ matrix.target }}
136+
python-version: "3.12"
167137

168138
- name: Build wheels
169139
uses: PyO3/maturin-action@v1
170140
with:
171141
target: ${{ matrix.target }}
172-
args: --release --out dist --find-interpreter
173-
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
142+
args: --release --out dist
143+
sccache: "true"
174144

175145
- name: Upload wheels
176146
uses: actions/upload-artifact@v4
@@ -191,22 +161,22 @@ jobs:
191161
matrix:
192162
include:
193163
- runner: macos-13
194-
target: x86_64
164+
target: x86_64-apple-darwin
195165
- runner: macos-14
196-
target: aarch64
166+
target: aarch64-apple-darwin
197167
steps:
198168
- uses: actions/checkout@v4
199169

200170
- uses: actions/setup-python@v5
201171
with:
202-
python-version: ${{ env.PYTHON_VERSION }}
172+
python-version: "3.12"
203173

204174
- name: Build wheels
205175
uses: PyO3/maturin-action@v1
206176
with:
207177
target: ${{ matrix.target }}
208-
args: --release --out dist --find-interpreter
209-
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
178+
args: --release --out dist
179+
sccache: "true"
210180

211181
- name: Upload wheels
212182
uses: actions/upload-artifact@v4
@@ -243,7 +213,7 @@ jobs:
243213
# ============================================================
244214
auto_release:
245215
name: Auto Tag & Release
246-
needs: [linux, musllinux, windows, macos, sdist]
216+
needs: [linux, windows, macos, sdist]
247217
runs-on: ubuntu-latest
248218
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master')
249219
outputs:
@@ -282,7 +252,7 @@ jobs:
282252
git tag -a "v${{ steps.get_version.outputs.version }}" -m "Release v${{ steps.get_version.outputs.version }}"
283253
git push origin "v${{ steps.get_version.outputs.version }}"
284254
285-
- name: Download all wheels
255+
- name: Download all artifacts
286256
if: steps.check_tag.outputs.should_release == 'true'
287257
uses: actions/download-artifact@v4
288258
with:
@@ -306,7 +276,7 @@ jobs:
306276
prerelease: false
307277

308278
# ============================================================
309-
# Publish to PyPI
279+
# Publish to PyPI (auto-release)
310280
# ============================================================
311281
publish:
312282
name: Publish to PyPI
@@ -319,7 +289,7 @@ jobs:
319289
permissions:
320290
id-token: write
321291
steps:
322-
- name: Download all wheels
292+
- name: Download all artifacts
323293
uses: actions/download-artifact@v4
324294
with:
325295
path: dist/
@@ -341,19 +311,20 @@ jobs:
341311
# ============================================================
342312
publish_on_tag:
343313
name: Publish (Tag)
344-
needs: [linux, musllinux, windows, macos, sdist]
314+
needs: [linux, windows, macos, sdist]
345315
runs-on: ubuntu-latest
346-
if: startsWith(github.ref, 'refs/tags/')
316+
if: startsWith(github.ref, 'refs/tags/v')
347317
environment:
348318
name: pypi
349319
url: https://pypi.org/p/vjson
350320
permissions:
351321
id-token: write
352322
contents: write
323+
attestations: write
353324
steps:
354325
- uses: actions/checkout@v4
355326

356-
- name: Download all wheels
327+
- name: Download all artifacts
357328
uses: actions/download-artifact@v4
358329
with:
359330
path: dist/

0 commit comments

Comments
 (0)