dev/jenkinsfile (#10)
Reviewed-on: #10 Co-authored-by: bQUARKz <bquarkz@gmail.com> Co-committed-by: bQUARKz <bquarkz@gmail.com>
This commit was merged in pull request #10.
This commit is contained in:
Vendored
+88
@@ -0,0 +1,88 @@
|
||||
pipeline {
|
||||
agent any
|
||||
|
||||
environment {
|
||||
CARGO_TERM_COLOR = 'always'
|
||||
|
||||
MIN_LINES = '60'
|
||||
MIN_FUNCTIONS = '60'
|
||||
MIN_REGIONS = '60'
|
||||
}
|
||||
|
||||
stages {
|
||||
stage('Build') {
|
||||
steps {
|
||||
withChecks(name: 'Test', includeStage: true) {
|
||||
sh '''
|
||||
set -eux
|
||||
make ci cobertura
|
||||
|
||||
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)
|
||||
REGIONS=$(jq -r '.data[0].totals.regions.percent' target/llvm-cov/summary.json)
|
||||
|
||||
echo "Coverage summary:"
|
||||
echo " Lines: ${LINES}%"
|
||||
echo " Functions: ${FUNCTIONS}%"
|
||||
echo " Regions: ${REGIONS}%"
|
||||
|
||||
FAIL=0
|
||||
|
||||
awk "BEGIN { exit !(${LINES} < ${MIN_LINES}) }" && {
|
||||
echo "Lines coverage ${LINES}% is below minimum ${MIN_LINES}%"
|
||||
FAIL=1
|
||||
} || true
|
||||
|
||||
awk "BEGIN { exit !(${FUNCTIONS} < ${MIN_FUNCTIONS}) }" && {
|
||||
echo "Functions coverage ${FUNCTIONS}% is below minimum ${MIN_FUNCTIONS}%"
|
||||
FAIL=1
|
||||
} || true
|
||||
|
||||
awk "BEGIN { exit !(${REGIONS} < ${MIN_REGIONS}) }" && {
|
||||
echo "Regions coverage ${REGIONS}% is below minimum ${MIN_REGIONS}%"
|
||||
FAIL=1
|
||||
} || true
|
||||
|
||||
if [ "$FAIL" -ne 0 ]; then
|
||||
echo "Coverage gate failed."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Coverage gate passed."
|
||||
'''
|
||||
// recordCoverage(
|
||||
// tools: [[parser: 'COBERTURA', pattern: 'target/llvm-cov/cobertura.xml']],
|
||||
// sourceCodeRetention: 'LAST_BUILD',
|
||||
// enabledForFailure: true,
|
||||
// failOnError: false,
|
||||
// checksAnnotationScope: 'MODIFIED_LINES',
|
||||
// id: 'rust-coverage',
|
||||
// name: 'Rust Coverage',
|
||||
// checksName: 'Rust Coverage',
|
||||
// qualityGates: [
|
||||
// [metric: 'LINE', baseline: 'MODIFIED_LINES', threshold: 0.0],
|
||||
// [metric: 'LINE', baseline: 'PROJECT', threshold: 0.0],
|
||||
// [metric: 'BRANCH', baseline: 'PROJECT', threshold: 0.0]
|
||||
// ]
|
||||
// )
|
||||
}
|
||||
}
|
||||
} // Test
|
||||
|
||||
stage('Reports') {
|
||||
steps {
|
||||
script {
|
||||
publishHTML(target: [
|
||||
allowMissing: false,
|
||||
alwaysLinkToLastBuild: true,
|
||||
keepAll: true,
|
||||
reportDir: 'target/llvm-cov/html',
|
||||
reportFiles: 'index.html',
|
||||
reportName: 'Rust Coverage HTML',
|
||||
reportTitles: 'Coverage Report'
|
||||
])
|
||||
}
|
||||
}
|
||||
} // Reports
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user