From 4d4e923f8f0e3e0ac8c7cc95cf014041cbaef3a8 Mon Sep 17 00:00:00 2001 From: Pedro Alvarez Date: Tue, 23 Jun 2015 16:20:45 +0000 Subject: mason: Improve mason-report.sh to give more feedback when building. It will now show a row when a build has started, with a link to the current build log. Change-Id: Iec01529a80b45b2a61a6cf454a0ac8300c73e139 --- extensions/mason/mason-report.sh | 51 +++++++++++++++++++++++++++++++++++----- 1 file changed, 45 insertions(+), 6 deletions(-) diff --git a/extensions/mason/mason-report.sh b/extensions/mason/mason-report.sh index 9c20b65b..31745b93 100755 --- a/extensions/mason/mason-report.sh +++ b/extensions/mason/mason-report.sh @@ -6,6 +6,7 @@ set -x REPORT_PATH=/var/mason/report.html SERVER_PATH=/srv/mason +SERVER_REPORT_PATH="$SERVER_PATH/index.html" sed_escape() { printf "%s\n" "$1" | sed -e 's/\W/\\&/g' @@ -63,6 +64,12 @@ table tr.nonet { table tr.nonet:hover { background: #ffeeaa; } +table tr.progress { + background: #00CCFF; +} +table tr.progress:hover { + background: #91E9FF; +} table tr.headings th { font-weight: bold; text-align: left; @@ -99,6 +106,12 @@ tr.nonet td.result a { tr.nonet td.result a:hover { color: #962; } +tr.progress td.result a { + color: #000066; +} +tr.progress td.result a:hover { + color: #0000CC; +} td.ref { font-family: monospace; } @@ -177,6 +190,8 @@ update_report() { build_sha1="$4" build_duration="$5" build_result="$6" + report_path="$7" + build_log="$8" # Generate template if report file is not there if [ ! -f $REPORT_PATH ]; then @@ -185,13 +200,13 @@ update_report() { # Build table row for insertion into report file if [ "$build_result" = nonet ]; then - msg=''"${build_start_time}"'Failed to contact '"${build_trove_host}"''"${build_duration}s"''"${build_result}"'' + msg=''"${build_start_time}"'Failed to contact '"${build_trove_host}"''"${build_duration}s"''"${build_result}"'' else - msg=''"${build_start_time}"''"${build_sha1}"''"${build_duration}s"''"${build_result}"'' + msg=''"${build_start_time}"''"${build_sha1}"''"${build_duration}s"''"${build_result}"'' fi # Insert report line, newest at top - sed -i 's//\n'"$(sed_escape "$msg")"'/' $REPORT_PATH + sed -i 's//\n'"$(sed_escape "$msg")"'/' $report_path } update_report_time() { @@ -210,6 +225,23 @@ update_report_time "$START_TIME" cp "$REPORT_PATH" "$SERVER_PATH/index.html" logfile="$(mktemp)" + +#Update current.log symlink to point to the current build log +ln -sf "$logfile" "$SERVER_PATH"/current.log + +#Copy current server report, to restore when result is "skip" +cp "$SERVER_REPORT_PATH" "$SERVER_REPORT_PATH".bak + +update_report "$START_TIME" \ + "$UPSTREAM_TROVE_ADDRESS" \ + "$DEFINITIONS_REF" \ + "" \ + " - " \ + "progress" \ + "$SERVER_REPORT_PATH" \ + "current.log" + + /usr/lib/mason/mason.sh 2>&1 | tee "$logfile" case "${PIPESTATUS[0]}" in 0) @@ -228,25 +260,32 @@ esac # TODO: Update page with last executed time if [ "$RESULT" = skip ]; then + # Restore copied server report, otherwise the 'progress' row will + # be still present with a broken link after we remove the $logfile + mv "$SERVER_REPORT_PATH".bak "$SERVER_REPORT_PATH" + rm "$logfile" exit 0 fi DURATION=$(( $(date +%s) - $(date --date="$START_TIME" +%s) )) SHA1="$(cd "ws/$DEFINITIONS_REF/$UPSTREAM_TROVE_ADDRESS/baserock/baserock/definitions" && git rev-parse HEAD)" +BUILD_LOG="log/${SHA1}--${START_TIME}.log" update_report "$START_TIME" \ "$UPSTREAM_TROVE_ADDRESS" \ "$DEFINITIONS_REF" \ "$SHA1" \ "$DURATION" \ - "$RESULT" + "$RESULT" \ + "$REPORT_PATH" \ + "$BUILD_LOG" # # Copy report into server directory # -cp "$REPORT_PATH" "$SERVER_PATH/index.html" +cp "$REPORT_PATH" "$SERVER_REPORT_PATH" mkdir "$SERVER_PATH/log" -mv "$logfile" "$SERVER_PATH/log/$SHA1--$START_TIME.log" +mv "$logfile" "$SERVER_PATH/$BUILD_LOG" -- cgit v1.2.1