Skip to content

Commit

Permalink
Merge branch 'gurka-feat-harp_ci' into 'main'
Browse files Browse the repository at this point in the history
jenkins: [FEATURE] Integrate harp into Jenkins

See merge request ndk/ofm!416
  • Loading branch information
martinspinler committed Sep 23, 2024
2 parents f32bd08 + f55f132 commit c9d5275
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 1 deletion.
86 changes: 86 additions & 0 deletions tests/jenkins/common.jenkins
Original file line number Diff line number Diff line change
Expand Up @@ -151,4 +151,90 @@ def commonPrekladMultiVerRun(COMPONENTS, ofm_path = pwd()) {
}
}

def commonPrekladHarpRun(COMPONENTS, ofm_path = pwd()) {
// Clean old builds from Jenkins history
cleanBuilds()

// fetch sources from GIT
checkout scm
// clean artifacts possibly left by previous builds
sh "git clean -df"

// every midnight check for new commits and run pipeline if they exist
properties([pipelineTriggers([pollSCM('H H(0-2) * * *')])])

def failed = []
//load new fpga_version and set default simulator
def toolsel = "set +x\n"
toolsel += "source fpga_version.sh\n"
toolsel += "fpga_sim -d\n"
toolsel += "set -x\n"

def venv_dir = "$ofm_path/python/harp/harp_venv"

// prepare virtual environment with HARP
stage("Prepare virtual env") {
sh """
if ! command -v python3.9; then
echo "Python 3.9 is not installed. Please install Python 3.9."
exit 1
fi
python3.9 -m venv $venv_dir
source $venv_dir/bin/activate
pip install --upgrade pip
pip install $ofm_path/python/harp
"""
}

def env_source = "source $venv_dir/bin/activate\n"

for(c in COMPONENTS) {
// parse
def name = c[0]
def path = c[1]

// exec vsim
try { // try-catch is a hack to continue even after the first failed verification
timeout(time: 4, unit: 'HOURS') {
stage("$name") {
dir("$path") {
def command = "harp multiver"
sh "${env_source}${toolsel}${command}"
}
}
}
} catch(err) {
currentBuild.result = 'FAILURE' // still propagate failure status to Jenkins
failed.add("$name")
} finally { // collect interesting files
// there is unknown path to transcripts folder
// archiveArtifacts "$path/transcript*"
if(currentBuild.result == "FAILURE") {
archiveArtifacts "$path/failed_combinations.csv" // failed combinations summary with seed
// there is unknown path to wave folder
// archiveArtifacts "$path/vsim.wlf"
}
}
}

// send out emails if failure is detected
if(currentBuild.result == "FAILURE") {
println "FAILED on components: ${failed}."
emailext \
recipientProviders: [culprits(), developers()],
to: '[email protected]',
subject: "[Jenkins] ${currentBuild.currentResult} ${env.JOB_NAME} #${currentBuild.number}",
body: """\
The build of the repository (with HARP) ${env.JOB_NAME} #${currentBuild.number} ends up with status ${currentBuild.currentResult} on components: ${failed}. You can find build log in the attachments.

For more details see ${env.BUILD_URL}.

Yours sincerely
Jenkins\
""".stripIndent(),
attachLog: true,
compressLog: true
}
}

return this
6 changes: 5 additions & 1 deletion tests/jenkins/ver_mvb_tools.jenkins
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,22 @@ def COMPONENTS_MULTIVER = [\
['TCAM' , 'comp/mvb_tools/storage/tcam/ver' , 'top_level.fdo' , 'tbench/test_pkg.sv' , 'ver_settings.py' ],\
['GEN_DEMUX', , 'comp/mvb_tools/flow/demux/uvm' , 'top_level.fdo' , 'tbench/tests/pkg.sv' , 'ver_settings.py' ],\
['GEN_MUX', , 'comp/mvb_tools/flow/mux/uvm' , 'top_level.fdo' , 'tbench/tests/pkg.sv' , 'ver_settings.py' ],\
['MVB2MFB' , 'comp/mvb_tools/flow/mvb2mfb/uvm' , 'top_level.fdo' , 'tbench/tests/pkg.sv' , 'ver_settings.py' ],\
['MERGE_ITEMS' , 'comp/mvb_tools/flow/merge_items/uvm' , 'top_level.fdo' , 'tbench/tests/pkg.sv' , 'ver_settings.py' ],\
['MERGE_STREAMS_ORDERED' , 'comp/mvb_tools/flow/merge_streams_ordered/uvm' , 'top_level.fdo' , 'tbench/tests/pkg.sv' , 'ver_settings.py' ],\
]
// /////////////////////////////////////////////////////////////////////////////

def COMPONENTS_HARP = [\
['MVB2MFB', 'comp/mvb_tools/flow/mvb2mfb'],\
]

// Run component verifications using common script
node('preklad') {
lock(label:"resources-${env.NODE_NAME}", quantity: 1) {
// fetch sources from GIT
checkout scm
def common_run = load "tests/jenkins/common.jenkins"
common_run.commonPrekladHarpRun(COMPONENTS_HARP)
common_run.commonPrekladVerRun(COMPONENTS_VER)
common_run.commonPrekladMultiVerRun(COMPONENTS_MULTIVER)
}
Expand Down

0 comments on commit c9d5275

Please sign in to comment.