From ff4428ebef3dc99e438d2e1ec35e66e48ffd0ebd Mon Sep 17 00:00:00 2001 From: Dandaedre Date: Sun, 13 Sep 2026 13:32:15 +0200 Subject: [PATCH] Add Jenkinsfile --- Jenkinsfile | 237 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 237 insertions(+) create mode 100644 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..7c7fcc1 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,237 @@ +// 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 \ + --locked + ''' + } + } + + stage('Rust Tests') { + steps { + sh ''' + set -eu + + echo "Running Rust tests..." + + cargo test \ + --all-targets \ + --all-features \ + --locked + ''' + } + } + + stage('Clippy') { + steps { + sh ''' + set -eu + + echo "Running Clippy..." + + cargo clippy \ + --all-targets \ + --all-features \ + --locked + ''' + } + } + + stage('Build CLI') { + steps { + sh ''' + set -eu + + echo "Building xiv_csolver CLI..." + + cargo build \ + --release \ + --bin xiv_csolver_cli \ + --locked + + 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 \ + --locked + + 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 + ''' + } + } +} \ No newline at end of file -- 2.45.1