Adding code to output pytest warnings. (#22570)

* Added pytest-json-report plugin
	- modifying app-opts in setup.cfg
	- adding hook to all conftest.py files in repo
	- setting report to be saved to test_root/log/warnings.json
	- Writing custom logic to save json report to avoid overwrite if pytest called twice
This was created to allow us to easily parse through test warnings in jenkins
This commit is contained in:
Manjinder Singh
2020-01-02 10:01:52 -05:00
committed by GitHub
parent f4bb9b4b8e
commit 6c69b6d435
19 changed files with 488 additions and 20 deletions

View File

@@ -8,18 +8,31 @@ def runPythonTests() {
noTags: true, shallow: true]], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'jenkins-worker',
refspec: git_refspec, url: "git@github.com:edx/${REPO_NAME}.git"]]]
sh 'bash scripts/all-tests.sh'
stash includes: 'reports/**/*coverage*', name: "${TEST_SUITE}-reports"
stash includes: 'reports/**/*coverage*,test_root/log/*.json', name: "${TEST_SUITE}-reports"
}
}
def pythonTestCleanup() {
archiveArtifacts allowEmptyArchive: true, artifacts: 'reports/**/*,test_root/log/**/*.log,**/nosetests.xml,*.log'
archiveArtifacts allowEmptyArchive: true, artifacts: 'reports/**/*,test_root/log/**/*.log,test_root/log/*.json,**/nosetests.xml,*.log'
sendSplunkFile excludes: '', includes: '**/timing*.log', sizeLimit: '10MB'
junit '**/nosetests.xml'
sh '''source $HOME/edx-venv-$PYTHON_VERSION/edx-venv/bin/activate
bash scripts/xdist/terminate_xdist_nodes.sh'''
}
def createWarningsReport(fileExtension){
println "Creating warnings report for ${fileExtension}"
warning_filename = "warning_report_${fileExtension}.html"
sh """source $HOME/edx-venv-$PYTHON_VERSION/edx-venv/bin/activate
python openedx/core/process_warnings.py --dir-path test_root/log --html-path reports/pytest_warnings/${warning_filename}"""
publishHTML([allowMissing: false, alwaysLinkToLastBuild: false, keepAll: true,
reportDir: 'reports/pytest_warnings', reportFiles: "${warning_filename}",
reportName: "${warning_filename}", reportTitles: ''])
archiveArtifacts allowEmptyArchive: true, artifacts: 'reports/pytest_warnings/*.html'
}
def xdist_git_branch() {
if (env.ghprbActualCommit) {
return "${ghprbActualCommit}"
@@ -142,6 +155,8 @@ pipeline {
}
}
}
stage('Run coverage') {
environment {
CODE_COV_TOKEN = credentials('CODE_COV_TOKEN')
@@ -172,6 +187,7 @@ pipeline {
sh """export CI_BRANCH=$ci_branch
export TARGET_BRANCH=$target_branch
./scripts/jenkins-report.sh"""
createWarningsReport("all")
}
}
}