228 lines
5.9 KiB
Groovy
228 lines
5.9 KiB
Groovy
// 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'
|
|
MSRV = '1.98.1'
|
|
TARPAULIN_VERSION = '0.37.4'
|
|
}
|
|
|
|
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 not installed on this worker." >&2
|
|
exit 1
|
|
fi
|
|
|
|
echo "Ensuring the stable Rust toolchain is available..."
|
|
|
|
rustup toolchain install stable \
|
|
--profile minimal \
|
|
--component rustfmt \
|
|
--component clippy
|
|
|
|
rustup toolchain install "${MSRV}" \
|
|
--profile minimal
|
|
|
|
rustup default stable
|
|
|
|
echo
|
|
echo "Using:"
|
|
rustc --version
|
|
cargo --version
|
|
rustfmt --version
|
|
cargo clippy --version
|
|
|
|
INSTALLED_TARPAULIN="$(cargo tarpaulin --version 2>/dev/null || true)"
|
|
if [ "${INSTALLED_TARPAULIN}" != "cargo-tarpaulin-tarpaulin ${TARPAULIN_VERSION}" ]; then
|
|
cargo install cargo-tarpaulin \
|
|
--locked \
|
|
--version "${TARPAULIN_VERSION}"
|
|
fi
|
|
'''
|
|
}
|
|
}
|
|
|
|
stage('MSRV') {
|
|
steps {
|
|
sh '''
|
|
set -eu
|
|
|
|
echo "Checking all targets with Rust ${MSRV}..."
|
|
|
|
cargo "+${MSRV}" check \
|
|
--locked \
|
|
--all-targets \
|
|
--all-features
|
|
'''
|
|
}
|
|
}
|
|
|
|
stage('Format') {
|
|
steps {
|
|
sh '''
|
|
set -eu
|
|
|
|
echo "Checking Rust formatting..."
|
|
|
|
cargo fmt --all -- --check
|
|
'''
|
|
}
|
|
}
|
|
|
|
stage('Check') {
|
|
steps {
|
|
sh '''
|
|
set -eu
|
|
|
|
echo "Checking all targets..."
|
|
|
|
cargo check \
|
|
--locked \
|
|
--all-targets \
|
|
--all-features
|
|
'''
|
|
}
|
|
}
|
|
|
|
stage('Test') {
|
|
steps {
|
|
sh '''
|
|
set -eu
|
|
|
|
echo "Running tests..."
|
|
|
|
cargo test \
|
|
--locked \
|
|
--all-targets \
|
|
--all-features
|
|
'''
|
|
}
|
|
}
|
|
|
|
stage('Test Minimal Features') {
|
|
steps {
|
|
sh '''
|
|
set -eu
|
|
|
|
echo "Running tests without default features..."
|
|
|
|
cargo test \
|
|
--locked \
|
|
--all-targets \
|
|
--no-default-features
|
|
'''
|
|
}
|
|
}
|
|
|
|
stage('Coverage') {
|
|
steps {
|
|
sh '''
|
|
set -eu
|
|
|
|
echo "Measuring line coverage..."
|
|
|
|
cargo tarpaulin --config tarpaulin.toml
|
|
'''
|
|
}
|
|
}
|
|
|
|
stage('Clippy') {
|
|
steps {
|
|
sh '''
|
|
set -eu
|
|
|
|
echo "Running Clippy..."
|
|
|
|
cargo clippy \
|
|
--locked \
|
|
--all-targets \
|
|
--all-features
|
|
'''
|
|
}
|
|
}
|
|
|
|
stage('Build Release') {
|
|
steps {
|
|
sh '''
|
|
set -eu
|
|
|
|
echo "Building John Slop release binaries..."
|
|
|
|
cargo build \
|
|
--locked \
|
|
--release \
|
|
--all-features
|
|
|
|
echo
|
|
echo "Release build completed."
|
|
|
|
ls -lh \
|
|
target/release/john-slop \
|
|
target/release/john-slop-fmt \
|
|
target/release/john-slop-lsp
|
|
'''
|
|
}
|
|
}
|
|
}
|
|
|
|
post {
|
|
success {
|
|
publishChecks(
|
|
conclusion: 'SUCCESS',
|
|
name: 'Rust CI',
|
|
summary: 'JohnSlop passed all CI checks.',
|
|
text: 'Formatting, compilation checks, feature tests, coverage, Clippy, and the release build completed successfully.',
|
|
title: 'Build Successful'
|
|
)
|
|
|
|
echo '✅ JohnSlop passed all CI checks.'
|
|
}
|
|
|
|
failure {
|
|
publishChecks(
|
|
conclusion: 'FAILURE',
|
|
name: 'Rust CI',
|
|
summary: 'JohnSlop failed CI.',
|
|
text: 'Formatting, compilation, tests, coverage, Clippy, or the release build failed. Check the Jenkins log.',
|
|
title: 'Build Failed'
|
|
)
|
|
|
|
echo '❌ JohnSlop CI failed.'
|
|
}
|
|
|
|
unstable {
|
|
publishChecks(
|
|
conclusion: 'ACTION_REQUIRED',
|
|
name: 'Rust CI',
|
|
summary: 'JohnSlop CI is unstable.',
|
|
text: 'The Jenkins build completed with an unstable status.',
|
|
title: 'Build Unstable'
|
|
)
|
|
|
|
echo '⚠️ JohnSlop CI is unstable.'
|
|
}
|
|
}
|
|
}
|