new file mode 100755
@@ -0,0 +1,79 @@
+#!/bin/bash
+#
+# SPDX-License-Identifier: GPL-2.0-only
+#
+
+set -eu
+
+ARGS=$(getopt -o '' --long 'metrics:,results:,push' -n 'run-cvecharts' -- "$@")
+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)
+# The metrics repository to use
+METRICSDIR=""
+# Where to copy results to
+RESULTSDIR=""
+# Whether to push the metrics
+PUSH=0
+
+while true; do
+ case "$1" in
+ '--metrics')
+ METRICSDIR=$(realpath $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 "$METRICSDIR" -a "$RESULTSDIR"; then
+ echo "Not all required options specified"
+ exit 1
+fi
+
+#
+# CVE Chart data generation
+#
+if [ ! -d $RESULTSDIR ]; then
+ mkdir $RESULTSDIR
+fi
+
+# Do another pull to make sure we're as up to date as possible. This is
+# preferable to committing and rebasing before pushing as it would be better to
+# waste some time repeating work than commit potentially corrupted files from a
+# git merge gone wrong.
+git -C $METRICSDIR pull
+
+$OURDIR/cve-generate-chartdata --json $METRICSDIR/cve-count-byday.json --resultsdir $METRICSDIR/cve-check/
+git -C $METRICSDIR add cve-count-byday.json
+git -C $METRICSDIR commit -asm "Autobuilder updating CVE counts" || true
+if [ "$PUSH" = "1" ]; then
+ git -C $METRICSDIR push
+fi
+
+cp $METRICSDIR/cve-count-byday.json $RESULTSDIR
+cp $METRICSDIR/cve-count-byday-lastyear.json $RESULTSDIR
@@ -94,16 +94,3 @@ if [ -e tmp/log/cve/cve-summary.json ]; then
fi
$OURDIR/cve-report.py tmp/log/cve/cve-summary.json > $RESULTSDIR/cve-status-$BRANCH.txt
fi
-
-if [ "$BRANCH" = "master" ]; then
- mkdir -p $METRICSDIR/cve-check/$BRANCH/
- $OURDIR/cve-generate-chartdata --json $METRICSDIR/cve-count-byday.json --resultsdir $METRICSDIR/cve-check/
- git -C $METRICSDIR add cve-count-byday.json
- git -C $METRICSDIR commit -asm "Autobuilder updating CVE counts" || true
- if [ "$PUSH" = "1" ]; then
- git -C $METRICSDIR push
- fi
-
- cp $METRICSDIR/cve-count-byday.json $RESULTSDIR
- cp $METRICSDIR/cve-count-byday-lastyear.json $RESULTSDIR
-fi
run-cvecheck had a special case for master were it would generate chart data after computing CVE metrics. This had to happen last in the list branches calling run-cvecheck. By spliting run-cvecheck into 2: * run-cvecheck (only does the cve-check), * run-cvecharts (only does the chart generation), ... we can run-cvecheck on master first while keeping run-cvecharts last. Signed-off-by: Yoann Congal <yoann.congal@smile.fr> --- scripts/run-cvecharts | 79 +++++++++++++++++++++++++++++++++++++++++++ scripts/run-cvecheck | 13 ------- 2 files changed, 79 insertions(+), 13 deletions(-) create mode 100755 scripts/run-cvecharts