Skip to content

Commit

Permalink
Only run the tests when we should
Browse files Browse the repository at this point in the history
Avoid running the tests when all the commit files belongs to `skipTestsFilesList` otherwise run tests.
  • Loading branch information
adeas31 committed Sep 18, 2019
1 parent 66641cb commit 4e86690
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 7 deletions.
26 changes: 24 additions & 2 deletions .CI/common.groovy
Expand Up @@ -299,7 +299,7 @@ def makeCommand() {
}

def shouldWeBuildOSX() {
if (env.CHANGE_ID) {
if (isPR()) {
if (pullRequest.labels.contains("CI/Build OSX")) {
return true
}
Expand All @@ -308,14 +308,36 @@ def shouldWeBuildOSX() {
}

def shouldWeBuildMINGW() {
if (env.CHANGE_ID) {
if (isPR()) {
if (pullRequest.labels.contains("CI/Build MINGW")) {
return true
}
}
return params.BUILD_MINGW
}

def shouldWeRunTests() {
if (isPR()) {
def skipTestsFilesList = [".*[.]md",
"OMEdit/.*",
"OMNotebook/.*",
"OMPlot/.*",
"OMShell/.*"]
def runTest = false
for (commitFile in pullRequest.files) {
def results = skipTestsFilesList.findAll {element -> commitFile.filename.matches(element)}
if (results.size() > 0) {
continue
} else {
runTest = true
break;
}
}
return runTest
}
return true
}

def isPR() {
return env.CHANGE_ID ? true : false
}
Expand Down
60 changes: 55 additions & 5 deletions Jenkinsfile
@@ -1,6 +1,7 @@
def common
def shouldWeBuildOSX
def shouldWeBuildMINGW
def shouldWeRunTests
def isPR
pipeline {
agent none
Expand All @@ -27,15 +28,16 @@ pipeline {
def buildNumber = env.BUILD_NUMBER as int
if (buildNumber > 1) milestone(buildNumber - 1)
milestone(buildNumber)
isPR = true
} else {
isPR = false
}
common = load("${env.workspace}/.CI/common.groovy")
isPR = common.isPR()
print "isPR: ${isPR}"
shouldWeBuildOSX = common.shouldWeBuildOSX()
print "shouldWeBuildOSX: ${shouldWeBuildOSX}"
shouldWeBuildMINGW = common.shouldWeBuildMINGW()
print "shouldWeBuildMINGW: ${shouldWeBuildMINGW}"
shouldWeRunTests = common.shouldWeRunTests()
print "shouldWeRunTests: ${shouldWeRunTests}"
}
}
}
Expand Down Expand Up @@ -175,6 +177,10 @@ pipeline {
RUNTESTDB = "/cache/runtest/"
LIBRARIES = "/cache/omlibrary"
}
when {
beforeAgent true
expression { shouldWeRunTests }
}
steps {
script {
common.standardSetup()
Expand All @@ -199,6 +205,10 @@ pipeline {
RUNTESTDB = "/cache/runtest/"
LIBRARIES = "/cache/omlibrary"
}
when {
beforeAgent true
expression { shouldWeRunTests }
}
steps {
script {
common.standardSetup()
Expand All @@ -219,6 +229,10 @@ pipeline {
RUNTESTDB = "/cache/runtest/"
LIBRARIES = "/cache/omlibrary"
}
when {
beforeAgent true
expression { shouldWeRunTests }
}
steps {
script {
def deps = docker.build('testsuite-fmu-crosscompile', '--pull .CI/cache')
Expand Down Expand Up @@ -261,6 +275,10 @@ pipeline {
COMPLIANCEEXTRAREPORTFLAGS = "--expectedFailures=.CI/compliance.failures --flakyTests=.CI/compliance.flaky"
COMPLIANCEPREFIX = "compliance"
}
when {
beforeAgent true
expression { shouldWeRunTests }
}
steps {
script { common.compliance() }
}
Expand All @@ -287,6 +305,10 @@ pipeline {
COMPLIANCEEXTRAREPORTFLAGS = "--expectedFailures=.CI/compliance-newinst.failures"
COMPLIANCEPREFIX = "compliance-newinst"
}
when {
beforeAgent true
expression { shouldWeRunTests }
}
steps {
script { common.compliance() }
}
Expand Down Expand Up @@ -367,6 +389,10 @@ pipeline {
// No runtest.db cache necessary; the tests run in serial and do not load libraries!
}
}
when {
beforeAgent true
expression { shouldWeRunTests }
}
steps {
script {
common.standardSetup()
Expand All @@ -383,6 +409,10 @@ pipeline {
label 'linux'
}
}
when {
beforeAgent true
expression { shouldWeRunTests }
}
steps {
script { common.standardSetup() }
unstash 'omc-clang'
Expand All @@ -398,6 +428,10 @@ pipeline {
alwaysPull true
}
}
when {
beforeAgent true
expression { shouldWeRunTests }
}
steps {
script {
common.standardSetup()
Expand All @@ -419,6 +453,10 @@ pipeline {
image 'docker.openmodelica.org/fmuchecker:v2.0.4'
}
}
when {
beforeAgent true
expression { shouldWeRunTests }
}
options {
skipDefaultCheckout true
}
Expand All @@ -440,6 +478,10 @@ pipeline {
agent {
label 'osx'
}
when {
beforeAgent true
expression { shouldWeRunTests }
}
options {
skipDefaultCheckout true
}
Expand All @@ -460,6 +502,10 @@ pipeline {
image 'docker.openmodelica.org/fmuchecker:v2.0.4-arm'
}
}
when {
beforeAgent true
expression { shouldWeRunTests }
}
options {
skipDefaultCheckout true
}
Expand All @@ -485,6 +531,10 @@ pipeline {
alwaysPull true
}
}
when {
beforeAgent true
expression { shouldWeRunTests }
}
options {
skipDefaultCheckout true
}
Expand All @@ -509,7 +559,7 @@ pipeline {
}
when {
beforeAgent true
expression { not isPR }
expression { !isPR }
}
steps {
unstash 'compliance'
Expand All @@ -527,7 +577,7 @@ pipeline {
}
when {
beforeAgent true
expression { not isPR }
expression { !isPR }
}
steps {
unstash 'usersguide'
Expand Down

0 comments on commit 4e86690

Please sign in to comment.