feat!(report): generate JSON instead of markdown
This allows us to analyze the report more easily. There is experimental support for comparing against a base report, but we don't expose that functionality to the action.
This commit is contained in:
parent
3c231dbfef
commit
46291fc850
4 changed files with 171 additions and 76 deletions
20
compare.jq
Normal file
20
compare.jq
Normal file
|
@ -0,0 +1,20 @@
|
|||
# Calculate the change in percentage of a nummeric key
|
||||
#
|
||||
# Where .[0] is the new value, and .[1] is the old value
|
||||
def calc_change($key):
|
||||
. as $input | $input[1][$key] - $input[0][$key];
|
||||
|
||||
# Calculate the change in percentage for multiple keys
|
||||
#
|
||||
# Returns an array of {"key": $key, "value": change%}
|
||||
def keys_change_perc($keys):
|
||||
. as $input | $keys | map(. as $key | $input | {"key": $key, "value": . | calc_change($key)});
|
||||
|
||||
# For a set of keys, calculate the change percentage and return it as
|
||||
# "\($key)Change" = $value in the original object.
|
||||
def set_change_perc($keys):
|
||||
. as $input | reduce keys_change_perc($keys)[] as $change ($input[0]; .["\($change.key)Change"] = $change.value);
|
||||
|
||||
# Bring everything together
|
||||
reduce .[] as $x ({}; . as $acc | reduce ($x | keys[]) as $key ($acc; .[$key] |= . + $x[$key])) |
|
||||
map_values(group_by(.name) | map(set_change_perc(["size", "narSize"])))
|
Loading…
Add table
Add a link
Reference in a new issue