Compare commits
2 Commits
| Author | SHA1 | Date |
|---|---|---|
|
|
0600681ec8 | |
|
|
ff4428ebef |
|
|
@ -0,0 +1,232 @@
|
||||||
|
// 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'
|
||||||
|
VENV = '.venv'
|
||||||
|
}
|
||||||
|
|
||||||
|
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 stable Rust is available..."
|
||||||
|
|
||||||
|
rustup toolchain install stable \
|
||||||
|
--profile minimal \
|
||||||
|
--component rustfmt \
|
||||||
|
--component clippy
|
||||||
|
|
||||||
|
rustup default stable
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo "Using:"
|
||||||
|
rustc --version
|
||||||
|
cargo --version
|
||||||
|
rustfmt --version
|
||||||
|
cargo clippy --version
|
||||||
|
'''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage('Setup Python') {
|
||||||
|
steps {
|
||||||
|
sh '''
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
if ! command -v uv >/dev/null 2>&1; then
|
||||||
|
echo "uv not found — installing it..."
|
||||||
|
|
||||||
|
if ! command -v cargo-binstall >/dev/null 2>&1; then
|
||||||
|
echo "cargo-binstall not found — installing it..."
|
||||||
|
cargo install cargo-binstall
|
||||||
|
fi
|
||||||
|
|
||||||
|
cargo binstall --no-confirm uv
|
||||||
|
else
|
||||||
|
echo "uv already installed."
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Using:"
|
||||||
|
uv --version
|
||||||
|
|
||||||
|
rm -rf "${VENV}"
|
||||||
|
|
||||||
|
echo "Creating Python virtual environment..."
|
||||||
|
uv venv "${VENV}"
|
||||||
|
|
||||||
|
echo "Installing Maturin..."
|
||||||
|
uv pip install \
|
||||||
|
--python "${VENV}/bin/python" \
|
||||||
|
"maturin>=0.14,<0.15"
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo "Python:"
|
||||||
|
"${VENV}/bin/python" --version
|
||||||
|
|
||||||
|
echo "Maturin:"
|
||||||
|
"${VENV}/bin/maturin" --version
|
||||||
|
'''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage('Format') {
|
||||||
|
steps {
|
||||||
|
sh '''
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
echo "Checking Rust formatting..."
|
||||||
|
cargo fmt --all -- --check
|
||||||
|
'''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage('Rust Check') {
|
||||||
|
steps {
|
||||||
|
sh '''
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
echo "Checking Rust targets..."
|
||||||
|
|
||||||
|
cargo check \
|
||||||
|
--all-targets \
|
||||||
|
--all-features
|
||||||
|
'''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage('Rust Tests') {
|
||||||
|
steps {
|
||||||
|
sh '''
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
echo "Running Rust tests..."
|
||||||
|
|
||||||
|
cargo test \
|
||||||
|
--all-targets \
|
||||||
|
--all-features
|
||||||
|
'''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage('Clippy') {
|
||||||
|
steps {
|
||||||
|
sh '''
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
echo "Running Clippy..."
|
||||||
|
|
||||||
|
cargo clippy \
|
||||||
|
--all-targets \
|
||||||
|
--all-features
|
||||||
|
'''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage('Build CLI') {
|
||||||
|
steps {
|
||||||
|
sh '''
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
echo "Building xiv_csolver CLI..."
|
||||||
|
|
||||||
|
cargo build \
|
||||||
|
--release \
|
||||||
|
--bin xiv_csolver_cli
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo "CLI build completed."
|
||||||
|
|
||||||
|
if [ -f target/release/xiv_csolver_cli ]; then
|
||||||
|
ls -lh target/release/xiv_csolver_cli
|
||||||
|
fi
|
||||||
|
'''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage('Build Python Bindings') {
|
||||||
|
steps {
|
||||||
|
sh '''
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
echo "Building Python extension through Maturin..."
|
||||||
|
|
||||||
|
"${VENV}/bin/maturin" build \
|
||||||
|
--release
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo "Python binding build completed."
|
||||||
|
'''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
post {
|
||||||
|
success {
|
||||||
|
publishChecks(
|
||||||
|
conclusion: 'SUCCESS',
|
||||||
|
name: 'Rust/Python CI',
|
||||||
|
summary: 'xiv_csolver passed all CI checks.',
|
||||||
|
text: 'Formatting, Rust checks, tests, Clippy, CLI build, and Python binding build completed successfully.',
|
||||||
|
title: 'Build Successful'
|
||||||
|
)
|
||||||
|
|
||||||
|
echo '✅ xiv_csolver passed all CI checks.'
|
||||||
|
}
|
||||||
|
|
||||||
|
failure {
|
||||||
|
publishChecks(
|
||||||
|
conclusion: 'FAILURE',
|
||||||
|
name: 'Rust/Python CI',
|
||||||
|
summary: 'xiv_csolver failed CI.',
|
||||||
|
text: 'Formatting, Rust compilation, tests, Clippy, CLI build, or Maturin binding build failed. Check the Jenkins log.',
|
||||||
|
title: 'Build Failed'
|
||||||
|
)
|
||||||
|
|
||||||
|
echo '❌ xiv_csolver CI failed.'
|
||||||
|
}
|
||||||
|
|
||||||
|
unstable {
|
||||||
|
publishChecks(
|
||||||
|
conclusion: 'ACTION_REQUIRED',
|
||||||
|
name: 'Rust/Python CI',
|
||||||
|
summary: 'xiv_csolver CI is unstable.',
|
||||||
|
text: 'The Jenkins build completed with an unstable status.',
|
||||||
|
title: 'Build Unstable'
|
||||||
|
)
|
||||||
|
|
||||||
|
echo '⚠️ xiv_csolver CI is unstable.'
|
||||||
|
}
|
||||||
|
|
||||||
|
always {
|
||||||
|
sh '''
|
||||||
|
echo "Cleaning Python CI environment..."
|
||||||
|
rm -rf .venv
|
||||||
|
'''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue