fader_master/Jenkinsfile

175 lines
4.7 KiB
Groovy

// Add this webhook in Gitea:
// http://192.168.1.37:8080/gitea-webhook/post
pipeline {
agent { label 'rust_nodocker' }
options {
disableConcurrentBuilds()
skipDefaultCheckout(true)
timeout(time: 45, unit: 'MINUTES')
timestamps()
}
environment {
// Jenkins logs are easier to read without Cargo ANSI escape sequences.
CARGO_TERM_COLOR = 'never'
RUST_BACKTRACE = '1'
// Keep CI artifacts separate from local build output.
CARGO_TARGET_DIR = "${WORKSPACE}/target-ci"
}
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
if ! command -v rustup >/dev/null 2>&1; then
echo 'ERROR: rustup is required on the Jenkins worker.' >&2
exit 1
fi
rustup toolchain install stable \
--profile minimal \
--component rustfmt \
--component clippy
rustup default stable
rustc --version
cargo --version
rustfmt --version
cargo clippy --version
'''
}
}
stage('Format') {
steps {
sh '''
set -eu
cargo fmt --all -- --check
'''
}
}
stage('Check') {
steps {
sh '''
set -eu
cargo check --workspace --all-targets --all-features
'''
}
}
stage('Tests') {
steps {
sh '''
set -eu
cargo test --workspace --all-targets --all-features
'''
}
}
stage('Documentation') {
steps {
sh '''
set -eu
cargo test --workspace --doc --all-features
RUSTDOCFLAGS='-D warnings' \
cargo doc --workspace --no-deps --all-features
'''
}
}
stage('Clippy') {
steps {
sh '''
set -eu
cargo clippy \
--workspace \
--all-targets \
--all-features \
-- \
-D warnings
'''
}
}
stage('Build Release') {
steps {
sh '''
set -eu
cargo build --workspace --release --all-features
BINARY="${CARGO_TARGET_DIR}/release/fader_master"
if [ ! -x "${BINARY}" ]; then
echo "ERROR: expected release binary is missing or not executable: ${BINARY}" >&2
exit 1
fi
ls -lh "${BINARY}"
file "${BINARY}" || true
ldd "${BINARY}" || true
'''
}
}
}
post {
success {
publishChecks(
conclusion: 'SUCCESS',
name: 'Rust CI',
summary: 'fader_master passed CI.',
text: 'Formatting, workspace checks, tests, documentation, warning-strict Clippy and the release build completed successfully.',
title: 'Build Successful'
)
echo 'fader_master passed CI.'
}
failure {
publishChecks(
conclusion: 'FAILURE',
name: 'Rust CI',
summary: 'fader_master failed CI.',
text: 'Formatting, workspace checks, tests, documentation, Clippy, or the release build failed. See the Jenkins log.',
title: 'Build Failed'
)
echo 'fader_master CI failed.'
}
unstable {
publishChecks(
conclusion: 'ACTION_REQUIRED',
name: 'Rust CI',
summary: 'fader_master CI is unstable.',
text: 'The Jenkins build completed with an unstable status. See the Jenkins log.',
title: 'Build Unstable'
)
echo 'fader_master CI is unstable.'
}
cleanup {
deleteDir()
}
}
}