File: shields-from-tests.jq

package info (click to toggle)
rust-cursive-tabs 0.8.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 544 kB
  • sloc: sh: 89; makefile: 2
file content (27 lines) | stat: -rw-r--r-- 801 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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
}