From 5499c75c21a7f5fd2832c0107ab8b5936fc2b466 Mon Sep 17 00:00:00 2001 From: Simone Ballarin Date: Tue, 1 Aug 2023 11:57:02 +0200 Subject: [PATCH] automation/eclair: add direct link to reports This patch adds direct links to the analysis findings in the console log. Signed-off-by: Simone Ballarin Acked-by: Stefano Stabellini --- .../eclair_analysis/ECLAIR/action.helpers | 84 ++++++++++++++----- 1 file changed, 65 insertions(+), 19 deletions(-) diff --git a/automation/eclair_analysis/ECLAIR/action.helpers b/automation/eclair_analysis/ECLAIR/action.helpers index 2ad6428eaa..df9bf2bd11 100644 --- a/automation/eclair_analysis/ECLAIR/action.helpers +++ b/automation/eclair_analysis/ECLAIR/action.helpers @@ -1,17 +1,26 @@ +esc=$(printf '\e') +cr=$(printf '\r') + if [ -n "${GITLAB_CI:-}" ]; then ci=gitlab + eol= + link_start="${esc}[33m" + link_end="${esc}[m" elif [ -n "${GITHUB_ACTION:-}" ]; then ci=github + eol="\\" + link_start= + link_end= elif [ -n "${JENKINS_HOME:-}" ]; then ci=jenkins + eol="
" + link_start= + link_end= else echo "Unexpected CI/CD context" >&2 exit 1 fi -esc=$(printf '\e') -cr=$(printf '\r') - open_section() { id=$1 title=$2 @@ -36,54 +45,86 @@ summary() { case "${ci}" in github) - nl="\\" + eol="\\" ;; gitlab) - nl= + eol= ;; jenkins) - nl="
" + eol="
" ;; *) - nl= + eol= ;; esac + currentDbReportsUrl="${eclairReportUrlPrefix}/fs${jobDir}/PROJECT.ecd;/by_service.html#service&kind" if [ -z "${newReports}" ]; then - fixedMsg= + fixedMsg="No fixed reports as there is no baseline" unfixedMsg="Unfixed reports: ${unfixedReports}" - countsMsg="${unfixedMsg}" + referenceReportsMsgTxt= + referenceReportsMsgLog= else fixedMsg="Fixed reports: ${fixedReports}" unfixedMsg="Unfixed reports: ${unfixedReports} [new: ${newReports}]" - countsMsg="${fixedMsg}${nl} -${unfixedMsg}" + case "${event}" in + pull_request | auto_pull_request) + referenceDbReportsUrl="${eclairReportUrlPrefix}/fs${jobDir}/base/PROJECT.ecd;/by_service.html#service&kind" + reference_kind=base + ;; + push) + referenceDbReportsUrl="${eclairReportUrlPrefix}/fs${jobDir}/prev/PROJECT.ecd;/by_service.html#service&kind" + reference_kind=previous + ;; + *) + echo "Unexpected event ${event}" >&2 + exit 1 + ;; + esac fi + case "${ci}" in jenkins) + if [ -n "${newReports}" ]; then + referenceReportsMsgTxt="Browse ${reference_kind} reports" + fi cat <"${summaryTxt}" -${countsMsg} ${nl} +${fixedMsg}${eol} +${unfixedMsg} ${eol}

${jobHeadline}

-Browse analysis results +Browse analysis summary +Browse current reports +${referenceReportsMsgTxt} EOF ;; *) + if [ -n "${newReports}" ]; then + referenceReportsMsgTxt="Browse ${reference_kind} reports: ${referenceDbReportsUrl}" + fi cat <"${summaryTxt}" Analysis Summary -${jobHeadline}${nl} -${countsMsg}${nl} -[Browse analysis](${indexHtmlUrl}) +${jobHeadline}${eol} +${fixedMsg}${eol} +${unfixedMsg}${eol} +Browse analysis summary: ${indexHtmlUrl} +Browse current reports: ${currentDbReportsUrl} +${referenceReportsMsgTxt} EOF ;; esac + analysisSummaryMsgLog="Browse analysis summary: ${link_start}${indexHtmlUrl}${link_end}" + currentReportsMsgLog="Browse current reports: ${link_start}${currentDbReportsUrl}${link_end}" + if [ -n "${newReports}" ]; then + referenceReportsMsgLog="Browse ${reference_kind} reports: ${link_start}${referenceDbReportsUrl}${link_end}" + fi case ${ci} in github) cat "${summaryTxt}" >"${GITHUB_STEP_SUMMARY}" @@ -93,8 +134,11 @@ EOF # Generate summary and print it (GitLab-specific) cat <