Update Jenkinsfile
Rust CI IdleFox passed all CI checks.
Gitea/idlefox/pipeline/head This commit looks good
Details
Rust CI IdleFox passed all CI checks.
Gitea/idlefox/pipeline/head This commit looks good
Details
This commit is contained in:
parent
048be0e619
commit
faba5f1422
|
|
@ -7,6 +7,20 @@ pipeline {
|
|||
environment {
|
||||
CARGO_TERM_COLOR = 'always'
|
||||
RUST_BACKTRACE = '1'
|
||||
|
||||
// CI gets its own Cargo home. This prevents ~/.cargo/config*
|
||||
// from injecting host-specific linker options.
|
||||
CARGO_HOME = "${WORKSPACE}/.ci-cargo-home"
|
||||
|
||||
// Keep CI artifacts separate from local/project builds.
|
||||
CARGO_TARGET_DIR = "${WORKSPACE}/target-ci"
|
||||
|
||||
// Explicitly use the native FreeBSD compiler/linker.
|
||||
CARGO_TARGET_X86_64_UNKNOWN_FREEBSD_LINKER = 'cc'
|
||||
|
||||
// Explicitly neutralize environment-provided Rust flags.
|
||||
RUSTFLAGS = ''
|
||||
CARGO_ENCODED_RUSTFLAGS = ''
|
||||
}
|
||||
|
||||
stages {
|
||||
|
|
@ -28,10 +42,6 @@ pipeline {
|
|||
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
|
||||
|
|
@ -47,41 +57,27 @@ pipeline {
|
|||
rustup default stable
|
||||
|
||||
# ---------------------------------------------------------
|
||||
# mold linker
|
||||
# Prepare isolated Cargo environment
|
||||
# ---------------------------------------------------------
|
||||
|
||||
if ! command -v mold >/dev/null 2>&1; then
|
||||
echo "mold not found — installing it..."
|
||||
rm -rf "${CARGO_HOME}"
|
||||
mkdir -p "${CARGO_HOME}"
|
||||
|
||||
pkg install -y mold
|
||||
else
|
||||
echo "mold already installed."
|
||||
fi
|
||||
rm -rf "${CARGO_TARGET_DIR}"
|
||||
mkdir -p "${CARGO_TARGET_DIR}"
|
||||
|
||||
echo
|
||||
echo "Testing mold..."
|
||||
# Cargo discovers .cargo/config* by walking upward from the
|
||||
# current working directory. We therefore invoke Cargo from
|
||||
# a neutral directory outside the repository.
|
||||
CI_RUN_DIR="/tmp/idlefox-ci-${BUILD_NUMBER}"
|
||||
|
||||
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=$?
|
||||
rm -rf "${CI_RUN_DIR}"
|
||||
mkdir -p "${CI_RUN_DIR}"
|
||||
|
||||
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
|
||||
echo "${CI_RUN_DIR}" > .ci-run-dir
|
||||
|
||||
# ---------------------------------------------------------
|
||||
# Environment information
|
||||
# Information
|
||||
# ---------------------------------------------------------
|
||||
|
||||
echo
|
||||
|
|
@ -102,46 +98,41 @@ pipeline {
|
|||
|
||||
echo
|
||||
echo "Compiler:"
|
||||
cc --version || true
|
||||
cc --version
|
||||
|
||||
echo
|
||||
echo "Selected linker mode:"
|
||||
cat .ci-linker
|
||||
echo "Rust target:"
|
||||
rustc -vV
|
||||
|
||||
echo
|
||||
echo "Linker-related environment:"
|
||||
env | grep -E 'RUSTFLAGS|CARGO.*RUSTFLAGS|MOLD' || true
|
||||
'''
|
||||
}
|
||||
}
|
||||
echo "Cargo home:"
|
||||
echo "${CARGO_HOME}"
|
||||
|
||||
stage('Prepare Linker') {
|
||||
steps {
|
||||
sh '''
|
||||
set -eu
|
||||
echo
|
||||
echo "Cargo target directory:"
|
||||
echo "${CARGO_TARGET_DIR}"
|
||||
|
||||
linker="$(cat .ci-linker)"
|
||||
echo
|
||||
echo "Neutral Cargo working directory:"
|
||||
cat .ci-run-dir
|
||||
|
||||
if [ "${linker}" = "mold" ]; then
|
||||
echo "Using mold linker configuration."
|
||||
else
|
||||
echo "Using native FreeBSD linker."
|
||||
echo
|
||||
echo "Repository Cargo configuration files:"
|
||||
find "${WORKSPACE}" \
|
||||
-path '*/.cargo/config' \
|
||||
-o \
|
||||
-path '*/.cargo/config.toml' \
|
||||
2>/dev/null || true
|
||||
|
||||
# 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
|
||||
echo
|
||||
echo "Any mold references in repository Cargo configuration:"
|
||||
if [ -d "${WORKSPACE}/.cargo" ]; then
|
||||
grep -Rni 'mold' "${WORKSPACE}/.cargo" || true
|
||||
fi
|
||||
|
||||
if [ ! -f .ci-env ]; then
|
||||
: > .ci-env
|
||||
fi
|
||||
echo
|
||||
echo "CI linker:"
|
||||
echo "${CARGO_TARGET_X86_64_UNKNOWN_FREEBSD_LINKER}"
|
||||
'''
|
||||
}
|
||||
}
|
||||
|
|
@ -151,11 +142,13 @@ EOF
|
|||
sh '''
|
||||
set -eu
|
||||
|
||||
. ./.ci-env
|
||||
CI_RUN_DIR="$(cat "${WORKSPACE}/.ci-run-dir")"
|
||||
cd "${CI_RUN_DIR}"
|
||||
|
||||
echo "Checking Rust formatting..."
|
||||
|
||||
cargo fmt \
|
||||
--manifest-path "${WORKSPACE}/Cargo.toml" \
|
||||
--all \
|
||||
-- \
|
||||
--check
|
||||
|
|
@ -168,11 +161,13 @@ EOF
|
|||
sh '''
|
||||
set -eu
|
||||
|
||||
. ./.ci-env
|
||||
CI_RUN_DIR="$(cat "${WORKSPACE}/.ci-run-dir")"
|
||||
cd "${CI_RUN_DIR}"
|
||||
|
||||
echo "Checking all IdleFox targets..."
|
||||
|
||||
cargo check \
|
||||
--manifest-path "${WORKSPACE}/Cargo.toml" \
|
||||
--all-targets \
|
||||
--all-features
|
||||
'''
|
||||
|
|
@ -184,11 +179,13 @@ EOF
|
|||
sh '''
|
||||
set -eu
|
||||
|
||||
. ./.ci-env
|
||||
CI_RUN_DIR="$(cat "${WORKSPACE}/.ci-run-dir")"
|
||||
cd "${CI_RUN_DIR}"
|
||||
|
||||
echo "Running IdleFox tests..."
|
||||
|
||||
cargo test \
|
||||
--manifest-path "${WORKSPACE}/Cargo.toml" \
|
||||
--all-targets \
|
||||
--all-features
|
||||
'''
|
||||
|
|
@ -200,11 +197,13 @@ EOF
|
|||
sh '''
|
||||
set -eu
|
||||
|
||||
. ./.ci-env
|
||||
CI_RUN_DIR="$(cat "${WORKSPACE}/.ci-run-dir")"
|
||||
cd "${CI_RUN_DIR}"
|
||||
|
||||
echo "Running Clippy..."
|
||||
|
||||
cargo clippy \
|
||||
--manifest-path "${WORKSPACE}/Cargo.toml" \
|
||||
--all-targets \
|
||||
--all-features
|
||||
'''
|
||||
|
|
@ -216,11 +215,13 @@ EOF
|
|||
sh '''
|
||||
set -eu
|
||||
|
||||
. ./.ci-env
|
||||
CI_RUN_DIR="$(cat "${WORKSPACE}/.ci-run-dir")"
|
||||
cd "${CI_RUN_DIR}"
|
||||
|
||||
echo "Checking benchmark compilation..."
|
||||
|
||||
cargo check \
|
||||
--manifest-path "${WORKSPACE}/Cargo.toml" \
|
||||
--benches \
|
||||
--all-features
|
||||
'''
|
||||
|
|
@ -232,22 +233,34 @@ EOF
|
|||
sh '''
|
||||
set -eu
|
||||
|
||||
. ./.ci-env
|
||||
CI_RUN_DIR="$(cat "${WORKSPACE}/.ci-run-dir")"
|
||||
cd "${CI_RUN_DIR}"
|
||||
|
||||
echo "Building IdleFox release..."
|
||||
|
||||
cargo build \
|
||||
--manifest-path "${WORKSPACE}/Cargo.toml" \
|
||||
--release \
|
||||
--all-features
|
||||
|
||||
echo
|
||||
echo "Release build completed."
|
||||
|
||||
if [ -f target/release/idlefox ]; then
|
||||
echo
|
||||
echo "Release binary:"
|
||||
ls -lh target/release/idlefox
|
||||
BINARY="${CARGO_TARGET_DIR}/release/idlefox"
|
||||
|
||||
if [ ! -f "${BINARY}" ]; then
|
||||
echo "ERROR: expected release binary was not produced:"
|
||||
echo "${BINARY}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo
|
||||
echo "Release binary:"
|
||||
ls -lh "${BINARY}"
|
||||
|
||||
echo
|
||||
echo "Binary type:"
|
||||
file "${BINARY}" || true
|
||||
'''
|
||||
}
|
||||
}
|
||||
|
|
@ -259,7 +272,7 @@ EOF
|
|||
conclusion: 'SUCCESS',
|
||||
name: 'Rust CI',
|
||||
summary: 'IdleFox passed all CI checks.',
|
||||
text: 'Formatting, compilation checks, tests, Clippy, benchmark compilation, and release build completed successfully.',
|
||||
text: 'Formatting, compilation checks, tests, Clippy, benchmark compilation, and release build completed successfully using the native FreeBSD linker.',
|
||||
title: 'Build Successful'
|
||||
)
|
||||
|
||||
|
|
@ -292,7 +305,21 @@ EOF
|
|||
|
||||
always {
|
||||
sh '''
|
||||
rm -f .ci-linker .ci-env
|
||||
echo "Cleaning IdleFox CI environment..."
|
||||
|
||||
if [ -f .ci-run-dir ]; then
|
||||
CI_RUN_DIR="$(cat .ci-run-dir)"
|
||||
rm -rf "${CI_RUN_DIR}"
|
||||
fi
|
||||
|
||||
rm -f .ci-run-dir
|
||||
rm -rf .ci-cargo-home
|
||||
|
||||
# Keep target-ci for now so Jenkins retains incremental
|
||||
# compilation between builds. Uncomment to make every build
|
||||
# completely clean:
|
||||
#
|
||||
# rm -rf target-ci
|
||||
'''
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue