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 <simone.ballarin@bugseng.com>
Acked-by: Stefano Stabellini <sstabellini@kernel.org>
This commit is contained in:
Simone Ballarin authored and Stefano Stabellini committed 2023-08-03 18:17:13 -07:00
1 parent 4d687adc8c
commit 5499c75c21
1 file changed
+65 -19
@@ -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="<br/>"
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="<br/>"
eol="<br/>"
;;
*)
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="<a href="${referenceDbReportsUrl}">Browse ${reference_kind} reports</a>"
fi
cat <<EOF >"${summaryTxt}"
${countsMsg} ${nl}
${fixedMsg}${eol}
${unfixedMsg} ${eol}
<a href="https://www.bugseng.com/eclair">
<img src="${eclairReportUrlPrefix}/rsrc/eclair.svg" width="100" />
</a>
<h3>${jobHeadline}</h3>
<a href="${indexHtmlUrl}">Browse analysis results</a>
<a href="${indexHtmlUrl}">Browse analysis summary</a>
<a href="${currentDbReportsUrl}">Browse current reports</a>
${referenceReportsMsgTxt}
EOF
;;
*)
if [ -n "${newReports}" ]; then
referenceReportsMsgTxt="Browse ${reference_kind} reports: ${referenceDbReportsUrl}"
fi
cat <<EOF >"${summaryTxt}"
<a href="https://www.bugseng.com/eclair">
<img src="${eclairReportUrlPrefix}/rsrc/eclair.svg" width="100" />
</a>
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 <<EOF
${jobHeadline}
${countsMsg}
Browse analysis: ${esc}[33m${indexHtmlUrl}${esc}[m
${fixedMsg}
${unfixedMsg}
${analysisSummaryMsgLog}
${currentReportsMsgLog}
${referenceReportsMsgLog}
EOF
close_section ECLAIR_summary
;;
@@ -103,7 +147,9 @@ EOF
${jobHeadline}
${fixedMsg}
${unfixedMsg}
Browse analysis: ${indexHtmlUrl}
${analysisSummaryMsgLog}
${currentReportsMsgLog}
${referenceReportsMsgLog}
EOF
;;
*)
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.