Files
medicallib_rust/.gitea/workflows/ci-reusable.yml
T
zack3d d71b0ec5ff
Quick CI / quick-test (push) Failing after 1m16s
Multi-Platform CI / test-platforms (ubuntu-22.04) (push) Failing after 1m23s
Multi-Platform CI / test-platforms (windows-latest) (push) Failing after 1m21s
Multi-Platform CI / package (ubuntu-22.04) (push) Has been skipped
Multi-Platform CI / package (windows-latest) (push) Has been skipped
hgdhgfcvbncnb
2025-09-22 00:04:53 -07:00

97 lines
2.9 KiB
YAML

name: Reusable CI
on:
workflow_call:
inputs:
os:
required: true
type: string
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
- name: Build
run: cargo build --all-features
- name: Test
run: cargo test --all-features
- name: Clippy
run: cargo clippy --all-targets --all-features -- -D warnings
- name: Fmt check
run: |
cargo fmt --all -- --check
- name: Benchmark (Linux only)
if: runner.os == 'Linux'
run: cargo bench --bench heart
- name: Security audit (Linux only)
if: runner.os == 'Linux'
run: |
cargo install cargo-audit
cargo audit
- name: Build FFI library
if: inputs.upload-artifacts
run: 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
TARGET_DIR="target/release"
case "${{ runner.os }}" in
Linux) PKG_BASENAME="medicallib_rust-v${VERSION}-x86_64-unknown-linux-gnu" ;;
Windows) PKG_BASENAME="medicallib_rust-v${VERSION}-x86_64-pc-windows-msvc" ;;
*) PKG_BASENAME="medicallib_rust-v${VERSION}-native" ;;
esac
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-${{ runner.os }}
path: dist/