Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
gitpod-io
GitHub Repository: gitpod-io/gitpod
Path: blob/main/test/report.sh
2486 views
1
#!/usr/bin/env bash
2
# Convenience script to create the Quality Assurance Report
3
#
4
# Usage:
5
#
6
# report.sh [input.json]
7
#
8
# Examples
9
#
10
# run.sh result.json
11
#
12
13
set -euo pipefail
14
15
input_file=${1}
16
17
d=$(date "+%Y%m%d-%H%M%S")
18
tempdir=$(mktemp -d /tmp/report-"$d".XXXXX)
19
20
exec {base}< <( \
21
jq -r 'select( .Action | test("(pass|fail|skip)") ) | select( .Elapsed | . != 0) | select( .Test | . != null) | [.Package,.Test,.Action]|@csv' "$input_file" | \
22
sed 's/github.com\/gitpod-io\/gitpod\/test\/tests\///' > "$tempdir"/base.csv
23
)
24
25
jq -r 'select( .Action | test("(pass|fail|skip)") ) | select( .Elapsed | . != 0) | select( .Test | . != null).Test' "$input_file" > "$tempdir"/list.txt
26
27
exec {feature}< <( \
28
while read -r test_name; do
29
jq -r -s --arg name "$test_name" 'map(select( . | .Test == $name) | select( . | .Output != null ) | select( .Output | startswith("===") | not) | select( .Output | contains("---") | not) | .Output | gsub("[\\n\\t]"; ""))[0]' "$input_file"
30
done < "$tempdir"/list.txt | sed 's/^[ \t]*//' | sed 's/,/ /g' | cut -d ':' -f 3 > "$tempdir"/features.txt
31
)
32
33
exec {desc}< <( \
34
while read -r test_name; do
35
jq -r -s --arg name "$test_name" 'map(select( . | .Test == $name) | select( . | .Output != null ) | select( .Output | startswith("===") | not) | select( .Output | contains("---") | not) | .Output | gsub("[\\n\\t]"; ""))[1]' "$input_file"
36
done < "$tempdir"/list.txt | sed 's/^[ \t]*//' | sed 's/,/ /g' | cut -d ':' -f 3 > "$tempdir"/desc.txt
37
)
38
39
cat <&${base}
40
cat <&${feature}
41
cat <&${desc}
42
43
paste "$tempdir"/features.txt "$tempdir"/base.csv "$tempdir"/desc.txt -d ',' | \
44
awk -F"," 'OFS="," {print $3,$1,$2,$4,$5}' | \
45
sed "/null/d" |\
46
sed '1iname,feature,component,status,desc'
47
48