Skip to content

Commit

Permalink
Selected branches coverage (hyperledger-iroha#1122)
Browse files Browse the repository at this point in the history
* run coverage for selected branches only

Signed-off-by: Artyom Bakhtin <[email protected]>

* branches to cover as a separate script

Signed-off-by: Artyom Bakhtin <[email protected]>
  • Loading branch information
bakhtin authored Mar 31, 2018
1 parent e13a37e commit 76d5ec2
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 6 deletions.
13 changes: 13 additions & 0 deletions .jenkinsci/selected-branches-coverage.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env groovy

def selectedBranchesCoverage(branches, PRCoverage=true) {
// trigger coverage if branch is either develop or master, or it is a PR
if (PRCoverage) {
return env.BRANCH_NAME in branches || env.CHANGE_ID != null
}
else {
return env.BRANCH_NAME in branches
}
}

return this
21 changes: 15 additions & 6 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,13 @@ pipeline {
steps {
script {
debugBuild = load ".jenkinsci/debug-build.groovy"
debugBuild.doDebugBuild(true)
coverage = load ".jenkinsci/selected-branches-coverage.groovy"
if (coverage.selectedBranchesCoverage(['develop', 'master'])) {
debugBuild.doDebugBuild(true)
}
else {
debugBuild.doDebugBuild()
}
if (BRANCH_NAME ==~ /(master|develop)/) {
releaseBuild = load ".jenkinsci/release-build.groovy"
releaseBuild.doReleaseBuild()
Expand All @@ -117,8 +123,9 @@ pipeline {
agent { label 'armv7' }
steps {
script {
def debugBuild = load ".jenkinsci/debug-build.groovy"
if (!params.Linux && !params.ARMv8 && !params.MacOS) {
debugBuild = load ".jenkinsci/debug-build.groovy"
coverage = load ".jenkinsci/selected-branches-coverage.groovy"
if (!params.Linux && !params.ARMv8 && !params.MacOS && (coverage.selectedBranchesCoverage(['develop', 'master']))) {
debugBuild.doDebugBuild(true)
}
else {
Expand Down Expand Up @@ -147,8 +154,9 @@ pipeline {
agent { label 'armv8' }
steps {
script {
def debugBuild = load ".jenkinsci/debug-build.groovy"
if (!params.Linux && !params.MacOS) {
debugBuild = load ".jenkinsci/debug-build.groovy"
coverage = load ".jenkinsci/selected-branches-coverage.groovy"
if (!params.Linux && !params.MacOS && (coverage.selectedBranchesCoverage(['develop', 'master']))) {
debugBuild.doDebugBuild(true)
}
else {
Expand Down Expand Up @@ -179,7 +187,8 @@ pipeline {
script {
def coverageEnabled = false
def cmakeOptions = ""
if (!params.Linux) {
coverage = load ".jenkinsci/selected-branches-coverage.groovy"
if (!params.Linux && (coverage.selectedBranchesCoverage(['develop', 'master']))) {
coverageEnabled = true
cmakeOptions = " -DCOVERAGE=ON "
}
Expand Down

0 comments on commit 76d5ec2

Please sign in to comment.