aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYuchen Pei <hi@ypei.me>2023-03-23 09:21:56 +1100
committerYuchen Pei <hi@ypei.me>2023-03-23 09:21:56 +1100
commit7cc017ccc12921e38d0ace50400e096a4f6ddd2b (patch)
treed0d39a1cce41f0ea3aab077d0aa6b79f95bb0c12
parentf9792cdcfab9b2728b3db8152e62e119b135b7ac (diff)
added buildbot build mode
-rw-r--r--buildbot-build.el39
-rw-r--r--buildbot-client.el3
-rw-r--r--buildbot-revision.el53
-rw-r--r--buildbot-utils.el4
4 files changed, 86 insertions, 13 deletions
diff --git a/buildbot-build.el b/buildbot-build.el
index ca1a8bc..a6c2b09 100644
--- a/buildbot-build.el
+++ b/buildbot-build.el
@@ -1,4 +1,43 @@
+(require 'buildbot-client)
(define-derived-mode buildbot-build-mode special-mode "Buildbot build"
"Buildbot view for a build")
+(defvar-local buildbot-build-build-id nil)
+(defvar-local buildbot-build-info nil)
+(defun buildbot-build-buffer-name (buildid)
+ (concat "*buildbot build " (number-to-string buildid) "*"))
+
+(defun buildbot-build-load (buildid)
+ (let ((buffer-name (buildbot-build-buffer-name buildid)))
+ (with-current-buffer (get-buffer-create buffer-name)
+ (buildbot-build-mode)
+ (setq buildbot-build-build-id buildid)
+ (buildbot-build-update))
+ (switch-to-buffer buffer-name)))
+
+(defun buildbot-build-update ()
+ (unless (derived-mode-p 'buildbot-build-mode)
+ (error "Not in buildbot build mode"))
+ (let ((inhibit-read-only t))
+ (erase-buffer)
+ (let ((steps (buildbot-get-steps-by-buildid buildbot-build-build-id)))
+ (insert (buildbot-build-format steps))
+ (goto-char (point-min)))))
+
+(defun buildbot-build-open (buildid)
+ (interactive "sBuildi ID: ")
+ (buildbot-build-load (string-to-number buildid)))
+
+(defun buildbot-build-format (steps)
+ (string-join
+ (mapcar 'buildbot-build-format-step steps)
+ "\n"))
+
+(defun buildbot-build-format-step (step)
+ (propertize
+ (format "\n[%d %s %s]\n"
+ (alist-get 'number step)
+ (alist-get 'name step)
+ (alist-get 'state_string step))))
+
(provide 'buildbot-build)
diff --git a/buildbot-client.el b/buildbot-client.el
index 1bb8310..afc1a69 100644
--- a/buildbot-client.el
+++ b/buildbot-client.el
@@ -55,6 +55,9 @@
(buildbot-api-change (list (cons 'revision revision))))
0))
+(defun buildbot-get-build-by-buildid (buildid)
+ (buildbot-api-build (list (cons 'buildid buildid))))
+
(defun buildbot-get-builds-by-revision (revision)
(alist-get 'builds (buildbot-get-change-by-revision revision)))
diff --git a/buildbot-revision.el b/buildbot-revision.el
index 4f8ad57..08ba7b1 100644
--- a/buildbot-revision.el
+++ b/buildbot-revision.el
@@ -2,6 +2,7 @@
(require 'buildbot-client)
(defvar-local buildbot-revision-revision-id nil)
+(defvar-local buildbot-revision-info nil)
(defvar buildbot-revision-header-regex "^\\[.*\\]$")
(define-derived-mode buildbot-revision-mode special-mode "Buildbot revision"
@@ -25,7 +26,13 @@
(error "Not in buildbot revision mode"))
(let ((inhibit-read-only t))
(erase-buffer)
- (insert (buildbot-revision-format buildbot-revision-revision-id))))
+ (let ((change
+ (buildbot-get-change-by-revision buildbot-revision-revision-id)))
+ (setq buildbot-revision-info
+ (buildbot-revision-get-info change))
+ (insert (buildbot-revision-format buildbot-revision-info
+ (alist-get 'builds change)))
+ (goto-char (point-min)))))
(defun buildbot-revision-open (revision)
(interactive "sRevision (commit hash): ")
@@ -35,11 +42,29 @@
(interactive)
(buildbot-revision-update))
-(defun buildbot-revision-format (revision)
- (string-join
- (mapcar 'buildbot-revision-format-build
- (buildbot-get-builds-by-revision revision))
- "\n"))
+(defun buildbot-revision-format (revision-info builds)
+ (concat
+ (buildbot-revision-format-info revision-info)
+ "\n"
+ (string-join
+ (mapcar 'buildbot-revision-format-build builds)
+ "\n")))
+
+(defun buildbot-revision-get-info (change)
+ (list (cons 'revision (alist-get 'revision change))
+ (cons 'author (alist-get 'author change))
+ (cons 'created-at (buildbot-format-epoch-time
+ (alist-get 'created_at
+ (alist-get 'sourcestamp change))))
+ (cons 'comments (alist-get 'comments change))))
+
+(defun buildbot-revision-format-info (info)
+ (format
+ "commit %s\nAuthor: %s\nDate: %s\n\n%s"
+ (alist-get 'revision info)
+ (alist-get 'author info)
+ (alist-get 'created-at info)
+ (alist-get 'comments info)))
(defun buildbot-revision-next-header (n)
(interactive "p")
@@ -59,12 +84,14 @@
(define-key buildbot-revision-mode-map "p" 'buildbot-revision-previous-header)
(defun buildbot-revision-format-build (build)
- (format "[%s %s]\n%s\n"
- (buildbot-get-builder-name-by-id (alist-get 'builderid build))
- (alist-get 'state_string build)
- (string-join
- (mapcar (lambda (test) (alist-get 'test_name test))
- (alist-get 'failed_tests build))
- "\n")))
+ (propertize
+ (format "\n[%s %s]\n%s"
+ (buildbot-get-builder-name-by-id (alist-get 'builderid build))
+ (alist-get 'state_string build)
+ (string-join
+ (mapcar (lambda (test) (alist-get 'test_name test))
+ (alist-get 'failed_tests build))
+ "\n"))
+ 'buildid (alist-get 'id build)))
(provide 'buildbot-revision)
diff --git a/buildbot-utils.el b/buildbot-utils.el
index ebac706..269cdf3 100644
--- a/buildbot-utils.el
+++ b/buildbot-utils.el
@@ -47,4 +47,8 @@
attr)
"&"))
+(defun buildbot-format-epoch-time (epoch)
+ (format-time-string "%Y-%m-%d %a %H:%M:%S %Z" (encode-time
+ (decode-time epoch))))
+
(provide 'buildbot-utils)