Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test slack back #106

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 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
22 changes: 15 additions & 7 deletions ghaf-main-pipeline.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ properties([

// Record failed target(s)
def failedTargets = []

def failedHWTests = []
def target_jobs = [:]

////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -114,7 +114,7 @@ pipeline {
dir(WORKDIR) {
script {
utils.nix_eval_jobs(targets)
target_jobs = utils.create_parallel_stages(targets)
target_jobs = utils.create_parallel_stages(targets,false,failedTargets,failedHWTests)
}
}
}
Expand All @@ -136,23 +136,31 @@ pipeline {
servername = sh(script: 'uname -n', returnStdout: true).trim()
echo "Server name:$servername"
def formattedFailedMessage = ""
def formattedHWFailedTests = ""
def line5=""
def line6=""
if (failedTargets) {
formattedFailedMessage = failedTargets.collect { "- ${it.trim()}" }.join("\n")
} else {
formattedFailedMessage = "None, builds were ok, maybe HW tests failed?"
formattedFailedMessage = "No failed build targets"
formattedHWFailedMessage = failedHWTests.collect { "- ${it.trim()}" }.join("\n")
line5="\n*Failed HW test targets:*".stripIndent()
line6="\n${formattedHWFailedMessage}".stripIndent()
}
if (servername=="ghaf-jenkins-controller-prod") {
serverchannel="ghaf-build" // prod main build failures channel
echo "Slack channel:$serverchannel"
line1="*FAILURE:* ${env.BUILD_URL}".stripIndent()
line2="\n*Failed Targets:*".stripIndent()
line3="\n${formattedFailedMessage}".stripIndent()
line4="\n*Commit*: <${githublink}|${env.TARGET_COMMIT}>".stripIndent()
line2="\nCommit: <${githublink}|${env.TARGET_COMMIT}>".stripIndent()
line3="\n*Failed build targets:*".stripIndent()
line4="\n${formattedFailedMessage}".stripIndent()
message = """
${line1}
${line2}
${line3}
${line4}""".stripIndent()
${line4}
${line5}
${line6}""".stripIndent()
slackSend (
channel: "$serverchannel",
color: "danger",
Expand Down
21 changes: 16 additions & 5 deletions utils.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,8 @@ def ghaf_hw_test(String flakeref, String device_config, String testset='_boot_')
// Add a link to failed test job(s) on the calling pipeline
def test_href = "<a href=\"${job.absoluteUrl}\">⛔ ${flakeref_trimmed}</a>"
currentBuild.description = "${currentBuild.description}<br>${test_href}"
return
return flakeref

}
// Copy test results from agent to controller to 'test-results' directory
copyArtifacts(
Expand All @@ -243,6 +244,7 @@ def ghaf_hw_test(String flakeref, String device_config, String testset='_boot_')
)
// Archive the test results
archive_artifacts("ghaf-hw-test", flakeref_trimmed)
return null
}

def nix_eval_jobs(List<Map> targets) {
Expand Down Expand Up @@ -301,15 +303,14 @@ def nix_eval_hydrajobs(List<Map> targets) {
}
}

def create_parallel_stages(List<Map> targets, Boolean skip_hw_test=false) {
def create_parallel_stages(List<Map> targets, Boolean skip_hw_test=false, List failedTargets = null, List failedHWTests =null) {
def target_jobs = [:]
targets.each {
def timestampBegin = ""
def timestampEnd = ""
def displayName = "${it.target} (${it.system})"
def targetAttr = "${it.system}.${it.target}"
def scsdir = "scs/${targetAttr}/scs"

target_jobs[displayName] = {
stage("Build ${displayName}") {
def opts = ""
Expand All @@ -322,7 +323,6 @@ def create_parallel_stages(List<Map> targets, Boolean skip_hw_test=false) {
if (it.error) {
error("Error in evaluation! ${it.error}")
}

timestampBegin = sh(script: "date +%s", returnStdout: true).trim()
sh "nix build -L ${it.drvPath}\\^* ${opts}"
timestampEnd = sh(script: "date +%s", returnStdout: true).trim()
Expand All @@ -338,6 +338,9 @@ def create_parallel_stages(List<Map> targets, Boolean skip_hw_test=false) {
} catch (Exception e) {
unstable("FAILED: ${displayName}")
currentBuild.result = "FAILURE"
if (failedTargets != null) {
failedTargets.add(targetAttr)
}
println "Error: ${e.toString()}"
}
}
Expand Down Expand Up @@ -418,7 +421,15 @@ def create_parallel_stages(List<Map> targets, Boolean skip_hw_test=false) {
if (!skip_hw_test && it.hwtest_device != null) {
stage("Test ${displayName}") {
script {
ghaf_hw_test(targetAttr, it.hwtest_device, '_boot_bat_perf_')
errorstatus=ghaf_hw_test(targetAttr, it.hwtest_device, '_boot_bat_perf_')
println ("Test creation and execution done")
if (errorstatus==null) {
println("Test was OK")
}
else {
failedHWTests.add(errorstatus)
println ("ERROR FOUND, target: ${errorstatus}")
}
}
}
}
Expand Down