mirror of
https://github.com/micropython/micropython.git
synced 2025-12-15 17:30:14 +01:00
tools/metrics.py: Tersely show the commits in the size report.
This will show a line for both the reference and comparison, e.g.,
Reference: zephyr/boards: Add PocketBeagle 2 rev A1… [00a926e99e]
Comparison: metrics: Tersely show the commi… [merge of c7ac411e22]
When the comparison is a merge commit (as it is during CI) the second
parent of that commit is shown instead.
This will be helpful when checking which revision of the code size report
comment on a PR corresponds to which revision of the code.
Signed-off-by: Jeff Epler <jepler@unpythonic.net>
This commit is contained in:
committed by
Damien George
parent
2af0c52a91
commit
3bea897073
13
tools/ci.sh
13
tools/ci.sh
@@ -80,6 +80,10 @@ function ci_code_size_setup {
|
||||
ci_picotool_setup
|
||||
}
|
||||
|
||||
function _ci_is_git_merge {
|
||||
[[ $(git log -1 --format=%P "$1" | wc -w) > 1 ]]
|
||||
}
|
||||
|
||||
function ci_code_size_build {
|
||||
# check the following ports for the change in their code size
|
||||
# Override the list by setting PORTS_TO_CHECK in the environment before invoking ci.
|
||||
@@ -112,21 +116,26 @@ function ci_code_size_build {
|
||||
OUTFILE=$2
|
||||
IGNORE_ERRORS=$3
|
||||
|
||||
echo "Building ${COMMIT}..."
|
||||
git checkout --detach $COMMIT
|
||||
git submodule update --init $SUBMODULES
|
||||
git show -s
|
||||
tools/metrics.py clean "$PORTS_TO_CHECK"
|
||||
# Allow errors from tools/metrics.py to propagate out of the pipe below.
|
||||
set -o pipefail
|
||||
tools/metrics.py build "$PORTS_TO_CHECK" | tee $OUTFILE || $IGNORE_ERRORS
|
||||
tools/metrics.py build "$PORTS_TO_CHECK" | tee -a $OUTFILE || $IGNORE_ERRORS
|
||||
return $?
|
||||
}
|
||||
|
||||
# build reference, save to size0
|
||||
# ignore any errors with this build, in case master is failing
|
||||
echo "BUILDING $(git log --format='%s [%h]' -1 ${REFERENCE})" > ~/size0
|
||||
code_size_build_step $REFERENCE ~/size0 true
|
||||
# build PR/branch, save to size1
|
||||
if _ci_is_git_merge "$COMPARISON"; then
|
||||
echo "BUILDING $(git log --oneline -1 --format='%s [merge of %h]' ${COMPARISON}^2)"
|
||||
else
|
||||
echo "BUILDING $(git log --oneline -1 --formta='%s [%h]' ${COMPARISON})"
|
||||
fi > ~/size1
|
||||
code_size_build_step $COMPARISON ~/size1 false
|
||||
)
|
||||
}
|
||||
|
||||
@@ -127,6 +127,8 @@ def read_build_log(filename):
|
||||
with open(filename) as f:
|
||||
for line in f:
|
||||
line = line.strip()
|
||||
if line.startswith("BUILDING ") and "_ref" not in data:
|
||||
data["_ref"] = line.removeprefix("BUILDING ")
|
||||
if line.strip() == "COMPUTING SIZES":
|
||||
found_sizes = True
|
||||
elif found_sizes:
|
||||
@@ -158,6 +160,10 @@ def do_diff(args):
|
||||
data1 = read_build_log(args[0])
|
||||
data2 = read_build_log(args[1])
|
||||
|
||||
ref1 = data1.pop("_ref", "(unknown ref)")
|
||||
ref2 = data2.pop("_ref", "(unknown ref)")
|
||||
print(f"Reference: {ref1}")
|
||||
print(f"Comparison: {ref2}")
|
||||
max_delta = None
|
||||
for key, value1 in data1.items():
|
||||
value2 = data2[key]
|
||||
|
||||
Reference in New Issue
Block a user