1
0
Fork 0

Add reason of failure on top of summary

This commit is contained in:
Mikhail Goncharov 2020-02-07 12:22:37 +01:00
parent 41581c95be
commit 6b6558e22c
2 changed files with 31 additions and 3 deletions

View file

@ -13,6 +13,7 @@
// limitations under the License. // limitations under the License.
def success = true def success = true
def failure_message = ""
pipeline { pipeline {
agent { label 'linux' } agent { label 'linux' }
@ -72,15 +73,23 @@ pipeline {
} }
stage('arc patch'){ stage('arc patch'){
steps { steps {
success = false
failure_message = "Failed to apply patch"
sh "${SCRIPT_DIR}/phabtalk/apply_patch2.py ${DIFF_ID} --token ${CONDUIT_TOKEN} --url ${PHABRICATOR_HOST} --comment-file ${PHAB_LOG}" sh "${SCRIPT_DIR}/phabtalk/apply_patch2.py ${DIFF_ID} --token ${CONDUIT_TOKEN} --url ${PHABRICATOR_HOST} --comment-file ${PHAB_LOG}"
success = true
failure_message = ""
} }
} }
stage('CMake') { stage('CMake') {
steps { steps {
success = false
failure_message = "Failed to run cmake"
sh 'rm -rf build || true' sh 'rm -rf build || true'
sh 'mkdir -p build' sh 'mkdir -p build'
sh 'mkdir -p "${TARGET_DIR}"' sh 'mkdir -p "${TARGET_DIR}"'
sh "${SCRIPT_DIR}/run_cmake.sh" sh "${SCRIPT_DIR}/run_cmake.sh"
success = true
failure_message = ""
} }
} }
stage('ninja all') { stage('ninja all') {
@ -90,6 +99,7 @@ pipeline {
sh(script: "${SCRIPT_DIR}/run_ninja.sh all") sh(script: "${SCRIPT_DIR}/run_ninja.sh all")
} catch (e) { } catch (e) {
success = false; success = false;
failure_message = "'ninja all' failed" // append as build might already be broken
echo e.toString() echo e.toString()
} }
} }
@ -116,6 +126,7 @@ pipeline {
sh(script: "${SCRIPT_DIR}/run_ninja.sh check-all") sh(script: "${SCRIPT_DIR}/run_ninja.sh check-all")
} catch (e) { } catch (e) {
success = false; success = false;
failure_message += "\n'ninja check-all' failed" // append as build might already be broken
echo e.toString() echo e.toString()
} }
} }
@ -123,7 +134,15 @@ pipeline {
} }
stage('linters') { stage('linters') {
steps { steps {
sh "${SCRIPT_DIR}/lint.sh" script {
try {
sh(script: "${SCRIPT_DIR}/lint.sh")
} catch (e) {
success = false;
failure_message += "\nFailed to run linters" // append as build might already be broken
echo e.toString()
}
}
} }
} }
} }
@ -160,7 +179,8 @@ pipeline {
--clang-tidy-result "clang-tidy.txt" \ --clang-tidy-result "clang-tidy.txt" \
--clang-tidy-ignore "${SCRIPT_DIR}/clang-tidy-comments.ignore" \ --clang-tidy-ignore "${SCRIPT_DIR}/clang-tidy-comments.ignore" \
--results-dir "${TARGET_DIR}" \ --results-dir "${TARGET_DIR}" \
--results-url "${RESULT_URL}" --results-url "${RESULT_URL}" \
--failures "${failure_message}"
""" """
} }
} }

View file

@ -191,6 +191,7 @@ class BuildReport:
self.results_dir = args.results_dir # type: str self.results_dir = args.results_dir # type: str
self.results_url = args.results_url # type: str self.results_url = args.results_url # type: str
self.workspace = args.workspace # type: str self.workspace = args.workspace # type: str
self.failure_messages = args.failures # type: str
self.api = PhabTalk(args.conduit_token, args.host, args.dryrun) self.api = PhabTalk(args.conduit_token, args.host, args.dryrun)
@ -237,7 +238,13 @@ class BuildReport:
'=&title=enable%20checks%20for%20{{PATH}}">enable it for your project</a>'.format( '=&title=enable%20checks%20for%20{{PATH}}">enable it for your project</a>'.format(
urllib.parse.quote(title))) urllib.parse.quote(title)))
with open(os.path.join(self.results_dir, 'summary.html'), 'w') as f: with open(os.path.join(self.results_dir, 'summary.html'), 'w') as f:
f.write('<html><head><style>body { font-family: monospace; margin: 16px; }</style></head><body>') f.write('<html><head><style>'
'body { font-family: monospace; margin: 16px; }\n'
'.failure {color:red;}'
'</style></head><body>')
if self.failure_messages and len(self.failure_messages) > 0:
for s in self.failure_messages.split('\n'):
f.write('<p class="failure">{}</p>'.format(s))
f.write('<p>' + '</p><p>'.join(self.comments) + '</p>') f.write('<p>' + '</p><p>'.join(self.comments) + '</p>')
f.write('</body></html>') f.write('</body></html>')
self.api.add_artifact(self.ph_id, 'summary.html', 'summary', self.results_url) self.api.add_artifact(self.ph_id, 'summary.html', 'summary', self.results_url)
@ -456,6 +463,7 @@ def main():
dest='results_url', dest='results_url',
help="public URL to access results directory") help="public URL to access results directory")
parser.add_argument('--workspace', type=str, required=True, help="path to workspace") parser.add_argument('--workspace', type=str, required=True, help="path to workspace")
parser.add_argument('--failures', type=str, default=None, help="optional failure messages separated by newline")
args = parser.parse_args() args = parser.parse_args()
reporter = BuildReport(args) reporter = BuildReport(args)