wf
Quick CI / quick-test (push) Failing after 1m15s
Multi-Platform CI / test-platforms (macos-latest, aarch64-apple-darwin) (push) Failing after 56s
Multi-Platform CI / test-platforms (macos-latest, x86_64-apple-darwin) (push) Failing after 40s
Multi-Platform CI / test-platforms (ubuntu-22.04, aarch64-unknown-linux-gnu) (push) Failing after 1m20s
Multi-Platform CI / test-platforms (ubuntu-22.04, x86_64-unknown-linux-gnu) (push) Failing after 40s
Multi-Platform CI / test-platforms (windows-latest, aarch64-pc-windows-msvc) (push) Failing after 40s
Multi-Platform CI / test-platforms (windows-latest, x86_64-pc-windows-msvc) (push) Failing after 39s
Multi-Platform CI / test-native (macos-latest) (push) Failing after 1m16s
Multi-Platform CI / test-native (ubuntu-22.04) (push) Failing after 1m16s
Multi-Platform CI / test-native (windows-latest) (push) Failing after 1m17s
Multi-Platform CI / package (macos-latest, aarch64-apple-darwin) (push) Has been skipped
Multi-Platform CI / package (macos-latest, x86_64-apple-darwin) (push) Has been skipped
Multi-Platform CI / package (ubuntu-22.04, x86_64-unknown-linux-gnu) (push) Has been skipped
Multi-Platform CI / package (windows-latest, x86_64-pc-windows-msvc) (push) Has been skipped
Quick CI / quick-test (push) Failing after 1m15s
Multi-Platform CI / test-platforms (macos-latest, aarch64-apple-darwin) (push) Failing after 56s
Multi-Platform CI / test-platforms (macos-latest, x86_64-apple-darwin) (push) Failing after 40s
Multi-Platform CI / test-platforms (ubuntu-22.04, aarch64-unknown-linux-gnu) (push) Failing after 1m20s
Multi-Platform CI / test-platforms (ubuntu-22.04, x86_64-unknown-linux-gnu) (push) Failing after 40s
Multi-Platform CI / test-platforms (windows-latest, aarch64-pc-windows-msvc) (push) Failing after 40s
Multi-Platform CI / test-platforms (windows-latest, x86_64-pc-windows-msvc) (push) Failing after 39s
Multi-Platform CI / test-native (macos-latest) (push) Failing after 1m16s
Multi-Platform CI / test-native (ubuntu-22.04) (push) Failing after 1m16s
Multi-Platform CI / test-native (windows-latest) (push) Failing after 1m17s
Multi-Platform CI / package (macos-latest, aarch64-apple-darwin) (push) Has been skipped
Multi-Platform CI / package (macos-latest, x86_64-apple-darwin) (push) Has been skipped
Multi-Platform CI / package (ubuntu-22.04, x86_64-unknown-linux-gnu) (push) Has been skipped
Multi-Platform CI / package (windows-latest, x86_64-pc-windows-msvc) (push) Has been skipped
This commit is contained in:
@@ -0,0 +1,116 @@
|
||||
name: Reusable CI
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
os:
|
||||
required: true
|
||||
type: string
|
||||
target:
|
||||
required: false
|
||||
type: string
|
||||
default: ""
|
||||
upload-artifacts:
|
||||
required: false
|
||||
type: boolean
|
||||
default: false
|
||||
|
||||
jobs:
|
||||
ci:
|
||||
runs-on: ${{ inputs.os }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: dtolnay/rust-toolchain@stable
|
||||
with:
|
||||
components: clippy, rustfmt
|
||||
targets: ${{ inputs.target }}
|
||||
|
||||
- name: Install components (clippy, rustfmt)
|
||||
run: |
|
||||
rustup component add clippy rustfmt || true
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
${{ inputs.target && format('cargo build --all-features --target {0}', inputs.target) || 'cargo build --all-features' }}
|
||||
|
||||
- name: Test
|
||||
run: |
|
||||
${{ inputs.target && format('cargo test --all-features --target {0}', inputs.target) || 'cargo test --all-features' }}
|
||||
|
||||
- name: Clippy
|
||||
run: |
|
||||
${{ inputs.target && format('cargo clippy --all-targets --all-features --target {0} -D warnings', inputs.target) || 'cargo clippy --all-targets --all-features -D warnings' }}
|
||||
|
||||
- name: Fmt check
|
||||
run: |
|
||||
cargo fmt --all -- --check
|
||||
|
||||
- name: Benchmark (Linux only)
|
||||
if: runner.os == 'Linux' && inputs.target == ''
|
||||
run: |
|
||||
cargo bench --bench heart
|
||||
|
||||
- name: Security audit (Linux only)
|
||||
if: runner.os == 'Linux' && inputs.target == ''
|
||||
run: |
|
||||
cargo install cargo-audit
|
||||
cargo audit
|
||||
|
||||
- name: Build FFI library
|
||||
if: inputs.upload-artifacts
|
||||
run: |
|
||||
${{ inputs.target && format('cargo build --release --features ffi --target {0}', inputs.target) || 'cargo build --release --features ffi' }}
|
||||
|
||||
- name: Extract version and create package
|
||||
if: inputs.upload-artifacts
|
||||
shell: bash
|
||||
run: |
|
||||
VERSION=$(sed -n 's/^version\s*=\s*"\([^"]\+\)"/\1/p' Cargo.toml | head -n1)
|
||||
|
||||
# Determine target directory and library extension
|
||||
if [[ -n "${{ inputs.target }}" ]]; then
|
||||
TARGET_DIR="target/${{ inputs.target }}/release"
|
||||
PKG_BASENAME="medicallib_rust-v${VERSION}-${{ inputs.target }}"
|
||||
else
|
||||
TARGET_DIR="target/release"
|
||||
case "${{ runner.os }}" in
|
||||
Linux) PKG_BASENAME="medicallib_rust-v${VERSION}-x86_64-unknown-linux-gnu" ;;
|
||||
macOS) PKG_BASENAME="medicallib_rust-v${VERSION}-x86_64-apple-darwin" ;;
|
||||
Windows) PKG_BASENAME="medicallib_rust-v${VERSION}-x86_64-pc-windows-msvc" ;;
|
||||
*) PKG_BASENAME="medicallib_rust-v${VERSION}-native" ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
PKG_DIR="dist/${PKG_BASENAME}"
|
||||
|
||||
echo "Creating package ${PKG_BASENAME}..."
|
||||
mkdir -p "${PKG_DIR}/include" "${PKG_DIR}/lib" "${PKG_DIR}/examples/c"
|
||||
|
||||
# Copy header and example
|
||||
cp ffi/medicallib.h "${PKG_DIR}/include/"
|
||||
cp examples/c/ffi_example.c "${PKG_DIR}/examples/c/"
|
||||
cp README.md INSTALL.md MIGRATION.md ARCHITECTURE.md "${PKG_DIR}/" || true
|
||||
|
||||
# Copy library with proper extension detection
|
||||
if [[ "${{ runner.os }}" == "Windows" ]]; then
|
||||
cp "${TARGET_DIR}/medicallib_rust.dll" "${PKG_DIR}/lib/" || \
|
||||
cp "${TARGET_DIR}/libmedicallib_rust.dll" "${PKG_DIR}/lib/"
|
||||
elif [[ "${{ runner.os }}" == "macOS" ]]; then
|
||||
cp "${TARGET_DIR}/libmedicallib_rust.dylib" "${PKG_DIR}/lib/"
|
||||
else
|
||||
cp "${TARGET_DIR}/libmedicallib_rust.so" "${PKG_DIR}/lib/"
|
||||
fi
|
||||
|
||||
# Create archives
|
||||
tar -C dist -czf "dist/${PKG_BASENAME}.tar.gz" "${PKG_BASENAME}"
|
||||
if command -v zip >/dev/null 2>&1; then
|
||||
(cd dist && zip -r9 "${PKG_BASENAME}.zip" "${PKG_BASENAME}")
|
||||
fi
|
||||
|
||||
- name: Upload artifacts
|
||||
if: inputs.upload-artifacts
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: medicallib-rust-${{ inputs.target || runner.os }}
|
||||
path: dist/
|
||||
+14
-7
@@ -1,18 +1,21 @@
|
||||
name: CI
|
||||
name: Quick CI
|
||||
|
||||
on:
|
||||
push:
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
# Target the runner using only the labels it already has.
|
||||
|
||||
# this will target it correctly in your current setup.
|
||||
# Fast feedback for development - Linux only
|
||||
quick-test:
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: dtolnay/rust-toolchain@stable
|
||||
with:
|
||||
components: clippy, rustfmt
|
||||
- name: Install components (clippy, rustfmt)
|
||||
run: |
|
||||
rustup component add clippy rustfmt || true
|
||||
- name: Build
|
||||
run: |
|
||||
cargo build --all-features
|
||||
@@ -25,6 +28,10 @@ jobs:
|
||||
- name: Fmt check
|
||||
run: |
|
||||
cargo fmt --all -- --check
|
||||
- name: Package (ffi)
|
||||
- name: Benchmark
|
||||
run: |
|
||||
bash ../scripts/package.sh
|
||||
cargo bench --bench heart
|
||||
- name: Security audit
|
||||
run: |
|
||||
cargo install cargo-audit
|
||||
cargo audit
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
name: Multi-Platform CI
|
||||
|
||||
on:
|
||||
push:
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
# Test on all platforms
|
||||
test-platforms:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
# Linux platforms
|
||||
- os: ubuntu-22.04
|
||||
target: x86_64-unknown-linux-gnu
|
||||
- os: ubuntu-22.04
|
||||
target: aarch64-unknown-linux-gnu
|
||||
|
||||
# macOS platforms
|
||||
- os: macos-latest
|
||||
target: x86_64-apple-darwin
|
||||
- os: macos-latest
|
||||
target: aarch64-apple-darwin
|
||||
|
||||
# Windows platforms
|
||||
- os: windows-latest
|
||||
target: x86_64-pc-windows-msvc
|
||||
- os: windows-latest
|
||||
target: aarch64-pc-windows-msvc
|
||||
|
||||
uses: ./.gitea/workflows/ci-reusable.yml
|
||||
with:
|
||||
os: ${{ matrix.os }}
|
||||
target: ${{ matrix.target }}
|
||||
upload-artifacts: false
|
||||
|
||||
# Test native builds (no cross-compilation)
|
||||
test-native:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ubuntu-22.04, macos-latest, windows-latest]
|
||||
|
||||
uses: ./.gitea/workflows/ci-reusable.yml
|
||||
with:
|
||||
os: ${{ matrix.os }}
|
||||
upload-artifacts: false
|
||||
|
||||
# Package for distribution (only on master)
|
||||
package:
|
||||
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
|
||||
needs: [test-platforms, test-native]
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
- os: ubuntu-22.04
|
||||
target: x86_64-unknown-linux-gnu
|
||||
- os: macos-latest
|
||||
target: x86_64-apple-darwin
|
||||
- os: macos-latest
|
||||
target: aarch64-apple-darwin
|
||||
- os: windows-latest
|
||||
target: x86_64-pc-windows-msvc
|
||||
|
||||
uses: ./.gitea/workflows/ci-reusable.yml
|
||||
with:
|
||||
os: ${{ matrix.os }}
|
||||
target: ${{ matrix.target }}
|
||||
upload-artifacts: true
|
||||
@@ -15,3 +15,5 @@ Cargo.lock
|
||||
node_modules/
|
||||
coverage/
|
||||
|
||||
|
||||
.claude/settings.local.json
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
# Repository Guidelines
|
||||
|
||||
## Project Structure & Module Organization
|
||||
- Source: `src/` (crate root `src/lib.rs`). Core modules in `src/organs/`, types in `src/types.rs`, errors in `src/error.rs`, FFI in `src/ffi.rs`.
|
||||
- Tests: integration tests in `tests/` (e.g., `tests/patient.rs`).
|
||||
- Examples: `examples/` (Rust usage and tracing demos), plus C FFI example in `examples/c/` with header in `ffi/medicallib.h`.
|
||||
- Benchmarks: `benches/` (Criterion-based; see `benches/heart.rs`).
|
||||
- Docs: `README.md`, `ARCHITECTURE.md`, `INSTALL.md`, `MIGRATION.md`.
|
||||
|
||||
## Build, Test, and Development Commands
|
||||
- Build library (debug): `cargo build`
|
||||
- Build with FFI (shared lib): `cargo build --release --features ffi`
|
||||
- Run tests: `cargo test` (single test file: `cargo test --test patient`)
|
||||
- Run examples: `cargo run --example usage` (or `tracing_demo`)
|
||||
- Benchmarks (Criterion): `cargo bench`
|
||||
- Lint: `cargo clippy --all-targets -- -D warnings`
|
||||
- Format: `cargo fmt --all`
|
||||
- Docs (open): `cargo doc --no-deps --open`
|
||||
|
||||
## Coding Style & Naming Conventions
|
||||
- Rust style via `rustfmt`; 4-space indentation; wrap at ~100 cols where reasonable.
|
||||
- Naming: modules/files `snake_case`, types/traits `CamelCase`, functions/vars `snake_case`, constants `SCREAMING_SNAKE_CASE`.
|
||||
- Public API changes must be intentional; update examples and docs when modifying `src/ffi.rs` or `src/organs/*`.
|
||||
|
||||
## Testing Guidelines
|
||||
- Prefer integration tests in `tests/` named after features (e.g., `basic.rs`, `ffi.rs`).
|
||||
- Add unit tests near code under `#[cfg(test)]` for small invariants.
|
||||
- Keep tests deterministic; avoid sleeping/time unless necessary.
|
||||
- Run `cargo test` locally and ensure `cargo clippy` passes before opening a PR.
|
||||
|
||||
## Commit & Pull Request Guidelines
|
||||
- Commits: clear, imperative subject (e.g., "Add heart rate update clamp"). Conventional Commits (feat/fix/refactor/docs/test) are welcome.
|
||||
- PRs: concise description, link issues, note breaking changes, and include tests or examples. Add screenshots only if relevant to docs.
|
||||
|
||||
## Security & FFI Notes
|
||||
- FFI: when changing `src/ffi.rs`, update C header `ffi/medicallib.h` and verify `examples/c/ffi_example.c` still builds against the produced `cdylib`.
|
||||
- Avoid `unsafe` unless essential; document safety contracts.
|
||||
|
||||
## Agent-Specific Tips
|
||||
- Maintain module organization under `src/organs/` and keep APIs cohesive.
|
||||
- Do not introduce new runtime dependencies without discussion; prefer standard library and existing crates.
|
||||
Reference in New Issue
Block a user