Add jq script for CI

This commit is contained in:
Fin Christensen 2019-08-20 15:24:50 +02:00
parent de45635057
commit 702cc56cdb
No known key found for this signature in database
GPG Key ID: 1C295651D0424BF1

View File

@ -0,0 +1,27 @@
{
# filter for "passed" and "test_count" in input objects with `"type": "suite"`
# and accumulate stats from all tests
"passed": map(select(.type == "suite" and has("passed")) | .passed) | add,
"total": map(select(.type == "suite" and has("test_count")) | .test_count) | add
} | . + {
# calculate ratio of passed tests
"factor": (.passed / .total)
} | {
# calculate color from test factor
"color": (
if .factor < 0.33 then
"red"
elif .factor < 0.66 then
"orange"
elif .factor < 1.0 then
"yellow"
else
"brightgreen"
end
),
"isError": true,
"label": "cargo test",
# interpolate the shield label
"message": "\(.passed) / \(.total) tests",
"schemaVersion": 1
}