Skip to content

Commit 39fab64

Browse files
committed
ci : Print test summary in tabular format
Print Lava Test summary for targets in tabular format Signed-off-by: Salendarsingh Gaud <sgaud@qti.qualcomm.com>
1 parent 72ec607 commit 39fab64

File tree

1 file changed

+66
-44
lines changed

1 file changed

+66
-44
lines changed

.github/workflows/comment.yml

Lines changed: 66 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -75,52 +75,74 @@ jobs:
7575

7676
- name: Parse json files
7777
run: |
78-
set -euo pipefail
79-
GLOB="all-json/*.json"
80-
81-
shopt -s nullglob
82-
files=( $GLOB )
83-
84-
if [ ${#files[@]} -eq 0 ]; then
85-
echo "No files matched: ${GLOB}" >&2
86-
exit 1
87-
fi
88-
89-
# Start a new Markdown summary
90-
SUMMARY_FILE="summary.md"
91-
: > "$SUMMARY_FILE"
92-
93-
for f in "${files[@]}"; do
94-
base="$(basename "$f")"
95-
target="${base%.*}" # filename without extension, e.g., rb3gen2-corekit.json -> rb3gen2-corekit
96-
97-
# Fail if JSON invalid
98-
jq empty "$f" >/dev/null
99-
100-
total=$(jq 'length' "$f")
101-
pass=$(jq '[ .[] | select(.result=="pass") ] | length' "$f")
102-
fail=$(jq '[ .[] | select(.result=="fail") ] | length' "$f")
103-
error=$(jq '[ .[] | select(.result=="error") ] | length' "$f")
104-
skip=$(jq '[ .[] | select(.result=="skip" or .result=="skipped") ] | length' "$f")
105-
106-
# Collect failing test names (if any)
107-
mapfile -t fail_names < <(jq -r '[ .[] | select(.result=="fail") | .name ] | .[]?' "$f")
108-
109-
{
110-
echo "## ${target}"
111-
echo "- Total: ${total} (✅ ${pass}, ❌ ${fail}, ⛔ ${error}, ⚠️ ${skip})"
112-
if (( fail > 0 )); then
113-
echo " - Failures:"
114-
for n in "${fail_names[@]}"; do
115-
[ -n "$n" ] && echo " - ${n}"
116-
done
117-
fi
118-
echo
119-
} >> "$SUMMARY_FILE"
78+
#!/usr/bin/env bash
79+
set -e
80+
81+
INPUT_DIR="all-json/"
82+
OUTPUT="summary.md"
83+
84+
# Collect file list
85+
FILES=("$INPUT_DIR"/*.json)
86+
87+
# Extract target names (filenames without .json)
88+
TARGETS=()
89+
for f in "${FILES[@]}"; do
90+
base=$(basename "$f" .json)
91+
TARGETS+=("$base")
92+
done
93+
94+
# Build list of ALL test names
95+
TESTS=$(grep -ho '"name"[ ]*:[ ]*"[^"]*"' "$INPUT_DIR"/*.json \
96+
| sed 's/.*"name"[ ]*:[ ]*"//' | sed 's/"$//' \
97+
| sort -u)
98+
99+
# Start table
100+
echo "# Test Matrix" > "$OUTPUT"
101+
echo "" >> "$OUTPUT"
102+
103+
# Header
104+
printf "| Test Case " >> "$OUTPUT"
105+
for t in "${TARGETS[@]}"; do
106+
target_name="${t#Tests-}"
107+
printf "| %s " "$target_name" >> "$OUTPUT"
108+
done
109+
printf " | \n" >> "$OUTPUT"
110+
111+
# Separator
112+
printf "| --- " >> "$OUTPUT"
113+
for _ in "${TARGETS[@]}"; do
114+
printf "| ---- " >> "$OUTPUT"
115+
done
116+
printf "|\n" >> "$OUTPUT"
117+
118+
# Build rows
119+
for test in $TESTS; do
120+
printf "| %s " "$test" >> "$OUTPUT"
121+
122+
for t in "${TARGETS[@]}"; do
123+
file="$INPUT_DIR/$t.json"
124+
# Extract the result for this test
125+
res=$(grep -A1 "\"name\" *: *\"$test\"" "$file" 2>/dev/null \
126+
| grep '"result"' \
127+
| sed 's/.*"result"[ ]*:[ ]*"//' | sed 's/"$//' \
128+
|| true)
129+
echo "Salendar : $res"
130+
case "$res" in
131+
pass) cell="✅ Pass" ;;
132+
fail) cell="❌ Fail" ;;
133+
skip) cell="⚠️ skip" ;;
134+
error) cell="⛔ Error" ;;
135+
*) cell="◻️" ;; # missing
136+
esac
137+
138+
printf "| %s " "$cell" >> "$OUTPUT"
139+
done
140+
141+
printf "|\n" >> "$OUTPUT"
120142
done
121143
122-
echo "Wrote Markdown summary to: $SUMMARY_FILE"
123-
sed -n '1,120p' "$SUMMARY_FILE"
144+
echo ""
145+
echo "[OK] Generated table: $OUTPUT"
124146
125147
- name: Post results to PR
126148
run: |

0 commit comments

Comments
 (0)