Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
// That PR should be landed with out deleting the PR branch.
// Then a second PR submitted to comment out the @Library line, and when it
// is landed, both PR branches can be deleted.
//@Library(value='pipeline-lib@my_branch_name') _
@Library(value='pipeline-lib@osalyk/SRE-322') _

/* groovylint-disable-next-line CompileStatic */
job_status_internal = [:]
Expand Down
22 changes: 22 additions & 0 deletions vars/getCommitTags.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// vars/getCommitTags.groovy


def call() {
def commitMsg = sh(
script: "git log -1 --pretty=%B",
returnStdout: true
).trim()

def commitTags = []

commitMsg.split("\n").each { line ->
if (line.toLowerCase().startsWith("test-tag:")) {
def value = line.split(":", 2)[1].trim()
if (value) {
commitTags.addAll(value.split())
}
}
}

return commitTags as Set
}
56 changes: 56 additions & 0 deletions vars/getTestTag.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// vars/getTestTag.groovy


def call(Map commitPragmaMapping, List<String> paths, String defaultTag = 'pr') {

def commitTags = getCommitTags() as Set

def allTags = [] as Set
allTags.addAll(commitTags)

def ftestTagMap = new org.example.ftest.FtestTagMap(
org.example.ftest.FtestTagMap.allFtestPythonFiles()
)

paths.each { path ->
commitPragmaMapping.each { pattern, config ->
if (path ==~ /${pattern}/) {

def testTagConfig = config.get('test-tag', defaultTag)

if (testTagConfig instanceof String) {
testTagConfig = [
tags: testTagConfig,
handler: 'direct'
]
}

def handler = testTagConfig.handler

if (handler == 'FtestTagMap') {
try {
allTags.addAll(ftestTagMap.minimalTags(path))
} catch (Exception e) {
allTags.addAll(testTagConfig.tags.split(' '))
}
} else if (handler == 'direct') {
allTags.addAll(testTagConfig.tags.split(' '))
} else {
error "Invalid handler: ${handler}"
}

if (testTagConfig.get('stop_on_match', config.get('stop_on_match', false))) {
return
}
}
}
}

def validTags = ftestTagMap.uniqueTags()
invalid = allTags - validTags
if (invalid) {
error "test-tag does not match any tests: ${invalid.join(', ')}"
}

return allTags.sort().join(' ')
}