ci: add FFI CI pipeline

This commit is contained in:
2025-11-12 23:04:19 +01:00
parent 958d7965ce
commit 1630915010
2 changed files with 61 additions and 0 deletions
+38
View File
@@ -0,0 +1,38 @@
FROM occt-builder:latest AS ffi-base
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y curl build-essential
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
ENV PATH="/root/.cargo/bin:${PATH}"
WORKDIR /app
COPY . .
ENV LD_LIBRARY_PATH=/usr/local/lib:/app/build
ENV RUSTFLAGS="-L /usr/local/lib -L /app/build"
RUN cargo build
FROM ubuntu:24.04 AS ffi-unit-testing
RUN apt-get update && apt-get install -y \
build-essential cmake git curl \
libfreetype-dev \
xvfb \
&& rm -rf /var/lib/apt/lists/*
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
ENV PATH="/root/.cargo/bin:${PATH}"
COPY --from=occt-builder:latest /usr/local /usr/local
COPY --from=occt-builder:latest /app/build /app/occt-build
COPY --from=ffi-base /app /app
WORKDIR /app
ENV LD_LIBRARY_PATH=/usr/local/lib:/app/occt-build
ENV RUSTFLAGS="-L /usr/local/lib -L /app/occt-build"
CMD ["cargo", "test", "--verbose", "--", "--nocapture"]
+23
View File
@@ -0,0 +1,23 @@
#!/usr/bin/env bash
set -euo pipefail
IMAGE_NAME="ffi-builder:latest"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_PATH="$(cd "$SCRIPT_DIR/../../" && pwd)"
DOCKERFILE_PATH="$SCRIPT_DIR/../ffi.Dockerfile"
RUN_UNIT_TESTS=false
if [[ "${1-}" == "--tests" ]]; then
RUN_UNIT_TESTS=true
fi
echo "Building base image..."
docker build --target ffi-base -f "$DOCKERFILE_PATH" -t "$IMAGE_NAME" "$PROJECT_PATH"
if [ "$RUN_UNIT_TESTS" = true ]; then
echo "Building unit-testing stage..."
docker build --target ffi-unit-testing -f "$DOCKERFILE_PATH" -t "$IMAGE_NAME" "$PROJECT_PATH"
echo "Running tests..."
docker run --rm -it "$IMAGE_NAME" cargo test
fi