From 7446e0ba1e11310eb46cc7b472c183de37841ab8 Mon Sep 17 00:00:00 2001 From: Yegor Bugayenko Date: Tue, 23 Jul 2024 05:37:16 +0300 Subject: [PATCH] #61 -index.html --- Makefile | 9 +++++++++ action.yml | 6 ++++++ entry.sh | 11 ++++++++--- judges/normalize-qos-metrics/normalize-all.yml | 5 ++++- judges/normalize-qos-metrics/normalize-qos-metrics.rb | 11 ++++++++++- 5 files changed, 37 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index d58486f..3554396 100644 --- a/Makefile +++ b/Makefile @@ -48,6 +48,8 @@ target/html/%.html: target/fb/%.fb xsl/*.xsl entry.sh Makefile target/css/main.c export INPUT_OPTIONS=testing=yes export GITHUB_WORKSPACE=. export INPUT_FACTBASE=$< + export INPUT_COLUMNS=what,when,who + export INPUT_HIDDEN=_id,_time,_version fb=$$(basename $<) fb=$${fb%.*} export INPUT_OUTPUT=target/output/$${fb} @@ -87,6 +89,8 @@ entry: target/docker-image.txt target/fb/simple.fb -e INPUT_FACTBASE=simple.fb \ -e INPUT_VERBOSE=true \ -e INPUT_OUTPUT=pages \ + -e INPUT_COLUMNS=what,when,who \ + -e INPUT_HIDDEN=_id \ "$${img}" echo "$$?" > target/entry.exit @@ -98,6 +102,11 @@ rmi: target/docker-image.txt verify: e2=$$(cat target/entry.exit) test "$${e2}" = "0" + test -e target/fb/pages/simple-index.html + test -e target/fb/pages/simple.html + test -e target/fb/pages/simple.xml + test -e target/fb/pages/simple.json + test -e target/fb/pages/simple.yaml target/docker-image.txt: Makefile Dockerfile entry.sh mkdir -p "$$(dirname $@)" diff --git a/action.yml b/action.yml index cbe37a0..599ff71 100644 --- a/action.yml +++ b/action.yml @@ -42,3 +42,9 @@ inputs: logo: description: 'URL of the logo to put on the HTML page' default: 'https://www.zerocracy.com/svg/logo.svg' + columns: + description: 'Comma-separated list of columns to print in the HTML' + default: 'when,what,who,repository,issue,details' + hidden: + description: 'Comma-separated list of properties to hide' + default: '_id,_time,_version' diff --git a/entry.sh b/entry.sh index b178abc..8fc6a0a 100755 --- a/entry.sh +++ b/entry.sh @@ -62,8 +62,13 @@ mkdir -p "${INPUT_OUTPUT}" name=$(basename "${INPUT_FACTBASE}") name="${name%.*}" -for f in yaml xml json; do - "${JUDGES}" "${gopts[@]}" print --format "${f}" "${INPUT_FACTBASE}" "${INPUT_OUTPUT}/${name}.${f}" +for f in yaml xml json html; do + "${JUDGES}" "${gopts[@]}" print \ + --format "${f}" \ + --columns "${INPUT_COLUMNS}" \ + --hidden "${INPUT_HIDDEN}" \ + "${INPUT_FACTBASE}" \ + "${INPUT_OUTPUT}/${name}.${f}" done declare -a options=() @@ -84,7 +89,7 @@ done <<< "${INPUT_OPTIONS}" # Build a summary HTML. css=$(cat "${SELF}/target/css/main.css") js=$(cat "${SELF}/target/js/main.js") -html=${INPUT_OUTPUT}/${name}.html +html=${INPUT_OUTPUT}/${name}-index.html java -jar "${SELF}/target/saxon.jar" \ "-s:${INPUT_OUTPUT}/${name}.rich.xml" \ "-xsl:${SELF}/target/xsl/index.xsl" \ diff --git a/judges/normalize-qos-metrics/normalize-all.yml b/judges/normalize-qos-metrics/normalize-all.yml index 43d8491..0016a07 100644 --- a/judges/normalize-qos-metrics/normalize-all.yml +++ b/judges/normalize-qos-metrics/normalize-all.yml @@ -23,6 +23,9 @@ options: testing: true input: + - + when: 2024-05-16T22:22:22.8492Z + what: quality-of-service - when: 2024-05-17T22:22:22.8492Z what: quality-of-service @@ -42,6 +45,6 @@ input: average_release_interval: 40432.42 average_workflow_success_rate: 0.67 expected: - - /fb[count(f)=3] + - /fb[count(f)=4] - /fb/f[n_average_issue_lifetime] - /fb/f[n_average_release_interval] diff --git a/judges/normalize-qos-metrics/normalize-qos-metrics.rb b/judges/normalize-qos-metrics/normalize-qos-metrics.rb index dce68bb..d20f4bb 100644 --- a/judges/normalize-qos-metrics/normalize-qos-metrics.rb +++ b/judges/normalize-qos-metrics/normalize-qos-metrics.rb @@ -36,11 +36,20 @@ start[prop] = first[prop][0] end +facts.drop(1).each do |f| + f.all_properties.each do |prop| + next unless prop.match?(/^[a-z]+_[a-z]+.*$/) + v = f[prop][0] + start[prop] = v if start[prop].nil? + end +end + facts.each do |f| f.all_properties.each do |prop| next unless prop.match?(/^[a-z]+_[a-z]+.*$/) v = f[prop][0] - diff = v - start[prop] + s = start[prop] + diff = v - s diff /= start[prop] unless start[prop].zero? f.send("n_#{prop}=", diff) end