From 09d525ee820afdf7e794edbbe8cf1f414de41815 Mon Sep 17 00:00:00 2001 From: mersinvald Date: Sun, 30 Jun 2019 18:11:07 +0300 Subject: [PATCH] ci: linux-only Jenkinsfile until it's possible to toggle jit as a feature --- Jenkinsfile | 83 +++++++++++++++++++++++++++++++++++++++++++++ ci/build.bat | 3 ++ ci/build.sh | 6 ++++ ci/install_rust.ps1 | 7 ++++ ci/install_rust.sh | 24 +++++++++++++ ci/test.bat | 3 ++ ci/test.sh | 6 ++++ 7 files changed, 132 insertions(+) create mode 100644 Jenkinsfile create mode 100644 ci/build.bat create mode 100755 ci/build.sh create mode 100755 ci/install_rust.ps1 create mode 100755 ci/install_rust.sh create mode 100644 ci/test.bat create mode 100755 ci/test.sh diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..d866fc8 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,83 @@ +pipeline { + agent none + stages { + stage('Install Rust') { + parallel { + stage('linux') { + agent { label 'linux' } + steps { + sh './ci/install_rust.sh' + } + } + } + } + stage('Build') { + parallel { + stage('linux') { + agent { + label 'linux' + } + stages { + stage('stable') { + steps { + sh './ci/build.sh' + } + } + stage('beta') { + steps { + sh './ci/build.sh +beta' + } + } + stage('nightly') { + steps { + sh './ci/build.sh +nightly' + } + } + } + } + } + } + stage('Test') { + parallel { + stage('linux') { + agent { + label 'linux' + } + steps { + sh './ci/test.sh' + } + } + } + } + stage('Lint') { + agent { node { label 'linux' } } + steps { + sh 'cargo check 2>&1 | tee rustc.build_log' + sh 'cargo clean' + sh 'cargo clippy 2>&1 | tee clippy.build_log' + sh 'if grep -q "^error" clippy.build_log; then echo "clippy found a severe error"; exit 1; fi' + } + post { + always { + script { + recordIssues enabledForFailure: true, + qualityGates: [[threshold: 10, type: 'TOTAL', unstable: true]], + healthy: 5, unhealthy: 20, minimumSeverity: 'HIGH', + tools: [ + groovyScript(parserId: 'clippy-warnings', pattern: "clippy.build_log", reportEncoding:'UTF-8'), + groovyScript(parserId: 'rustc-warnings', pattern: "rustc.build_log", reportEncoding:'UTF-8') + ] + } + } + } + } + stage('Rustfmt') { + agent { + label 'linux' + } + steps { + sh 'cargo fmt -- --check' + } + } + } +} diff --git a/ci/build.bat b/ci/build.bat new file mode 100644 index 0000000..efb81e5 --- /dev/null +++ b/ci/build.bat @@ -0,0 +1,3 @@ +setx PATH "%PATH%;%USERPROFILE%\.cargo\bin" +set PATH="%PATH%;%USERPROFILE%\.cargo\bin" +%USERPROFILE%\.cargo\bin\cargo build diff --git a/ci/build.sh b/ci/build.sh new file mode 100755 index 0000000..2719880 --- /dev/null +++ b/ci/build.sh @@ -0,0 +1,6 @@ +#!/bin/bash +set -e +set -x + +source $HOME/.cargo/env +cargo $@ build diff --git a/ci/install_rust.ps1 b/ci/install_rust.ps1 new file mode 100755 index 0000000..c50261e --- /dev/null +++ b/ci/install_rust.ps1 @@ -0,0 +1,7 @@ +if (Test-Path -Path C:\Users\jenkins\.cargo\bin\rustup.exe) { + exit +} + +$client = new-object System.Net.WebClient +$client.DownloadFile('https://win.rustup.rs', "$pwd\rustup-init.exe") +.\rustup-init.exe -y diff --git a/ci/install_rust.sh b/ci/install_rust.sh new file mode 100755 index 0000000..1c7f90d --- /dev/null +++ b/ci/install_rust.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +# Fail fast if any commands exists with error +set -e + +# Print all executed commands +set -x + +# Download rustup script and execute it +curl https://sh.rustup.rs -sSf > ./rustup.sh +chmod +x ./rustup.sh +./rustup.sh -y + +# Load new environment +source $HOME/.cargo/env + +# Install nightly and beta toolchains, but set stable as a default +rustup install nightly +rustup install beta +rustup default stable + +# Install aux components, clippy for linter, rustfmt for formatting +rustup component add clippy +rustup component add rustfmt diff --git a/ci/test.bat b/ci/test.bat new file mode 100644 index 0000000..8b2c336 --- /dev/null +++ b/ci/test.bat @@ -0,0 +1,3 @@ +setx PATH "%PATH%;%USERPROFILE%\.cargo\bin" +set PATH="%PATH%;%USERPROFILE%\.cargo\bin" +%USERPROFILE%\.cargo\bin\cargo test --all diff --git a/ci/test.sh b/ci/test.sh new file mode 100755 index 0000000..5d80d1e --- /dev/null +++ b/ci/test.sh @@ -0,0 +1,6 @@ +#!/bin/bash +set -e +set -x + +source $HOME/.cargo/env +cargo $@ test --all