stages:
- build
- test
- examples
- docs
- security
- package
include:
- template: Security/SAST.gitlab-ci.yml
- template: Security/Secret-Detection.gitlab-ci.yml
variables:
CARGO_HOME: "$CI_PROJECT_DIR/.cargo"
SECRET_DETECTION_ENABLED: "true"
SAST_ENABLED: "true"
BINDGEN_EXTRA_CLANG_ARGS: "-I/usr/include"
.rust_cache: &rust_cache
cache:
key:
files:
- Cargo.lock
- Cargo.toml
paths:
- .cargo/
- target/release/deps/
- target/debug/deps/
- target/release/build/
- target/debug/build/
.rust_job: &rust_job
image: rust:latest
<<: *rust_cache
before_script:
- apt-get update -qq
- apt-get install -y -qq build-essential cmake clang libclang-dev pkg-config
- |
# Dynamically detect libclang path for current architecture
ARCH=$(uname -m)
if [ "$ARCH" = "x86_64" ]; then
export LIBCLANG_PATH="/usr/lib/x86_64-linux-gnu"
elif [ "$ARCH" = "aarch64" ]; then
export LIBCLANG_PATH="/usr/lib/aarch64-linux-gnu"
else
# Fallback: try to find libclang dynamically
export LIBCLANG_PATH=$(find /usr/lib -name "libclang.so*" 2>/dev/null | head -1 | xargs dirname)
fi
echo "Architecture: $ARCH"
echo "Using libclang path: $LIBCLANG_PATH"
- rustc --version
- cargo --version
build:
<<: *rust_job
stage: build
script:
- cargo build --verbose
- cargo build --release --verbose
artifacts:
paths:
- target/release/qrusty
- target/release/libqrusty.rlib
expire_in: 1 hour
test:
<<: *rust_job
stage: test
needs:
- job: "build"
optional: true
before_script:
- apt-get update -qq
- apt-get install -y -qq build-essential cmake clang libclang-dev pkg-config python3
- |
# Dynamically detect libclang path for current architecture
ARCH=$(uname -m)
if [ "$ARCH" = "x86_64" ]; then
export LIBCLANG_PATH="/usr/lib/x86_64-linux-gnu"
elif [ "$ARCH" = "aarch64" ]; then
export LIBCLANG_PATH="/usr/lib/aarch64-linux-gnu"
else
# Fallback: try to find libclang dynamically
export LIBCLANG_PATH=$(find /usr/lib -name "libclang.so*" 2>/dev/null | head -1 | xargs dirname)
fi
echo "Architecture: $ARCH"
echo "Using libclang path: $LIBCLANG_PATH"
- rustc --version
- cargo --version
- python3 --version
script:
- echo "Running comprehensive test suite including examples..."
- make all
- cargo test --doc --verbose
coverage: '/^\s*lines:\s*\d+\.\d+\%/'
artifacts:
reports:
junit: target/test-results.xml
expire_in: 1 hour
docs:
<<: *rust_job
stage: docs
needs:
- job: "build"
optional: true
script:
- cargo doc --no-deps --verbose
artifacts:
paths:
- target/doc/
expire_in: 1 week
only:
- main
- merge_requests
lint:
<<: *rust_job
stage: test
needs:
- job: "build"
optional: true
before_script:
- apt-get update -qq
- apt-get install -y -qq build-essential cmake clang libclang-dev pkg-config
- rustup component add rustfmt clippy
- rustc --version
- cargo --version
script:
- cargo fmt -- --check
- cargo clippy -- -D warnings
allow_failure: true
examples:
<<: *rust_job
stage: examples
needs:
- job: "build"
optional: true
before_script:
- apt-get update -qq
- apt-get install -y -qq build-essential cmake clang libclang-dev pkg-config python3
- |
# Dynamically detect libclang path for current architecture
ARCH=$(uname -m)
if [ "$ARCH" = "x86_64" ]; then
export LIBCLANG_PATH="/usr/lib/x86_64-linux-gnu"
elif [ "$ARCH" = "aarch64" ]; then
export LIBCLANG_PATH="/usr/lib/aarch64-linux-gnu"
else
# Fallback: try to find libclang dynamically
export LIBCLANG_PATH=$(find /usr/lib -name "libclang.so*" 2>/dev/null | head -1 | xargs dirname)
fi
echo "Architecture: $ARCH"
echo "Using libclang path: $LIBCLANG_PATH"
- rustc --version
- cargo --version
- python3 --version
script:
- echo "Validating all integration examples..."
- make examples
artifacts:
reports:
junit: target/example-results.xml
expire_in: 1 hour
sast:
stage: security
needs:
- job: "build"
optional: true
variables:
SAST_EXCLUDED_PATHS: "target/"
secret_detection:
stage: security
docker_build:
stage: package
image: docker:latest
services:
- docker:dind
needs:
- job: "test"
optional: true
- job: "docs"
optional: true
before_script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
script:
- docker build -t $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA .
- docker build -t $CI_REGISTRY_IMAGE:latest .
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
- docker push $CI_REGISTRY_IMAGE:latest
only:
- main
- tags
docker_build_mr:
stage: package
image: docker:latest
services:
- docker:dind
needs:
- job: "test"
optional: true
script:
- docker build -t qrusty:test .
only:
- merge_requests