Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 28 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ jobs:
with:
fetch-depth: 0

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable

- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v6
with:
Expand Down Expand Up @@ -78,6 +81,11 @@ jobs:
with:
fetch-depth: 0

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: llvm-tools-preview

- name: Set up Python 3.13
uses: actions/setup-python@v6
with:
Expand All @@ -100,12 +108,30 @@ jobs:
- name: Combine coverage data and display human readable report
run: nox --session=coverage

- name: Create coverage report
- name: Create Python coverage report
run: nox --session=coverage -- xml

- name: Upload coverage report
# Rust coverage
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov

- name: Generate Rust coverage
run: cargo llvm-cov --manifest-path crates/agon-core/Cargo.toml --lcov --output-path rust-coverage.lcov

- name: Upload Python coverage to Codecov
uses: codecov/codecov-action@v5
with:
files: coverage.xml
flags: python
name: agon-python
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true

- name: Upload Rust coverage to Codecov
uses: codecov/codecov-action@v5
with:
files: rust-coverage.lcov
flags: rust
name: agon-rust
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true
125 changes: 114 additions & 11 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,126 @@ permissions:
contents: read

jobs:
build-and-publish:
runs-on: ubuntu-latest
# Build wheels for Linux
linux:
runs-on: ${{ matrix.platform.runner }}
strategy:
matrix:
platform:
- runner: ubuntu-latest
target: x86_64
- runner: ubuntu-latest
target: aarch64
steps:
- uses: actions/checkout@v6

- uses: actions/setup-python@v6
with:
python-version: "3.13"

- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.platform.target }}
args: --release --out dist
sccache: "true"
manylinux: auto

- name: Upload wheels
uses: actions/upload-artifact@v6
with:
name: wheels-linux-${{ matrix.platform.target }}
path: dist

# Build wheels for macOS
macos:
runs-on: ${{ matrix.platform.runner }}
strategy:
matrix:
platform:
- runner: macos-13
target: x86_64
- runner: macos-14
target: aarch64
steps:
- name: Checkout
uses: actions/checkout@v6
- uses: actions/checkout@v6

- uses: actions/setup-python@v6
with:
python-version: "3.13"

- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.platform.target }}
args: --release --out dist
sccache: "true"

- name: Upload wheels
uses: actions/upload-artifact@v6
with:
fetch-depth: 0
name: wheels-macos-${{ matrix.platform.target }}
path: dist

- name: Install uv
uses: astral-sh/setup-uv@v7
# Build wheels for Windows
windows:
runs-on: ${{ matrix.platform.runner }}
strategy:
matrix:
platform:
- runner: windows-latest
target: x64
steps:
- uses: actions/checkout@v6

- uses: actions/setup-python@v6
with:
version: "0.8.3"
enable-cache: true
python-version: "3.13"
architecture: ${{ matrix.platform.target }}

- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.platform.target }}
args: --release --out dist
sccache: "true"

- name: Upload wheels
uses: actions/upload-artifact@v6
with:
name: wheels-windows-${{ matrix.platform.target }}
path: dist

# Build source distribution
sdist:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6

- name: Build sdist
uses: PyO3/maturin-action@v1
with:
command: sdist
args: --out dist

- name: Upload sdist
uses: actions/upload-artifact@v6
with:
name: wheels-sdist
path: dist

- name: Build package
run: uv build
# Publish to PyPI
publish:
name: Publish to PyPI
runs-on: ubuntu-latest
needs: [linux, macos, windows, sdist]
steps:
- name: Download all artifacts
uses: actions/download-artifact@v7
with:
path: dist
pattern: wheels-*
merge-multiple: true

- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# Rust
target/
Cargo.lock
*.lcov

# Python
__pycache__/
*.py[cod]
Expand Down
43 changes: 35 additions & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,55 @@ repos:
- id: detect-private-key
- id: debug-statements

# Python: codespell
- repo: https://github.com/codespell-project/codespell
rev: v2.4.1
hooks:
- id: codespell
args: ["--write-changes", "--skip", "*.lock,*.json"]
files: ^(python|tests|devtools|docs)/|^README\.md$

# Python: ruff check + format
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.11.9
rev: v0.14.10
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- id: ruff-check
args: [--fix]
files: ^(python|tests|devtools)/
- id: ruff-format
files: ^(python|tests|devtools)/

# Python: basedpyright
- repo: local
hooks:
- id: basedpyright
name: basedpyright (uv)
entry: uv run basedpyright
language: system
args: [src]
args: [python, tests, devtools]
pass_filenames: false

- repo: https://github.com/codespell-project/codespell
rev: v2.4.1
# Rust: cargo fmt
- repo: local
hooks:
- id: codespell
args: ["--skip", "*.lock,*.json"]
- id: cargo-fmt
name: cargo fmt
entry: cargo fmt --manifest-path crates/agon-core/Cargo.toml --
language: system
types: [rust]
pass_filenames: true

# Rust: cargo clippy
- repo: local
hooks:
- id: cargo-clippy
name: cargo clippy
entry: cargo clippy --manifest-path crates/agon-core/Cargo.toml --all-targets --fix --allow-dirty --allow-staged -- -D warnings
language: system
types: [rust]
pass_filenames: false

# CI: GitHub workflows and actions
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.30.0
hooks:
Expand Down
24 changes: 24 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[workspace]
resolver = "2"
members = ["crates/*"]

[workspace.package]
version = "0.2.0"
edition = "2024"
license = "MIT"
authors = ["Harvey Tseng <harveytseng2@gmail.com>"]
repository = "https://github.com/Verdenroz/agon-python"

[workspace.dependencies]
pyo3 = { version = "0.27.2", features = ["extension-module"] }
serde = { version = "1.0", features = ["derive"] }
serde_json = { version = "1.0", features = ["preserve_order"] }
rayon = "1.10"
thiserror = "2.0"
regex = "1.11"
tiktoken-rs = "0.9.1"

[profile.release]
lto = true
codegen-units = 1
opt-level = 3
Loading
Loading