Skip to content
This repository has been archived by the owner on Sep 17, 2024. It is now read-only.

Commit

Permalink
chore: properly evaluate how tests are skipped on CI when checking mo…
Browse files Browse the repository at this point in the history
…dified files (#1924)

* chore: consistency

* chore: refactor how the evaluation of the skip_tests is done

* chore: use proper function name

* chore: remove non needed initialisation

Co-authored-by: Victor Martinez <[email protected]>

* chore: call method without script block

Co-authored-by: Victor Martinez <[email protected]>
  • Loading branch information
mdelapenya and v1v authored Dec 17, 2021
1 parent 77cf62f commit e438b87
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 additions & 10 deletions .ci/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,7 @@ pipeline {
githubCheckNotify('PENDING') // we want to notify the upstream about the e2e the soonest
stash allowEmpty: true, name: 'source', useDefaultExcludes: false
setEnvVar("GO_VERSION", readFile("${env.WORKSPACE}/${env.BASE_DIR}/.go-version").trim())
dir("${BASE_DIR}"){
// Skip all the test stages for PR's with markdown changes only
setEnvVar("SKIP_TESTS", isGitRegionMatch(patterns: [ '.*\\.md' ], shouldMatchAll: true))
script {
def regexps = [ "^e2e/_suites/fleet/.*", "^e2e/_suites/helm/.*", "^e2e/_suites/kubernetes-autodiscover/.*", "^.ci/.*", "^cli/.*", "^e2e/.*\\.go", "^internal/.*\\.go" ]
setEnvVar("SKIP_TESTS", !isGitRegionMatch(patterns: regexps, shouldMatchAll: false))
}
}
checkSkipTests()
}
}
stage('Pre-Submit') {
Expand Down Expand Up @@ -133,8 +126,10 @@ pipeline {
options { skipDefaultCheckout() }
when {
beforeAgent true
expression { return env.FORCE_SKIP_GIT_CHECKS == "true" }
expression { return env.SKIP_TESTS == "false" }
anyOf {
expression { return env.FORCE_SKIP_GIT_CHECKS == "true" }
expression { return env.SKIP_TESTS == "false" }
}
}
steps {
withGithubNotify(context: 'Tests', tab: 'tests') {
Expand Down Expand Up @@ -305,6 +300,23 @@ pipeline {
}
}

// this function evaluates if the test stage of the build must be executed
def checkSkipTests() {
dir("${BASE_DIR}"){

// only docs means no tests are run
if (isGitRegionMatch(patterns: [ '.*\\.md' ], shouldMatchAll: true)) {
setEnvVar("SKIP_TESTS", true)
return
}

// patterns for all places that should trigger a full build
def regexps = [ "^e2e/_suites/fleet/.*", "^e2e/_suites/helm/.*", "^e2e/_suites/kubernetes-autodiscover/.*", "^.ci/.*", "^cli/.*", "^e2e/.*\\.go", "^internal/.*\\.go" ]
setEnvVar("SKIP_TESTS", !isGitRegionMatch(patterns: regexps, shouldMatchAll: false))
}
}


def sshexec(workspace, connection, cmd){
sh "ssh -tt -o TCPKeepAlive=yes -o ServerAliveInterval=60 -o ServerAliveCountMax=10 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i ${workspace}/e2essh ${connection.user}@${connection.ip} -- '${cmd}'"
}
Expand Down

0 comments on commit e438b87

Please sign in to comment.