Skip to content

Latest commit

 

History

History
177 lines (146 loc) · 5.61 KB

File metadata and controls

177 lines (146 loc) · 5.61 KB

CI/CD Pipeline Specification

Overview

A robust CI/CD pipeline ensures code quality, prevents regressions, and automates releases. This document describes the pipelines for Rust crates, Python bindings, and documentation.

Goals

  1. Automated Testing: Run unit, integration, and property‑based tests on every push.
  2. Code Quality: Enforce formatting, linting, and security checks.
  3. Cross‑platform Compatibility: Test on Linux, macOS, and Windows (where feasible).
  4. Automated Releases: Publish to crates.io and PyPI on version tags.
  5. Documentation Deployment: Build and deploy API docs to GitHub Pages.

Pipeline Stages

1. Pre‑merge Checks (on pull requests)

  • Formatting: cargo fmt --check
  • Linting: cargo clippy -- -D warnings
  • Rust tests: cargo test --all-features
  • Python tests: pytest python/
  • Build verification: cargo build --release for all crates.

2. Post‑merge Continuous Integration (on main branch)

  • All pre‑merge checks plus:
  • Coverage report: Generate code coverage with tarpaulin or grcov.
  • Integration tests: Run multi‑node simulation tests (requires Docker).
  • Benchmark regression: Compare performance against baseline (optional).
  • Security audit: cargo audit and cargo deny.

3. Release Pipeline (on version tags)

  • Build artifacts: Create binaries for supported platforms.
  • Publish to crates.io: cargo publish for each crate.
  • Build Python wheels: Use maturin to build wheels for Linux, macOS, Windows.
  • Upload to PyPI: Upload wheels and source distribution.
  • Update documentation: Rebuild and deploy API docs.
  • Create GitHub Release: Attach binaries and release notes.

Technology Stack

  • CI Provider: GitHub Actions (primary), optionally CircleCI for additional platforms.
  • Containerization: Docker for reproducible test environments.
  • Artifact Storage: GitHub Releases, PyPI, crates.io.
  • Monitoring: Sentry or similar for runtime errors (future).

Workflow Files

.github/workflows/ci.yml

name: CI

on:
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]

jobs:
  rust:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
      - run: cargo fmt --check
      - run: cargo clippy -- -D warnings
      - run: cargo test --all-features
      - run: cargo build --release

  python:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v5
        with:
          python-version: '3.10'
      - run: pip install maturin pytest
      - run: cd python && maturin develop && pytest

  cross-platform:
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [ubuntu-latest, macos-latest, windows-latest]
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
      - run: cargo test --lib

.github/workflows/release.yml

name: Release

on:
  push:
    tags:
      - 'v*'

jobs:
  publish-crates:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
      - run: cargo publish --token ${CRATES_IO_TOKEN}
        env:
          CRATES_IO_TOKEN: ${{ secrets.CRATES_IO_TOKEN }}

  publish-pypi:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v5
      - run: pip install maturin
      - run: cd python && maturin publish --token ${PYPI_TOKEN}
        env:
          PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}

  docs:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
      - run: cargo doc --no-deps
      - uses: peaceiris/actions-gh-pages@v3
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          publish_dir: ./target/doc

Additional Considerations

Dependency Caching

  • Cache ~/.cargo and ~/.cache/pip to speed up builds.

Matrix Testing

  • Test against multiple Rust versions (stable, nightly for beta features).
  • Test against Python 3.8, 3.9, 3.10, 3.11.

Security

  • Use cargo audit to check for vulnerable dependencies.
  • Scan for secrets in code with trufflehog or GitHub’s built‑in secret scanning.

Performance Regression

  • Store benchmark results in a dedicated branch and compare using criterion.rs output.

Dockerized Integration Tests

  • Use docker‑compose to spin up multiple containers that simulate a swarm.
  • Run the demo simulation in headless mode.

Implementation Timeline

Phase 1 – Basic CI

  1. Set up ci.yml with Rust formatting, clippy, and tests.
  2. Add Python binding tests.
  3. Ensure the pipeline passes on the current codebase (once code exists).

Phase 2 – Cross‑platform & Coverage

  1. Extend matrix to macOS and Windows.
  2. Integrate code coverage reporting (coveralls, codecov).

Phase 3 – Release Automation

  1. Create release.yml that triggers on tags.
  2. Configure secrets (CRATES_IO_TOKEN, PYPI_TOKEN) in GitHub repository.
  3. Test with a dummy tag.

Phase 4 – Advanced Checks

  1. Add security audit step.
  2. Add integration tests with Docker.
  3. Add benchmark regression detection.

Open Questions

  1. Should we use a monorepo release tool (like cargo release or changesets)?
  2. How to handle version bumps across multiple crates?
  3. Should we automate CHANGELOG generation?

References