Skip to content

Add makefile

Add makefile #38

Workflow file for this run

name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
env:
CARGO_TERM_COLOR: always
PYO3_USE_ABI3_FORWARD_COMPATIBILITY: "1"
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install ruff
run: pip install ruff
- name: Run ruff check
run: ruff check debot/
- name: Run ruff format check
run: ruff format --check debot/
test:
name: Test (Python ${{ matrix.python-version }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.11", "3.12", "3.13"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Set up Rust
uses: actions-rs/toolchain@v1
timeout-minutes: 30
with:
profile: minimal
toolchain: stable
override: true
- name: Cache Rust dependencies
uses: Swatinem/rust-cache@v2
with:
workspaces: rust
- name: Install maturin
run: pip install maturin
- name: Build Rust extension
run: maturin build --release -m rust/Cargo.toml
- name: Install package with dev dependencies
run: |
# Ensure PyO3 accepts newer Python via ABI3 forward compatibility during nested builds
export PYO3_USE_ABI3_FORWARD_COMPATIBILITY=1
pip install rust/target/wheels/*.whl
pip install ".[dev]"
- name: Run tests
run: pytest tests/ -v --tb=short
rust-lint:
name: Rust Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Rust toolchain
uses: actions-rs/toolchain@v1
timeout-minutes: 30
with:
profile: minimal
toolchain: stable
override: true
components: rustfmt, clippy
- name: Cache Rust dependencies
uses: Swatinem/rust-cache@v2
with:
workspaces: rust
- name: Check formatting
run: cargo fmt --manifest-path rust/Cargo.toml -- --check
- name: Run clippy
run: cargo clippy --manifest-path rust/Cargo.toml -- -D warnings
publish:
name: Publish Container
runs-on: ubuntu-latest
needs: [lint, test, rust-lint]
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=sha,prefix={{branch}}-
type=raw,value=latest,enable={{is_default_branch}}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max