Skip to content

Commit

Permalink
[CI] Generate html test reports on successful runs
Browse files Browse the repository at this point in the history
  • Loading branch information
johnnoel committed Oct 26, 2023
1 parent c7c905c commit 9132511
Showing 1 changed file with 35 additions and 18 deletions.
53 changes: 35 additions & 18 deletions ci/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ pipeline {
getBoardFiles(env.BOARD)

// Create test script
createTestScript('pynq_notebooks', "finn-examples_${env.BOARD}.xml")
createTestScript('pynq_notebooks', "finn-examples_${env.BOARD}")

// Execute the script as the root user - needed for zynq platforms
// Use an env variable to help collect test results later in pipeline
Expand All @@ -87,7 +87,7 @@ pipeline {
post {
always {
// Collect the results file on the slave node by stashing
stash name: "finn_examples_test_PynqZ1", includes: "finn-examples_${env.BOARD}.xml"
stash name: "finn_examples_test_PynqZ1", includes: "finn-examples_${env.BOARD}.xml,finn-examples_${env.BOARD}.html"
postCleanup()
}
failure {
Expand Down Expand Up @@ -119,7 +119,7 @@ pipeline {
getBoardFiles(env.BOARD)

// Create test script
createTestScript('ultra96_notebooks', "finn-examples_${env.BOARD}.xml")
createTestScript('ultra96_notebooks', "finn-examples_${env.BOARD}")

// Execute the script as the root user - needed for zynq platforms
// Use an env variable to help collect test results later in pipeline
Expand All @@ -131,7 +131,7 @@ pipeline {
post {
always {
// Collect the results file on the slave node by stashing
stash name: "finn_examples_test_${env.BOARD}", includes: "finn-examples_${env.BOARD}.xml"
stash name: "finn_examples_test_${env.BOARD}", includes: "finn-examples_${env.BOARD}.xml,finn-examples_${env.BOARD}.html"
postCleanup()
}
failure {
Expand Down Expand Up @@ -163,7 +163,7 @@ pipeline {
u250Workaround()

// Create test script
createTestScript('alveo_notebooks', "finn-examples_${env.BOARD}.xml")
createTestScript('alveo_notebooks', "finn-examples_${env.BOARD}")

// Execute the script as non-root user - root permissions not needed
// Use an env variable to help collect test results later in pipeline
Expand All @@ -175,7 +175,7 @@ pipeline {
post {
always {
// Collect the results file on the slave node by stashing
stash name: "finn_examples_test_${env.BOARD}", includes: "finn-examples_${env.BOARD}.xml"
stash name: "finn_examples_test_${env.BOARD}", includes: "finn-examples_${env.BOARD}.xml,finn-examples_${env.BOARD}.html"
postCleanup()
}
failure {
Expand Down Expand Up @@ -207,7 +207,7 @@ pipeline {
getBoardFiles(env.BOARD)

// Create test script
createTestScript('zcu_notebooks', "finn-examples_${env.BOARD}.xml")
createTestScript('zcu_notebooks', "finn-examples_${env.BOARD}")

// Execute the script as the root user - needed for zynq platforms
// Use an env variable to help collect test results later in pipeline
Expand All @@ -221,7 +221,7 @@ pipeline {
post {
always {
// Collect the results file on the slave node by stashing
stash name: "finn_examples_test_${env.BOARD}", includes: "finn-examples_${env.BOARD}.xml"
stash name: "finn_examples_test_${env.BOARD}", includes: "finn-examples_${env.BOARD}.xml,finn-examples_${env.BOARD}.html"
postCleanup()
}
failure {
Expand Down Expand Up @@ -253,17 +253,26 @@ pipeline {
always {
script {
// Delete previous build's XML test results
sh 'rm *.xml'
sh 'mkdir -p reports'
cleanPreviousBuildFiles('reports')

dir('reports') {
// Only unstash for stages that ran
unstashSuccessfulStage(env.TEST_PYNQ, "finn_examples_test_PynqZ1")
unstashSuccessfulStage(env.TEST_ULTRA96, "finn_examples_test_Ultra96")
unstashSuccessfulStage(env.TEST_U250, "finn_examples_test_U250")
unstashSuccessfulStage(env.TEST_ZCU104, "finn_examples_test_ZCU104")
}

// Combine individual HTML files to one single report
sh './run-docker.sh pytest_html_merger -i reports/ -o reports/test_report_final.html'

// Only unstash for stages that ran
unstashSuccessfulStage(env.TEST_PYNQ, "finn_examples_test_PynqZ1")
unstashSuccessfulStage(env.TEST_ULTRA96, "finn_examples_test_Ultra96")
unstashSuccessfulStage(env.TEST_U250, "finn_examples_test_U250")
unstashSuccessfulStage(env.TEST_ZCU104, "finn_examples_test_ZCU104")
// Archive the XML & HTML test results
archiveArtifacts artifacts: "reports/*.xml"
archiveArtifacts artifacts: "reports/*.html"

// Plot what XML files were created during the test run
archiveArtifacts artifacts: "*.xml"
junit '**/*.xml'
junit 'reports/*.xml'
}
}
}
Expand All @@ -290,6 +299,14 @@ void unstashSuccessfulStage(String stageEnvVariableSet, String stashName) {
}
}

void cleanPreviousBuildFiles(String buildDir) {
// Delete any build files from a previous build
// Previous build folders affect findCopyZip() and can cause the stage to fail
if (!buildDir.empty) {
sh "rm -rf ${buildDir}"
}
}

void cleanLocalCloneDir() {
// This removes previous run's test reports, bitstreams and test files
sh 'rm -f *.xml'
Expand Down Expand Up @@ -335,13 +352,13 @@ void createTestScript(String boardNotebooks, String testResultsFilename) {
sh """echo "#!/bin/bash
. /opt/xilinx/xrt/setup.sh
. ${VENV_ACTIVATE}
python -m pytest -m ${boardNotebooks} --junitxml=${testResultsFilename}" >> run-tests.sh
python -m pytest -m ${boardNotebooks} --junitxml=${testResultsFilename}.xml --html=${testResultsFilename}.html --self-contained-html" >> run-tests.sh
"""
else
sh """echo "#!/bin/bash
. /etc/profile.d/pynq_venv.sh
. /etc/profile.d/xrt_setup.sh
python -m pytest -m ${boardNotebooks} --junitxml=${testResultsFilename}" >> run-tests.sh
python -m pytest -m ${boardNotebooks} --junitxml=${testResultsFilename}.xml --html=${testResultsFilename}.html --self-contained-html" >> run-tests.sh
"""

// Give permissions to script
Expand Down

0 comments on commit 9132511

Please sign in to comment.