Skip to content
This repository has been archived by the owner on Oct 4, 2019. It is now read-only.

ci: linux-only Jenkinsfile backported from master #51

Open
wants to merge 1 commit into
base: etcjit
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 83 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -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'
}
}
}
}
3 changes: 3 additions & 0 deletions ci/build.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
setx PATH "%PATH%;%USERPROFILE%\.cargo\bin"
set PATH="%PATH%;%USERPROFILE%\.cargo\bin"
%USERPROFILE%\.cargo\bin\cargo build
6 changes: 6 additions & 0 deletions ci/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
set -e
set -x

source $HOME/.cargo/env
cargo $@ build
7 changes: 7 additions & 0 deletions ci/install_rust.ps1
Original file line number Diff line number Diff line change
@@ -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
24 changes: 24 additions & 0 deletions ci/install_rust.sh
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions ci/test.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
setx PATH "%PATH%;%USERPROFILE%\.cargo\bin"
set PATH="%PATH%;%USERPROFILE%\.cargo\bin"
%USERPROFILE%\.cargo\bin\cargo test --all
6 changes: 6 additions & 0 deletions ci/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
set -e
set -x

source $HOME/.cargo/env
cargo $@ test --all