Skip to contentSkip to conversation

scripts/run-patchmetrics: Only clone metrics if it isn't present

PATCH New Richard Purdie 1 participant 5 messages Oct 23, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/5 scripts/run-patchmetrics: Only clone metrics if it isn't present

To prepare for splitting things up, only clone the metrics repo if it isn't present.

---
 scripts/run-patchmetrics | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
scripts/run-patchmetrics +3 -1
index fc3f214..abe58c7 100755
@@ -13,7 +13,9 @@ TIMESTAMP=`date +"%s"`
 #
 # Patch Metrics
 #
-git clone ssh://[email protected]/yocto-metrics $PARENTDIR/yocto-metrics
+if [ ! -e $PARENTDIR/yocto-metrics ]; then
+    git clone ssh://[email protected]/yocto-metrics $PARENTDIR/yocto-metrics
+fi
 $OURDIR/patchmetrics-update --repo $PARENTDIR --patchscript $PARENTDIR/scripts/contrib/patchreview.py --metadata $TARGETDIR --json $PARENTDIR/yocto-metrics/patch-status.json
 git -C $PARENTDIR/yocto-metrics commit -asm "Autobuilder adding new patch stats"
 git -C $PARENTDIR/yocto-metrics push
Signature · 1 line
2.39.2
#1 lore raw

PATCH 2/5 scripts/run-patchmetrics: Split out CVE checks

Split the CVE checks from the patch metrics script

---
 config.json              |  6 +++++
 scripts/run-cvecheck     | 54 ++++++++++++++++++++++++++++++++++++++++
 scripts/run-patchmetrics | 36 ---------------------------
 3 files changed, 60 insertions(+), 36 deletions(-)
 create mode 100755 scripts/run-cvecheck
config.json +6 -0
index bebd999..f225148 100644
@@ -1208,8 +1208,14 @@
                 "BB_SERVER_TIMEOUT = '0'"
             ],
             "step1" : {
+                "shortname" : "Generating patch metrics",
                 "EXTRACMDS" : ["../../yocto-autobuilder-helper/scripts/run-patchmetrics ../ ../meta/ ${HELPERRESULTSDIR}/../../patchmetrics ."]
+            },
+            "step2" : {
+                "shortname" : "Running CVE checks",
+                "EXTRACMDS" : ["../../yocto-autobuilder-helper/scripts/run-cvecheck ../ ../meta/ ${HELPERRESULTSDIR}/../../patchmetrics ."]
             }
