ci.eval.compare: use argument parsing instead of environment variables to pass before/after to cmp-stats.py

This commit is contained in:
Philip Taron
2025-09-17 14:04:27 -07:00
parent 2fe7b1cec2
commit 241bb94b64
2 changed files with 10 additions and 12 deletions
+9 -7
View File
@@ -1,3 +1,4 @@
import argparse
import json
import numpy as np
import os
@@ -140,15 +141,16 @@ def perform_pairwise_tests(before_metrics: dict, after_metrics: dict) -> pd.Data
def main():
before_dir = os.environ.get("BEFORE_DIR")
after_dir = os.environ.get("AFTER_DIR")
parser = argparse.ArgumentParser(
description="Performance comparison of Nix evaluation statistics"
)
parser.add_argument("before", help="directory containing baseline (data before)")
parser.add_argument("after", help="directory containing comparison (data after)")
if not before_dir or not after_dir:
print("Error: Environment variables 'BEFORE_DIR' and 'AFTER_DIR' must be set.")
exit(1)
options = parser.parse_args()
before_stats = Path(before_dir) / "stats"
after_stats = Path(after_dir) / "stats"
before_stats = Path(options.before)
after_stats = Path(options.after)
# This may happen if the pull request target does not include PR#399720 yet.
if not before_stats.exists():
+1 -5
View File
@@ -182,10 +182,6 @@ runCommand "compare"
];
maintainers = builtins.toJSON maintainers;
passAsFile = [ "maintainers" ];
env = {
BEFORE_DIR = "${combined}/before";
AFTER_DIR = "${combined}/after";
};
}
''
mkdir $out
@@ -212,7 +208,7 @@ runCommand "compare"
echo
} >> $out/step-summary.md
cmp-stats >> $out/step-summary.md
cmp-stats ${combined}/before/stats ${combined}/after/stats >> $out/step-summary.md
else
# Package chunks are the same in both revisions