Skip to content

Commit

Permalink
brancher: pre-generate deltas when creating a branch
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
kuba-moo committed Aug 28, 2024
1 parent 8bc607d commit 4c83e5f
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
9 changes: 9 additions & 0 deletions contest/cidiff
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 18 additions & 0 deletions pw_brancher.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import json
import os
import psycopg2
import subprocess
import time
from typing import List, Tuple
import uuid
Expand All @@ -32,6 +33,7 @@
[output]
branches=branches.json
info=branches-info.json
deltas=/path/to/dir/
[db]
db=db-name
"""
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion ui/status.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 + "</a>" + br_pull;
branch.setAttribute("colspan", "2");
res.innerHTML = "";
res.innerHTML = "<a href=\"static/nipa/branch_deltas/" + v.branch + "\">cidiff</a>";
row.setAttribute("class", "end-row");
}
});
Expand Down

0 comments on commit 4c83e5f

Please sign in to comment.