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
151 changes: 151 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
name: CI

on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]
workflow_dispatch:

env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1

jobs:
test:
name: Test
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-latest
python-version: '3.10'
rust-version: stable
- os: ubuntu-latest
python-version: '3.11'
rust-version: stable
- os: ubuntu-latest
python-version: '3.12'
rust-version: stable
- os: windows-latest
python-version: '3.11'
rust-version: stable
- os: macos-latest
python-version: '3.11'
rust-version: stable

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust-version }}
components: rustfmt, clippy

- name: Cache Rust dependencies
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-

- name: Install Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Cache Python dependencies
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/pyproject.toml') }}
restore-keys: |
${{ runner.os }}-pip-

- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install maturin pytest pytest-mock pytest-cov flake8 black

- name: Check Rust formatting
run: cargo fmt -- --check

- name: Check Rust linting
run: cargo clippy -- -D warnings

- name: Run Rust tests
run: cargo test --verbose

- name: Create virtual environment
run: python -m venv .venv

- name: Activate virtual environment (Linux/macOS)
if: runner.os != 'Windows'
run: source .venv/bin/activate && python -m pip install --upgrade pip && pip install maturin pytest pytest-mock pytest-cov && maturin develop --release && python -m pytest tests/ -v --cov=drainage --cov-report=xml && python -c "import drainage; print('drainage module imported successfully')" && python -c "import examples.simple_analysis; print('examples imported successfully')"
shell: bash

- name: Activate virtual environment (Windows)
if: runner.os == 'Windows'
run: .venv\Scripts\activate && python -m pip install --upgrade pip && pip install maturin pytest pytest-mock pytest-cov && maturin develop --release && python -m pytest tests/ -v --cov=drainage --cov-report=xml && python -c "import drainage; print('drainage module imported successfully')" && python -c "import examples.simple_analysis; print('examples imported successfully')"
shell: cmd

- name: Upload coverage to Codecov
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.11'
uses: codecov/codecov-action@v4
with:
file: ./coverage.xml
flags: unittests
name: codecov-umbrella
fail_ci_if_error: false

build:
name: Build
runs-on: ubuntu-latest
needs: test

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
components: rustfmt, clippy

- name: Cache Rust dependencies
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-

- name: Install Python
uses: actions/setup-python@v4
with:
python-version: '3.11'

- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install maturin

- name: Build wheel
run: |
maturin build --release

- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: wheel-ubuntu-py3.11
path: target/wheels/*.whl
Loading