improve jenkins #11

Merged
bquarkz merged 2 commits from dev/improve-jenkins into master 2026-04-08 08:24:16 +00:00
2 changed files with 50 additions and 43 deletions

View File

@ -19,7 +19,7 @@ clean:
cargo llvm-cov clean --workspace cargo llvm-cov clean --workspace
coverage: coverage:
cargo llvm-cov --workspace --all-features --html --output-dir target/llvm-cov/html cargo llvm-cov --workspace --all-features --html --output-dir target/llvm-cov
coverage-xml: coverage-xml:
cargo llvm-cov report --cobertura --output-path target/llvm-cov/cobertura.xml cargo llvm-cov report --cobertura --output-path target/llvm-cov/cobertura.xml

View File

@ -2,6 +2,9 @@ pipeline {
agent any agent any
environment { environment {
CARGO_HOME = '/var/jenkins_home/.cargo'
CARGO_TARGET_DIR = 'target'
CARGO_TERM_COLOR = 'always' CARGO_TERM_COLOR = 'always'
MIN_LINES = '60' MIN_LINES = '60'
@ -12,44 +15,48 @@ pipeline {
stages { stages {
stage('Build') { stage('Build') {
steps { steps {
withChecks(name: 'Test', includeStage: true) { sh '''
sh ''' set -eux
set -eux make ci cobertura
make ci cobertura
LINES=$(jq -r '.data[0].totals.lines.percent' target/llvm-cov/summary.json) LINES=$(jq -r '.data[0].totals.lines.percent' target/llvm-cov/summary.json)
FUNCTIONS=$(jq -r '.data[0].totals.functions.percent' target/llvm-cov/summary.json) FUNCTIONS=$(jq -r '.data[0].totals.functions.percent' target/llvm-cov/summary.json)
REGIONS=$(jq -r '.data[0].totals.regions.percent' target/llvm-cov/summary.json) REGIONS=$(jq -r '.data[0].totals.regions.percent' target/llvm-cov/summary.json)
echo "Coverage summary:" echo "Coverage summary:"
echo " Lines: ${LINES}%" echo " Lines: ${LINES}%"
echo " Functions: ${FUNCTIONS}%" echo " Functions: ${FUNCTIONS}%"
echo " Regions: ${REGIONS}%" echo " Regions: ${REGIONS}%"
FAIL=0 FAIL=0
awk "BEGIN { exit !(${LINES} < ${MIN_LINES}) }" && { awk "BEGIN { exit !(${LINES} < ${MIN_LINES}) }" && {
echo "Lines coverage ${LINES}% is below minimum ${MIN_LINES}%" echo "Lines coverage ${LINES}% is below minimum ${MIN_LINES}%"
FAIL=1 FAIL=1
} || true } || true
awk "BEGIN { exit !(${FUNCTIONS} < ${MIN_FUNCTIONS}) }" && { awk "BEGIN { exit !(${FUNCTIONS} < ${MIN_FUNCTIONS}) }" && {
echo "Functions coverage ${FUNCTIONS}% is below minimum ${MIN_FUNCTIONS}%" echo "Functions coverage ${FUNCTIONS}% is below minimum ${MIN_FUNCTIONS}%"
FAIL=1 FAIL=1
} || true } || true
awk "BEGIN { exit !(${REGIONS} < ${MIN_REGIONS}) }" && { awk "BEGIN { exit !(${REGIONS} < ${MIN_REGIONS}) }" && {
echo "Regions coverage ${REGIONS}% is below minimum ${MIN_REGIONS}%" echo "Regions coverage ${REGIONS}% is below minimum ${MIN_REGIONS}%"
FAIL=1 FAIL=1
} || true } || true
if [ "$FAIL" -ne 0 ]; then if [ "$FAIL" -ne 0 ]; then
echo "Coverage gate failed." echo "Coverage gate failed."
exit 1 exit 1
fi fi
echo "Coverage gate passed." echo "Coverage gate passed."
''' '''
// withChecks(name: 'Test', includeStage: true) {
// sh '''
// set -eux
// make ci cobertura
// '''
// recordCoverage( // recordCoverage(
// tools: [[parser: 'COBERTURA', pattern: 'target/llvm-cov/cobertura.xml']], // tools: [[parser: 'COBERTURA', pattern: 'target/llvm-cov/cobertura.xml']],
// sourceCodeRetention: 'LAST_BUILD', // sourceCodeRetention: 'LAST_BUILD',
@ -65,23 +72,23 @@ pipeline {
// [metric: 'BRANCH', baseline: 'PROJECT', threshold: 0.0] // [metric: 'BRANCH', baseline: 'PROJECT', threshold: 0.0]
// ] // ]
// ) // )
} // }
} }
} // Test } // Test
stage('Reports') { stage('Reports') {
steps { steps {
script { publishHTML(target: [
publishHTML(target: [ allowMissing: false,
allowMissing: false, alwaysLinkToLastBuild: true,
alwaysLinkToLastBuild: true, keepAll: true,
keepAll: true, reportDir: 'target/llvm-cov/html',
reportDir: 'target/llvm-cov/html', reportFiles: 'index.html',
reportFiles: 'index.html', reportName: 'Rust Coverage HTML',
reportName: 'Rust Coverage HTML', reportTitles: 'Coverage Report'
reportTitles: 'Coverage Report' ])
])
} archiveArtifacts artifacts: 'target/llvm-cov/**', fingerprint: true
} }
} // Reports } // Reports
} }