Skip to content

Commit

Permalink
Add relevant metadata to the JSON output
Browse files Browse the repository at this point in the history
  • Loading branch information
oSoMoN committed Feb 13, 2024
1 parent 55bc85d commit 8d89a9e
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions run-upstream-testsuite.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/bash

scriptpath=$(dirname "$(readlink -f "$0")")
rev=$(git rev-parse HEAD)

# Allow passing a specific profile as parameter (default to "release")
profile="release"
Expand All @@ -25,6 +26,7 @@ git clone -n --depth=1 --filter=tree:0 "$testsuite" &> /dev/null
cd diffutils
git sparse-checkout set --no-cone tests &> /dev/null
git checkout &> /dev/null
upstreamrev=$(git rev-parse HEAD)

# Ensure that calling `diff` invokes the built `diffutils` binary instead of
# the upstream `diff` binary that is most likely installed on the system
Expand All @@ -45,7 +47,7 @@ echo "Running $(echo "$tests" | wc -w) tests"
export LC_ALL=C
export KEEP=yes
exitcode=0
json=""
timestamp=$(date -Iseconds)
for test in $tests
do
result="FAIL"
Expand Down Expand Up @@ -75,7 +77,16 @@ do
[[ "$result" = "SKIP" ]] && color=3 # yellow
printf " %-40s $(tput setaf $color)$result$(tput sgr0)\n" "$test"
done
json="[${json%,}]"
json="\"tests\":[${json%,}]"

metadata="\"timestamp\":\"$(date -Iseconds)\","
metadata+="\"revision\":\"$rev\","
metadata+="\"upstream-revision\":\"$upstreamrev\","
if [[ -n "$GITHUB_ACTIONS" ]]
then
metadata+="\"branch\":\"$GITHUB_REF\","
fi
json="{$metadata $json}"

# Clean up
cd "$scriptpath"
Expand Down

0 comments on commit 8d89a9e

Please sign in to comment.