From 4c83e5f3468e0528796b58c9766c340058ff6957 Mon Sep 17 00:00:00 2001 From: Jakub Kicinski Date: Wed, 28 Aug 2024 08:07:53 -0700 Subject: [PATCH] brancher: pre-generate deltas when creating a branch Since we batch patches for testing when something fails we need to figure out what went wrong. Instead of having to fetch the branches locally and manually run cidiff just generate the output after creating each branch. Link to it from the status page. Hardcoding part of the URL isn't nice but not sure what to do about that. We could put the link to the cidiff in the branch manifest. But it feels a little auxiliary. Signed-off-by: Jakub Kicinski --- contest/cidiff | 9 +++++++++ pw_brancher.py | 18 ++++++++++++++++++ ui/status.js | 2 +- 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/contest/cidiff b/contest/cidiff index 2df5232..fd5e9af 100755 --- a/contest/cidiff +++ b/contest/cidiff @@ -15,6 +15,15 @@ if [ x$BRANCH1$BRANCH2 == x ]; then BRANCH1=${branches[0]} BRANCH2=${branches[1]} + echo " " $BRANCH1 + echo " " $BRANCH2 + echo +elif [ x$BRANCH2 == x ]; then + echo "Single branch specified, using that and the previous one:" + branches=( $(git branch -a | grep -B1 "$1") ) + BRANCH1=${branches[0]} + BRANCH2=${branches[1]} + echo " " $BRANCH1 echo " " $BRANCH2 echo diff --git a/pw_brancher.py b/pw_brancher.py index 0a461d2..06e3826 100755 --- a/pw_brancher.py +++ b/pw_brancher.py @@ -6,6 +6,7 @@ import json import os import psycopg2 +import subprocess import time from typing import List, Tuple import uuid @@ -32,6 +33,7 @@ [output] branches=branches.json info=branches-info.json +deltas=/path/to/dir/ [db] db=db-name """ @@ -190,6 +192,18 @@ def db_insert(config, state, name): cur.execute("INSERT INTO branches VALUES " + arg.decode('utf-8')) +def generate_deltas(config, name): + outdir = config.get("output", "deltas", fallback=None) + if not outdir: + return + + outfile = os.path.join(outdir, name) + cidiff = os.path.join(os.path.dirname(__file__), "contest", "cidiff") + + with open(outfile, 'w') as fp: + subprocess.run([cidiff, name], stdout=fp, check=True) + + def create_new(pw, config, state, tree, tgt_remote) -> None: now = datetime.datetime.now(datetime.UTC) pfx = config.get("target", "branch_pfx") @@ -235,6 +249,10 @@ def create_new(pw, config, state, tree, tgt_remote) -> None: tree.git_push(tgt_remote, "HEAD:" + branch_name) log_end_sec() + log_open_sec("Generate deltas") + generate_deltas(config, branch_name) + log_end_sec() + def state_delete_branch(state, br): del state["branches"][br] diff --git a/ui/status.js b/ui/status.js index 15d9d8d..18999df 100644 --- a/ui/status.js +++ b/ui/status.js @@ -693,7 +693,7 @@ function load_result_table_one(data_raw, table, reported, avgs) br_pull = " (pull: " + v.pull_status + ")"; branch.innerHTML = a + v.branch + "" + br_pull; branch.setAttribute("colspan", "2"); - res.innerHTML = ""; + res.innerHTML = "cidiff"; row.setAttribute("class", "end-row"); } });