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
|
@ -19,52 +19,30 @@ configurations=$(
|
|||
echo "NixOS Configurations:" >&2
|
||||
echo "$configurations" >&2
|
||||
|
||||
package_size_table() {
|
||||
table='| Installable | NAR Size | Closure Size |
|
||||
|-------------|---------:|-------------:|
|
||||
'
|
||||
pkgs_json() {
|
||||
for package in $packages; do
|
||||
echo "Building $package" >&2
|
||||
path=$(nix build --print-out-paths ".#$package" 2>/dev/null)
|
||||
echo "Calculating size of $package" >&2
|
||||
row=$(nix path-info --size --closure-size --human-readable "$path" 2>/dev/null |
|
||||
sed "s/^\(\S\+\)\(\s\+\)\(\S\+\)\(\s\+\)\(\S\+\)$/| \`$package\` | \3 | \5 |/")
|
||||
table="$table$row
|
||||
"
|
||||
nix path-info --closure-size --json "$path" 2>/dev/null |
|
||||
jq --compact-output --arg pkg "$package" '.[] | {"name": $pkg, "size": .closureSize, "narSize": .narSize}'
|
||||
done
|
||||
|
||||
printf '%s' "$table"
|
||||
}
|
||||
|
||||
configuration_size_table() {
|
||||
table='| NixOS Configuration | NAR Size | Closure Size |
|
||||
|-------------|---------:|-------------:|
|
||||
'
|
||||
configs_json() {
|
||||
for config in $configurations; do
|
||||
echo "Building $config" >&2
|
||||
path=$(nix build --print-out-paths ".#nixosConfigurations.$config.config.system.build.toplevel" 2>/dev/null)
|
||||
echo "Calculating size of $config" >&2
|
||||
row=$(nix path-info --size --closure-size --human-readable "$path" 2>/dev/null |
|
||||
sed "s/^\(\S\+\)\(\s\+\)\(\S\+\)\(\s\+\)\(\S\+\)$/| \`$config\` | \3 | \5 |/")
|
||||
table="$table$row
|
||||
"
|
||||
nix path-info --closure-size --json "$path" 2>/dev/null |
|
||||
jq --compact-output --arg pkg "$config" '.[] | {"name": $pkg, "size": .closureSize, "narSize": .narSize}'
|
||||
done
|
||||
|
||||
printf '%s' "$table"
|
||||
}
|
||||
|
||||
markdown() {
|
||||
cat <<-EOF
|
||||
## Outputs' size
|
||||
pkgs=$(pkgs_json | jq --slurp '.')
|
||||
configs=$(configs_json | jq --slurp '.')
|
||||
|
||||
### NixOS Configurations sizes
|
||||
|
||||
$(configuration_size_table)
|
||||
|
||||
### Package sizes
|
||||
|
||||
$(package_size_table)
|
||||
EOF
|
||||
}
|
||||
|
||||
markdown >size-report.md
|
||||
echo "{}" | jq \
|
||||
--argjson pkgs "$pkgs" \
|
||||
--argjson configs "$configs" \
|
||||
'{"packages": $pkgs, "nixosConfigurations": $configs}'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue