aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.org35
-rw-r--r--buildbot-client.el28
-rw-r--r--buildbot-utils.el20
-rw-r--r--buildbot-view.el34
4 files changed, 95 insertions, 22 deletions
diff --git a/README.org b/README.org
index 7139b66..f46e660 100644
--- a/README.org
+++ b/README.org
@@ -8,18 +8,37 @@ instance. It supports [[https://docs.buildbot.net/latest/relnotes/0.9.0.html][ne
older versions (<0.9.0) and shows views for branches, revisions,
builds, steps, logs and builders.
+It has been tested for the following instances:
+- [[https://buildbot.mariadb.org][mariadb]]
+- [[https://buildbot.python.org/all][python]]
+- [[https://buildbot.buildbot.net][buildbot]]
+
*: The linked release notes describes the significant changes at
0.9.0.
* Install
+** From ELPA
+ :PROPERTIES:
+ :UPDATED: [2023-07-15 Sat 16:16]
+ :END:
+
+Buildbot is currently available at elpa-devel:
+
+#+begin_src elisp
+(add-to-list 'package-archives
+ ("elpa-devel" . "https://elpa.gnu.org/devel/"))
+(package-refresh-contents)
+(package-install 'buildbot)
+#+end_src
+
** Manual install
:PROPERTIES:
- :UPDATED: [2023-06-26 Mon 16:44]
+ :UPDATED: [2023-07-15 Sat 16:24]
:END:
Clone this repo, and add to load path (assuming you clone to
-~~/.emacs.d~):
+=~/.emacs.d=):
#+begin_src sh
cd ~/.emacs.d
@@ -34,11 +53,16 @@ After that, require buildbot and set the host and builders, like so
#+begin_src elisp
(require 'buildbot)
-(setq buildbot-host "https://buildbot.mariadb.org")
-(setq buildbot-builders (buildbot-get-all-builders))
+(setq buildbot-default-host "https://buildbot.mariadb.org")
#+end_src
+#+RESULTS:
+: https://buildbot.python.org/all
+
* Use
+ :PROPERTIES:
+ :UPDATED: [2023-07-15 Sat 16:11]
+ :END:
Entry points:
- ~M-x buildbot-revision-open~ prompts for a revision id (e.g. commit
@@ -49,6 +73,9 @@ Entry points:
- ~M-x buildbot-builder-open~ prompts for a builder name from a list
of available builders, and opens up a view of recent builds by this
builder.
+- The first time any of these commands is invoked it may take a bit
+ longer than usual because it needs to make an extra call to get all
+ builders.
* TODOs
:PROPERTIES:
diff --git a/buildbot-client.el b/buildbot-client.el
index 0d4cf41..1aaf55f 100644
--- a/buildbot-client.el
+++ b/buildbot-client.el
@@ -30,7 +30,12 @@
(defvar-local buildbot-host nil "Buildbot instance host.")
(defvar-local buildbot-builders nil
"Buildbot builders.
-Can be generated with `(buildbot-get-all-builders)'.")
+Can be generated with `buildbot-get-all-builders'.")
+(defgroup buildbot () "A Buildbot client." :group 'web)
+(defcustom buildbot-default-host nil
+ "The default Buildbot instance host."
+ :group 'buildbot
+ :type 'string)
(defun buildbot-api-change (attr)
"Call the Changes API with ATTR."
@@ -39,6 +44,13 @@ Can be generated with `(buildbot-get-all-builders)'.")
"%s/api/v2/changes?%s"
buildbot-host (buildbot-format-attr attr))))
+(defun buildbot-api-change-builds (change-id)
+ "Call the Changes API with CHANGE-ID to get all builds."
+ (buildbot-url-fetch-json
+ (format
+ "%s/api/v2/changes/%s/builds"
+ buildbot-host change-id)))
+
(defun buildbot-api-log (stepid)
"Call the Logs API with STEPID."
(buildbot-url-fetch-json
@@ -120,8 +132,18 @@ Can be generated with `(buildbot-get-all-builders)'.")
(defun buildbot-get-changes-by-revision (revision)
"Get the changes from a REVISION."
- (alist-get 'changes
- (buildbot-api-change `((revision . ,revision)))))
+ (let ((changes
+ (alist-get 'changes
+ (buildbot-api-change `((revision . ,revision))))))
+ (mapcar
+ (lambda (change)
+ (if (assq 'builds change)
+ change
+ (cons
+ (assq 'builds (buildbot-api-change-builds
+ (alist-get 'changeid change)))
+ change)))
+ changes)))
(defun buildbot-get-build-by-buildid (buildid)
"Get a build with BUILDID."
diff --git a/buildbot-utils.el b/buildbot-utils.el
index d016330..f28ab75 100644
--- a/buildbot-utils.el
+++ b/buildbot-utils.el
@@ -170,15 +170,17 @@ The changes should be of the same revision."
(let* ((first-change (elt changes 0))
(revision-info (buildbot-get-revision-info-from-change first-change))
(changes-info
- (mapcar (lambda (change)
- (list
- (assq 'branch change)
- (assq 'builds change)
- (cons 'build-stats
- (buildbot-get-build-stats
- (alist-get 'builds change)))
- (assq 'revision first-change)))
- changes)))
+ (mapcar
+ (lambda (change)
+ (append
+ (list
+ (assq 'branch change)
+ (assq 'builds change)
+ (assq 'revision first-change))
+ (when-let ((builds (assq 'builds change)))
+ `((build-stats . ,(buildbot-get-build-stats
+ (cdr builds)))))))
+ changes)))
`((revision-info . ,revision-info) (changes-info . ,changes-info))))
(provide 'buildbot-utils)
diff --git a/buildbot-view.el b/buildbot-view.el
index 323d3bc..1db4b87 100644
--- a/buildbot-view.el
+++ b/buildbot-view.el
@@ -128,10 +128,12 @@
(defun buildbot-view-format-build-stats (stats)
"Format build STATS in the view."
- (format "Build stats: Success - %d | Failure - %d | Pending - %d"
- (alist-get 'success stats)
- (alist-get 'failure stats)
- (alist-get 'pending stats)))
+ (if stats
+ (format "Build stats: Success - %d | Failure - %d | Pending - %d"
+ (alist-get 'success stats)
+ (alist-get 'failure stats)
+ (alist-get 'pending stats))
+ "Build stats: Unknown"))
(defun buildbot-view-format-build (revision build &optional show-revision)
"Format a BUILD header associated with REVISION in the view.
@@ -305,6 +307,22 @@ With a non-nil NO-BRANCH, do not show branch info."
('log (format "*buildbot log %d*"
(alist-get 'logid (alist-get 'log data))))))
+(defun buildbot-builders-same-host (host)
+ "Get `buildbot-builders' from a buffer with HOST.
+
+Find the first `buildbot-view-mode' buffer whose `buildbot-host'
+has value HOST and whose `buildbot-builders' is nonnil, and
+return `buildbot-builders' from that buffer."
+ (when-let ((found-buffer
+ (cl-find-if
+ (lambda (buffer)
+ (with-current-buffer buffer
+ (and (derived-mode-p 'buildbot-view-mode)
+ (equal buildbot-host host)
+ buildbot-builders)))
+ (buffer-list))))
+ (buffer-local-value 'buildbot-builders found-buffer)))
+
(defun buildbot-view-open (type data &optional force)
"Open a view of TYPE using DATA.
@@ -317,8 +335,12 @@ With a non-nil FORCE, reload the view buffer if exists."
(buildbot-view-mode)
(setq buildbot-view-type type
buildbot-view-data data
- buildbot-host host
- buildbot-builders builders)
+ buildbot-host
+ (or host buildbot-default-host)
+ buildbot-builders
+ (or builders
+ (buildbot-builders-same-host buildbot-host)
+ (buildbot-get-all-builders)))
(buildbot-view-update)))
(switch-to-buffer buffer-name)))