+
         },
         "meta-mingw" : {
             "NEEDREPOS" : ["poky", "meta-mingw"],
scripts/run-cvecheck new file +54 -0

54 lines not on this page · raw message

scripts/run-patchmetrics +0 -36
index abe58c7..e45d463 100755
@@ -27,39 +27,3 @@ fi
 $OURDIR/patchmetrics-generate-chartdata --json $PARENTDIR/yocto-metrics/patch-status.json --outputdir $RESULTSDIR
 cp $PARENTDIR/yocto-metrics/patch-status.json $RESULTSDIR
 cp $PARENTDIR/yocto-metrics/patch-status/* $RESULTSDIR
-
-#
-# CVE Checks
-#
-for branch in master mickledore langdale kirkstone dunfell; do
-    mkdir -p $PARENTDIR/yocto-metrics/cve-check/$branch/
-    git -C $PARENTDIR reset origin/$branch --hard
-    rm conf/local.conf
-    rm conf/bblayers.conf
-    rm -f conf/templateconf.cfg
-    rm tmp/ -rf
-    unset BB_ENV_PASSTHROUGH_ADDITIONS
-    unset BB_ENV_EXTRAWHITE
-    cd ..
-    . oe-init-build-env build
-    bitbake world --runall cve_check -R conf/distro/include/cve-extra-exclusions.inc
-    if [ -e tmp/log/cve/cve-summary.json ]; then
-        git -C $PARENTDIR/yocto-metrics rm cve-check/$branch/*.json
-        mkdir -p $PARENTDIR/yocto-metrics/cve-check/$branch
-        cp tmp/log/cve/cve-summary.json $PARENTDIR/yocto-metrics/cve-check/$branch/$TIMESTAMP.json
-        git -C $PARENTDIR/yocto-metrics add cve-check/$branch/$TIMESTAMP.json
-        git -C $PARENTDIR/yocto-metrics commit -asm "Autobuilder adding new CVE data for branch $branch"
-        git -C $PARENTDIR/yocto-metrics push
-        $OURDIR/cve-report.py tmp/log/cve/cve-summary.json > $RESULTSDIR/cve-status-$branch.txt
-    fi
-done
-
-mkdir -p $PARENTDIR/yocto-metrics/cve-check/
-$OURDIR/cve-generate-chartdata --json $PARENTDIR/yocto-metrics/cve-count-byday.json --resultsdir $PARENTDIR/yocto-metrics/cve-check/
-git -C $PARENTDIR/yocto-metrics add cve-count-byday.json
-git -C $PARENTDIR/yocto-metrics commit -asm "Autobuilder updating CVE counts"
-git -C $PARENTDIR/yocto-metrics push
-
-cp $PARENTDIR/yocto-metrics/cve-count-byday.json $RESULTSDIR
-cp $PARENTDIR/yocto-metrics/cve-count-byday-lastyear.json $RESULTSDIR
-
Signature · 1 line
2.39.2
#2 lore raw

PATCH 3/5 metrics: Pass branchname to scripts

In reply to Richard Purdie

To prepapre to run the scripts per branch, pass the branchname to the scripts.

---
 config.json              | 4 ++--
 scripts/run-cvecheck     | 1 +
 scripts/run-patchmetrics | 1 +
 3 files changed, 4 insertions(+), 2 deletions(-)
config.json +2 -2
index f225148..0c35632 100644
@@ -1209,11 +1209,11 @@
             ],
             "step1" : {
                 "shortname" : "Generating patch metrics",
-                "EXTRACMDS" : ["../../yocto-autobuilder-helper/scripts/run-patchmetrics ../ ../meta/ ${HELPERRESULTSDIR}/../../patchmetrics ."]
+                "EXTRACMDS" : ["../../yocto-autobuilder-helper/scripts/run-patchmetrics ../ ../meta/ ${HELPERRESULTSDIR}/../../patchmetrics . ${HELPERBRANCHNAME}"]
             },
             "step2" : {
                 "shortname" : "Running CVE checks",
-                "EXTRACMDS" : ["../../yocto-autobuilder-helper/scripts/run-cvecheck ../ ../meta/ ${HELPERRESULTSDIR}/../../patchmetrics ."]
+                "EXTRACMDS" : ["../../yocto-autobuilder-helper/scripts/run-cvecheck ../ ../meta/ ${HELPERRESULTSDIR}/../../patchmetrics . ${HELPERBRANCHNAME}"]
             }
 
         },
scripts/run-cvecheck +1 -0
index 35c796b..d48fd68 100755
@@ -6,6 +6,7 @@ PARENTDIR=`realpath $1`
 TARGETDIR=`realpath $2`
 RESULTSDIR=`realpath -m $3`
 BUILDDIR=`realpath $4`
+BRANCH=$5
 OURDIR=`dirname $0`
 
 TIMESTAMP=`date +"%s"`
scripts/run-patchmetrics +1 -0
index e45d463..20e6268 100755
@@ -6,6 +6,7 @@ PARENTDIR=`realpath $1`
 TARGETDIR=`realpath $2`
 RESULTSDIR=`realpath -m $3`
 BUILDDIR=`realpath $4`
+BRANCH=$5
 OURDIR=`dirname $0`
 
 TIMESTAMP=`date +"%s"`
Signature · 1 line
2.39.2
#3 lore raw

PATCH 4/5 scripts/run-patchmetrics: Only monitor master branch

In reply to Richard Purdie

We only monitor the master branch for patch metrics as we can't really make improvements to release branches.

---
 scripts/run-patchmetrics | 5 +++++
 1 file changed, 5 insertions(+)
scripts/run-patchmetrics +5 -0
index 20e6268..391ac45 100755
@@ -11,6 +11,11 @@ OURDIR=`dirname $0`
 
 TIMESTAMP=`date +"%s"`
 
+# We only monitor patch metrics on the master branch
+if [ "$BRANCH" != "master" ]; then
+    exit 0
+fi
+
 #
 # Patch Metrics
 #
Signature · 1 line
2.39.2
#4 lore raw

PATCH 5/5 scripts/run-cvecheck: Remove branch iteration

In reply to Richard Purdie

Rather than running multiple checkouts, lets move this to the autobuilder to handle and have it trigger the builds with the right checkouts.

---
 scripts/run-cvecheck | 52 ++++++++++++++++++++------------------------
 1 file changed, 23 insertions(+), 29 deletions(-)
scripts/run-cvecheck +23 -29
index d48fd68..6294fe6 100755
@@ -22,34 +22,28 @@ if [ ! -d $RESULTSDIR ]; then
     mkdir $RESULTSDIR
 fi
 
-for branch in master mickledore langdale kirkstone dunfell; do
-    mkdir -p $PARENTDIR/yocto-metrics/cve-check/$branch/
-    git -C $PARENTDIR reset origin/$branch --hard
-    rm conf/local.conf
-    rm conf/bblayers.conf
-    rm -f conf/templateconf.cfg
-    rm tmp/ -rf
-    unset BB_ENV_PASSTHROUGH_ADDITIONS
-    unset BB_ENV_EXTRAWHITE
-    cd ..
-    . oe-init-build-env build
-    bitbake world --runall cve_check -R conf/distro/include/cve-extra-exclusions.inc
-    if [ -e tmp/log/cve/cve-summary.json ]; then
-        git -C $PARENTDIR/yocto-metrics rm cve-check/$branch/*.json
-        mkdir -p $PARENTDIR/yocto-metrics/cve-check/$branch
-        cp tmp/log/cve/cve-summary.json $PARENTDIR/yocto-metrics/cve-check/$branch/$TIMESTAMP.json
-        git -C $PARENTDIR/yocto-metrics add cve-check/$branch/$TIMESTAMP.json
-        git -C $PARENTDIR/yocto-metrics commit -asm "Autobuilder adding new CVE data for branch $branch"
-        git -C $PARENTDIR/yocto-metrics push
-        $OURDIR/cve-report.py tmp/log/cve/cve-summary.json > $RESULTSDIR/cve-status-$branch.txt
-    fi
-done
+mkdir -p $PARENTDIR/yocto-metrics/cve-check/$BRANCH/
+cd ..
+. oe-init-build-env build
+bitbake world --runall cve_check -R conf/distro/include/cve-extra-exclusions.inc
+if [ -e tmp/log/cve/cve-summary.json ]; then
+    git -C $PARENTDIR/yocto-metrics rm cve-check/$BRANCH/*.json
+    mkdir -p $PARENTDIR/yocto-metrics/cve-check/$BRANCH
+    cp tmp/log/cve/cve-summary.json $PARENTDIR/yocto-metrics/cve-check/$BRANCH/$TIMESTAMP.json
+    git -C $PARENTDIR/yocto-metrics add cve-check/$BRANCH/$TIMESTAMP.json
+    git -C $PARENTDIR/yocto-metrics commit -asm "Autobuilder adding new CVE data for branch $BRANCH"
+    git -C $PARENTDIR/yocto-metrics push
+    $OURDIR/cve-report.py tmp/log/cve/cve-summary.json > $RESULTSDIR/cve-status-$BRANCH.txt
+fi
+
+if [ "$BRANCH" = "master" ]; then
+    mkdir -p $PARENTDIR/yocto-metrics/cve-check/
+    $OURDIR/cve-generate-chartdata --json $PARENTDIR/yocto-metrics/cve-count-byday.json --resultsdir $PARENTDIR/yocto-metrics/cve-check/
+    git -C $PARENTDIR/yocto-metrics add cve-count-byday.json
+    git -C $PARENTDIR/yocto-metrics commit -asm "Autobuilder updating CVE counts"
+    git -C $PARENTDIR/yocto-metrics push
 
-mkdir -p $PARENTDIR/yocto-metrics/cve-check/
-$OURDIR/cve-generate-chartdata --json $PARENTDIR/yocto-metrics/cve-count-byday.json --resultsdir $PARENTDIR/yocto-metrics/cve-check/
-git -C $PARENTDIR/yocto-metrics add cve-count-byday.json
-git -C $PARENTDIR/yocto-metrics commit -asm "Autobuilder updating CVE counts"
-git -C $PARENTDIR/yocto-metrics push
+    cp $PARENTDIR/yocto-metrics/cve-count-byday.json $RESULTSDIR
+    cp $PARENTDIR/yocto-metrics/cve-count-byday-lastyear.json $RESULTSDIR
+fi
 
-cp $PARENTDIR/yocto-metrics/cve-count-byday.json $RESULTSDIR
-cp $PARENTDIR/yocto-metrics/cve-count-byday-lastyear.json $RESULTSDIR
Signature · 1 line
2.39.2