// Add this webhook in Gitea: // http://192.168.1.37:8080/gitea-webhook/post pipeline { agent { label 'rust_no_docker' } environment { CARGO_TERM_COLOR = 'always' RUST_BACKTRACE = '1' } stages { stage('Checkout') { steps { checkout scm sh ''' set -eu git submodule sync --recursive git submodule update --init --recursive ''' } } stage('Setup Rust') { steps { sh ''' set -eu # --------------------------------------------------------- # Rust # --------------------------------------------------------- if ! command -v rustup >/dev/null 2>&1; then echo "ERROR: rustup is not installed on this worker." >&2 exit 1 fi echo "Ensuring stable Rust is available..." rustup toolchain install stable \ --profile minimal \ --component rustfmt \ --component clippy rustup default stable # --------------------------------------------------------- # mold linker # --------------------------------------------------------- if ! command -v mold >/dev/null 2>&1; then echo "mold not found — installing it..." pkg install -y mold else echo "mold already installed." fi echo echo "Testing mold..." if mold --version >/tmp/mold-version.txt 2>&1; then echo "mold is usable:" cat /tmp/mold-version.txt echo "mold" > .ci-linker else status=$? echo echo "WARNING: mold is installed but unusable." echo "mold exited with status ${status}." echo "Falling back to the native FreeBSD linker." cat /tmp/mold-version.txt || true echo "native" > .ci-linker fi rm -f /tmp/mold-version.txt # --------------------------------------------------------- # Environment information # --------------------------------------------------------- echo echo "Rust:" rustc --version echo echo "Cargo:" cargo --version echo echo "rustfmt:" rustfmt --version echo echo "Clippy:" cargo clippy --version echo echo "Compiler:" cc --version || true echo echo "Selected linker mode:" cat .ci-linker echo echo "Linker-related environment:" env | grep -E 'RUSTFLAGS|CARGO.*RUSTFLAGS|MOLD' || true ''' } } stage('Prepare Linker') { steps { sh ''' set -eu linker="$(cat .ci-linker)" if [ "${linker}" = "mold" ]; then echo "Using mold linker configuration." else echo "Using native FreeBSD linker." # Remove any worker/project environment override that # injects '-fuse-ld=mold'. unset RUSTFLAGS || true unset CARGO_ENCODED_RUSTFLAGS || true # Store an environment fragment for later stages. cat > .ci-env <<'EOF' unset RUSTFLAGS unset CARGO_ENCODED_RUSTFLAGS EOF fi if [ ! -f .ci-env ]; then : > .ci-env fi ''' } } stage('Format') { steps { sh ''' set -eu . ./.ci-env echo "Checking Rust formatting..." cargo fmt \ --all \ -- \ --check ''' } } stage('Check') { steps { sh ''' set -eu . ./.ci-env echo "Checking all IdleFox targets..." cargo check \ --all-targets \ --all-features ''' } } stage('Test') { steps { sh ''' set -eu . ./.ci-env echo "Running IdleFox tests..." cargo test \ --all-targets \ --all-features ''' } } stage('Clippy') { steps { sh ''' set -eu . ./.ci-env echo "Running Clippy..." cargo clippy \ --all-targets \ --all-features ''' } } stage('Check Benchmarks') { steps { sh ''' set -eu . ./.ci-env echo "Checking benchmark compilation..." cargo check \ --benches \ --all-features ''' } } stage('Build Release') { steps { sh ''' set -eu . ./.ci-env echo "Building IdleFox release..." cargo build \ --release \ --all-features echo echo "Release build completed." if [ -f target/release/idlefox ]; then echo echo "Release binary:" ls -lh target/release/idlefox fi ''' } } } post { success { publishChecks( conclusion: 'SUCCESS', name: 'Rust CI', summary: 'IdleFox passed all CI checks.', text: 'Formatting, compilation checks, tests, Clippy, benchmark compilation, and release build completed successfully.', title: 'Build Successful' ) echo '✅ IdleFox passed all CI checks.' } failure { publishChecks( conclusion: 'FAILURE', name: 'Rust CI', summary: 'IdleFox failed CI.', text: 'Formatting, compilation, tests, Clippy, benchmarks, or the release build failed. Check the Jenkins log.', title: 'Build Failed' ) echo '❌ IdleFox CI failed.' } unstable { publishChecks( conclusion: 'ACTION_REQUIRED', name: 'Rust CI', summary: 'IdleFox CI is unstable.', text: 'The Jenkins build completed with an unstable status.', title: 'Build Unstable' ) echo '⚠️ IdleFox CI is unstable.' } always { sh ''' rm -f .ci-linker .ci-env ''' } } }