public inbox for tools@linux.kernel.org
 help / color / mirror / Atom feed
From: Tamir Duberstein <tamird@kernel.org>
To: "Kernel.org Tools" <tools@kernel.org>
Cc: Konstantin Ryabitsev <konstantin@linuxfoundation.org>,
	 Tamir Duberstein <tamird@kernel.org>
Subject: [PATCH b4 12/12] Add local CI review check
Date: Tue, 07 Apr 2026 12:48:41 -0400	[thread overview]
Message-ID: <20260407-ruff-check-v1-12-c9568541ff67@kernel.org> (raw)
In-Reply-To: <20260407-ruff-check-v1-0-c9568541ff67@kernel.org>

Configure b4's review TUI to run the project's local checks as a
per-series check command. The helper emits the JSON shape expected by b4
and records the input message headers so results show which series was
checked.

Signed-off-by: Tamir Duberstein <tamird@kernel.org>
---
 .b4-config    |  1 +
 misc/b4-ci.py | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 58 insertions(+)

diff --git a/.b4-config b/.b4-config
index ea95e4a..9fcebab 100644
--- a/.b4-config
+++ b/.b4-config
@@ -5,3 +5,4 @@
   send-series-cc = Konstantin Ryabitsev <konstantin@linuxfoundation.org>
   send-endpoint-web = https://lkml.kernel.org/_b4_submit
   send-prefixes = b4
+  review-series-check-cmd = uv run --all-extras completion --all-groups python misc/b4-ci.py
diff --git a/misc/b4-ci.py b/misc/b4-ci.py
new file mode 100644
index 0000000..c65863c
--- /dev/null
+++ b/misc/b4-ci.py
@@ -0,0 +1,57 @@
+#!/usr/bin/env python3
+# SPDX-License-Identifier: GPL-2.0-or-later
+"""Run b4's local CI checks for the review TUI."""
+
+import json
+import subprocess
+import sys
+from email.parser import BytesParser
+from email.policy import default
+from typing import Dict, List
+
+CHECKS = [
+    ('ruff', ['ruff', 'check', '.']),
+    ('mypy', ['mypy', '.']),
+    ('pyright', ['pyright', '.']),
+    ('ty', ['ty', 'check', '.']),
+    ('pytest', ['pytest', '--durations=20']),
+]
+
+
+def read_input_details() -> List[str]:
+    msg = BytesParser(policy=default).parse(sys.stdin.buffer, headersonly=True)
+    details: List[str] = []
+    if subject := msg.get('Subject'):
+        details.append(f'Input-Subject: {subject}')
+    if msgid := msg.get('Message-ID'):
+        details.append(f'Input-Message-ID: {msgid}')
+    return details
+
+
+def run_check(tool: str, cmd: List[str], input_details: List[str]) -> Dict[str, str]:
+    proc = subprocess.run(cmd, capture_output=True, text=True, check=False)
+    details = [f'$ {" ".join(cmd)}']
+    if input_details:
+        details.extend(['', *input_details])
+    if proc.stdout:
+        details.extend(['', proc.stdout.rstrip()])
+    if proc.stderr:
+        details.extend(['', proc.stderr.rstrip()])
+
+    return {
+        'tool': tool,
+        'status': 'pass' if proc.returncode == 0 else 'fail',
+        'summary': 'passed' if proc.returncode == 0 else f'failed with exit code {proc.returncode}',
+        'details': '\n'.join(details),
+    }
+
+
+def main() -> None:
+    input_details = read_input_details()
+    results = [run_check(tool, cmd, input_details) for tool, cmd in CHECKS]
+    json.dump(results, sys.stdout, indent=2)
+    sys.stdout.write('\n')
+
+
+if __name__ == '__main__':
+    main()

-- 
2.53.0


  parent reply	other threads:[~2026-04-07 16:48 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-07 16:48 [PATCH b4 00/12] Enable stricter local checks Tamir Duberstein
2026-04-07 16:48 ` [PATCH b4 01/12] Configure ruff format with single quotes Tamir Duberstein
2026-04-07 16:48 ` [PATCH b4 02/12] Fix ruff check warnings Tamir Duberstein
2026-04-07 16:48 ` [PATCH b4 03/12] Use ruff to sort imports Tamir Duberstein
2026-04-07 16:48 ` [PATCH b4 04/12] Import dependencies unconditionally Tamir Duberstein
2026-04-07 16:48 ` [PATCH b4 05/12] Fix tests under uv with complex git config Tamir Duberstein
2026-04-07 16:48 ` [PATCH b4 06/12] Fix typings in misc/ Tamir Duberstein
2026-04-07 16:48 ` [PATCH b4 07/12] Enable mypy unreachable warnings Tamir Duberstein
2026-04-07 16:48 ` [PATCH b4 08/12] Enable and fix pyright diagnostics Tamir Duberstein
2026-04-07 16:48 ` [PATCH b4 09/12] Avoid duplicate map lookups Tamir Duberstein
2026-04-07 16:48 ` [PATCH b4 10/12] Add ty and configuration Tamir Duberstein
2026-04-07 16:48 ` [PATCH b4 11/12] Enable pyright strict mode Tamir Duberstein
2026-04-07 16:48 ` Tamir Duberstein [this message]
2026-04-10 15:05 ` [PATCH b4 00/12] Enable stricter local checks Tamir Duberstein
2026-04-10 15:21   ` Konstantin Ryabitsev
2026-04-10 22:39     ` Tamir Duberstein

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260407-ruff-check-v1-12-c9568541ff67@kernel.org \
    --to=tamird@kernel.org \
    --cc=konstantin@linuxfoundation.org \
    --cc=tools@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox