Files
medicallib_rust/.gitea/workflows/ci-reusable.yml
T
zack3d b0ac70dd19
Quick CI / quick-test (push) Failing after 1m13s
Multi-Platform CI / test-platforms (ubuntu-22.04, x86_64-unknown-linux-gnu) (push) Failing after 1m0s
Multi-Platform CI / test-platforms (windows-latest, x86_64-pc-windows-msvc) (push) Failing after 37s
Multi-Platform CI / test-native (ubuntu-22.04) (push) Failing after 1m20s
Multi-Platform CI / test-native (windows-latest) (push) Failing after 1m19s
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
hgjk
2025-09-21 23:50:28 -07:00

141 lines
4.8 KiB
YAML

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 cross-compilation tools (x86_64 on ARM64)
if: runner.os == 'Linux' && runner.arch == 'ARM64' && inputs.target == 'x86_64-unknown-linux-gnu'
run: |
sudo apt-get update
sudo apt-get install -y gcc-x86-64-linux-gnu
- name: Configure cross-compilation (x86_64 on ARM64)
if: runner.os == 'Linux' && runner.arch == 'ARM64' && inputs.target == 'x86_64-unknown-linux-gnu'
run: |
echo "CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER=x86_64-linux-gnu-gcc" >> $GITHUB_ENV
- name: Build
run: |
if [[ -n "${{ inputs.target }}" ]]; then
cargo build --all-features --target ${{ inputs.target }}
else
cargo build --all-features
fi
- name: Test
if: inputs.target == '' || (runner.os == 'Linux' && runner.arch == 'X64' && inputs.target == 'x86_64-unknown-linux-gnu') || (runner.os == 'Windows' && inputs.target == 'x86_64-pc-windows-msvc')
run: |
if [[ -n "${{ inputs.target }}" ]]; then
cargo test --all-features --target ${{ inputs.target }}
else
cargo test --all-features
fi
- name: Clippy
run: |
if [[ -n "${{ inputs.target }}" ]]; then
cargo clippy --all-targets --all-features --target ${{ inputs.target }} -- -D warnings
else
cargo clippy --all-targets --all-features -- -D warnings
fi
- 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: |
if [[ -n "${{ inputs.target }}" ]]; then
cargo build --release --features ffi --target ${{ inputs.target }}
else
cargo build --release --features ffi
fi
- 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/