Skip to content

Commit 38cc713

Browse files
committed
ci: add GitHub Actions workflows (tests, format, release)
- tests.yml: Rust, Python (3.10-3.13), WASM - format.yml: ruff format check - release.yml: PyPI publish on release via maturin-action Made-with: Cursor
1 parent 759f51e commit 38cc713

4 files changed

Lines changed: 131 additions & 1 deletion

File tree

.github/workflows/format.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Formatter
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches: [main, develop]
7+
tags: ["v*"]
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
format:
14+
name: Formatter check (ruff)
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Setup Python
20+
uses: actions/setup-python@v5
21+
with:
22+
python-version: "3.12"
23+
cache: pip
24+
25+
- name: Install ruff
26+
run: pip install ruff
27+
28+
- name: Check formatting
29+
run: ruff format --check .

.github/workflows/release.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Release
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
permissions:
8+
contents: read
9+
10+
jobs:
11+
build-pypi:
12+
name: Build and publish to PyPI
13+
runs-on: ubuntu-latest
14+
permissions:
15+
id-token: write
16+
environment:
17+
name: pypi
18+
steps:
19+
- uses: actions/checkout@v4
20+
21+
- name: Build wheels
22+
uses: PyO3/maturin-action@v1
23+
with:
24+
command: build
25+
args: --release -o dist
26+
sdist: true
27+
manylinux: auto
28+
29+
- name: Publish to PyPI
30+
uses: pypa/gh-action-pypi-publish@release/v1

.github/workflows/tests.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Tests
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches: [main, develop]
7+
tags: ["v*"]
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
test-rust:
14+
name: Rust tests
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Setup Rust
20+
uses: dtolnay/rust-toolchain@stable
21+
22+
- name: Run Rust tests
23+
run: cargo test -p badwords-core
24+
25+
test-python:
26+
name: Python tests (${{ matrix.python-version }})
27+
runs-on: ubuntu-latest
28+
strategy:
29+
fail-fast: false
30+
matrix:
31+
python-version: ["3.10", "3.11", "3.12", "3.13"]
32+
steps:
33+
- uses: actions/checkout@v4
34+
35+
- name: Setup Python
36+
uses: actions/setup-python@v5
37+
with:
38+
python-version: ${{ matrix.python-version }}
39+
cache: pip
40+
41+
- name: Install Rust
42+
uses: dtolnay/rust-toolchain@stable
43+
44+
- name: Install dependencies
45+
run: |
46+
python -m pip install --upgrade pip
47+
pip install maturin
48+
cd python && maturin develop --release
49+
50+
- name: Install dev dependencies
51+
run: pip install pytest pytest-benchmark
52+
53+
- name: Run Python tests
54+
run: pytest tests/ -v -m "not benchmark"
55+
56+
test-wasm:
57+
name: WASM tests
58+
runs-on: ubuntu-latest
59+
steps:
60+
- uses: actions/checkout@v4
61+
62+
- name: Setup Rust
63+
uses: dtolnay/rust-toolchain@stable
64+
with:
65+
targets: wasm32-unknown-unknown
66+
67+
- name: Install wasm-pack
68+
run: cargo install wasm-pack
69+
70+
- name: Run WASM tests
71+
run: cd rust/badwords-wasm && wasm-pack test --node

RELEASE_CHECKLIST.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ docker run --rm -v $(pwd):/io ghcr.io/pyo3/maturin build --release -o dist
2828
twine upload dist/badwords_py-*.whl
2929
```
3030

31-
Or use GitHub Actions: `maturin generate-ci github > .github/workflows/CI.yml`
31+
Or use GitHub Actions: `.github/workflows/release.yml` publishes to PyPI on release.
3232

3333
### crates.io (badwords-core)
3434
```bash

0 commit comments

Comments
 (0)