aboutsummaryrefslogtreecommitdiff
path: root/buildbot-view.el
diff options
context:
space:
mode:
authorYuchen Pei <hi@ypei.me>2023-03-24 00:08:42 +1100
committerYuchen Pei <hi@ypei.me>2023-03-24 00:08:42 +1100
commit94172a6c655ea4aefe2960aa5db9fec77130e87d (patch)
tree59b27daaf1f553d5e282799941af27c01aeadfaa /buildbot-view.el
parent7cc017ccc12921e38d0ace50400e096a4f6ddd2b (diff)
Adding step mode. Also refactoring
Diffstat (limited to 'buildbot-view.el')
-rw-r--r--buildbot-view.el69
1 files changed, 69 insertions, 0 deletions
diff --git a/buildbot-view.el b/buildbot-view.el
new file mode 100644
index 0000000..846c0df
--- /dev/null
+++ b/buildbot-view.el
@@ -0,0 +1,69 @@
+;; -*- lexical-binding: t; -*-
+(require 'buildbot-utils)
+
+(defvar buildbot-view-header-regex "^\\[.*\\]$")
+
+(define-derived-mode buildbot-view-mode special-mode "Buildbot view"
+ "Buildbot view, a base mode")
+
+(defun buildbot-view-next-header (n)
+ (interactive "p")
+ (dotimes (_ n)
+ (end-of-line 1)
+ (re-search-forward buildbot-view-header-regex)
+ (beginning-of-line 1)))
+(define-key buildbot-view-mode-map "n" 'buildbot-view-next-header)
+
+(defun buildbot-view-previous-header (n)
+ (interactive "p")
+ (beginning-of-line 1)
+ (unless (looking-at buildbot-view-header-regex)
+ (re-search-backward buildbot-view-header-regex))
+ (dotimes (_ n)
+ (re-search-backward buildbot-view-header-regex)))
+(define-key buildbot-view-mode-map "p" 'buildbot-view-previous-header)
+
+(defun buildbot-view-format-revision-info (revision-info)
+ (propertize
+ (format
+ "[commit %s]\nAuthor: %s\nDate: %s\n\n%s\n\n%s"
+ (alist-get 'revision revision-info)
+ (alist-get 'author revision-info)
+ (alist-get 'created-at revision-info)
+ (alist-get 'comments revision-info)
+ (buildbot-view-format-build-stats
+ (alist-get 'build-stats revision-info)))
+ 'revision-id (alist-get 'revision revision-info)))
+
+(defun buildbot-view-format-build-stats (stats)
+ (format "Build stats: Success - %d | Failure - %d | Pending - %d"
+ (alist-get 'success stats)
+ (alist-get 'failure stats)
+ (alist-get 'pending stats)))
+
+(defun buildbot-view-format-build (build)
+ (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"))
+ 'build build))
+
+(defun buildbot-view-format-step (step)
+ (propertize
+ (format "\n[%d %s %s]\n"
+ (alist-get 'number step)
+ (alist-get 'name step)
+ (alist-get 'state_string step))
+ 'step step))
+
+(defun buildbot-view-format-log (log)
+ (propertize
+ (format "\n[%s]\n"
+ (alist-get 'name log))
+ 'log log))
+
+(provide 'buildbot-view)