
Rewrite the scripts that gather the metrics to be more generic. Extract the metrics repository cloning out so that we don't have to repeatedly clone it. Make the scripts parse their arguments using getopt and be more specific about what they're passed. In particular, this means that for the patch review run we pass the _repository_ that we're scanning so we can do git operations on it, and the base of the _layers_ (either a layer, or a directory containing layers) so we know what to scan. Be more clever when identifying what commits we need to analyse for patch review: instead of iterating through a set randomly, we can keep the revision list sorted and the checkout operations are a lot faster. Remove the commit/file count metric addition as patchreview itself does that now. Add an explicit --push option so it's easy to test the scripts in isolation without pushing. Signed-off-by: Ross Burton <ross.burton@arm.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2.4 KiB
Executable File
#!/bin/bash
SPDX-License-Identifier: GPL-2.0-only
set -eu
ARGS=$(getopt -o '' --long 'poky:,metrics:,repo:,layer:,branch:,results:,push' -n 'run-patchmetrics' -- "$@") if [ $? -ne 0 ]; then echo 'Cannot parse arguments...' >&2 exit 1 fi eval set -- "$ARGS" unset ARGS
Location of the yocto-autobuilder-helper scripts
OURDIR=$(dirname $0)
Where Poky is (for patchreview.py)
POKYDIR=""
The metrics repository to use
METRICSDIR=""
Where to copy results to
RESULTSDIR=""
The branch we're building
BRANCH=""
The layer/repository to scan
LAYERDIR=""
Whether to push the metrics
PUSH=0
while true; do case "$1" in '--poky') POKYDIR=$(realpath $2) shift 2 continue ;; '--metrics') METRICSDIR=$(realpath $2) shift 2 continue ;; '--layer') LAYERDIR=$(realpath $2) shift 2 continue ;; '--repo') REPODIR=$(realpath $2) shift 2 continue ;; '--branch') BRANCH=$2 shift 2 continue ;; '--results') RESULTSDIR=$(realpath -m $2) shift 2 continue ;; '--push') PUSH=1 shift continue ;; '--') shift break ;; *) echo "Unexpected value $1" >&2 exit 1 ;; esac done
if ! test "$POKYDIR" -a "$METRICSDIR" -a "$REPODIR" -a "$LAYERDIR" -a "$BRANCH" -a "$RESULTSDIR"; then echo "Not all required options specified" exit 1 fi
We only monitor patch metrics on the master branch
if [ "$BRANCH" != "master" ]; then echo "Skipping, $BRANCH is not master" exit 0 fi
Patch Metrics
set -x $OURDIR/patchmetrics-update --patchscript $POKYDIR/scripts/contrib/patchreview.py --json $METRICSDIR/patch-status.json --repo $REPODIR --layer $LAYERDIR set +x
Allow the commit to fail if there is nothing to commit
git -C $METRICSDIR commit -asm "Autobuilder adding new patch stats" || true
if [ "$PUSH" = "1" ]; then git -C $METRICSDIR push fi
Update the results
if [ ! -d $RESULTSDIR ]; then mkdir $RESULTSDIR fi
$OURDIR/patchmetrics-generate-chartdata --json $METRICSDIR/patch-status.json --outputdir $RESULTSDIR cp $METRICSDIR/patch-status.json $RESULTSDIR cp $METRICSDIR/patch-status/* $RESULTSDIR