1 ;;; guix-hydra-jobset.el --- Interface for Hydra jobsets -*- lexical-binding: t -*-
3 ;; Copyright © 2015 Alex Kost <alezost@gmail.com>
5 ;; This file is part of GNU Guix.
7 ;; GNU Guix is free software; you can redistribute it and/or modify
8 ;; it under the terms of the GNU General Public License as published by
9 ;; the Free Software Foundation, either version 3 of the License, or
10 ;; (at your option) any later version.
12 ;; GNU Guix is distributed in the hope that it will be useful,
13 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ;; GNU General Public License for more details.
17 ;; You should have received a copy of the GNU General Public License
18 ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
22 ;; This file provides an interface for displaying Hydra jobsets in
23 ;; 'list' and 'info' buffers.
28 (require 'guix-buffer
)
32 (require 'guix-hydra-build
)
35 (guix-hydra-define-entry-type hydra-jobset
36 :search-types
'((project . guix-hydra-jobset-api-url
))
37 :filters
'(guix-hydra-jobset-filter-id)
38 :filter-names
'((nrscheduled . scheduled
)
39 (nrsucceeded . succeeded
)
43 (defun guix-hydra-jobset-get-display (search-type &rest args
)
44 "Search for Hydra builds and show results."
45 (apply #'guix-list-get-display-entries
46 'hydra-jobset search-type args
))
51 (defun guix-hydra-jobset-url (project jobset
)
52 "Return Hydra URL of a PROJECT's JOBSET."
53 (guix-hydra-url "jobset/" project
"/" jobset
))
55 (defun guix-hydra-jobset-api-url (project)
56 "Return Hydra API URL for jobsets by PROJECT."
57 (guix-hydra-api-url "jobsets"
58 `(("project" .
,project
))))
61 ;;; Filters for processing raw entries
63 (defun guix-hydra-jobset-filter-id (entry)
64 "Add 'ID' parameter to 'hydra-jobset' ENTRY."
65 (cons `(id .
,(guix-entry-value entry
'name
))
69 ;;; Hydra jobset 'info'
71 (guix-hydra-info-define-interface hydra-jobset
72 :mode-name
"Hydra-Jobset-Info"
73 :buffer-name
"*Guix Hydra Jobset Info*"
74 :format
'((name ignore
(simple guix-info-heading
))
76 guix-hydra-jobset-info-insert-url
77 (project format guix-hydra-jobset-info-insert-project
)
78 (scheduled format
(format guix-hydra-jobset-info-scheduled
))
79 (succeeded format
(format guix-hydra-jobset-info-succeeded
))
80 (failed format
(format guix-hydra-jobset-info-failed
))
81 (total format
(format guix-hydra-jobset-info-total
))))
83 (defface guix-hydra-jobset-info-scheduled
85 "Face used for the number of scheduled builds."
86 :group
'guix-hydra-jobset-info-faces
)
88 (defface guix-hydra-jobset-info-succeeded
89 '((t :inherit guix-hydra-build-status-succeeded
))
90 "Face used for the number of succeeded builds."
91 :group
'guix-hydra-jobset-info-faces
)
93 (defface guix-hydra-jobset-info-failed
94 '((t :inherit guix-hydra-build-status-failed
))
95 "Face used for the number of failed builds."
96 :group
'guix-hydra-jobset-info-faces
)
98 (defface guix-hydra-jobset-info-total
100 "Face used for the total number of builds."
101 :group
'guix-hydra-jobset-info-faces
)
103 (defun guix-hydra-jobset-info-insert-project (project entry
)
104 "Insert PROJECT button for the jobset ENTRY."
105 (let ((jobset (guix-entry-value entry
'name
)))
107 project
'guix-hydra-build-project
108 'action
(lambda (btn)
109 (let ((args (guix-hydra-build-latest-prompt-args
110 :project
(button-get btn
'project
)
111 :jobset
(button-get btn
'jobset
))))
112 (apply #'guix-hydra-build-get-display
117 (defun guix-hydra-jobset-info-insert-url (entry)
118 "Insert Hydra URL for the jobset ENTRY."
119 (guix-insert-button (guix-hydra-jobset-url
120 (guix-entry-value entry
'project
)
121 (guix-entry-value entry
'name
))
125 ;;; Hydra jobset 'list'
127 (guix-hydra-list-define-interface hydra-jobset
128 :mode-name
"Hydra-Jobset-List"
129 :buffer-name
"*Guix Hydra Jobset List*"
130 :format
'((name nil
25 t
)
137 (let ((map guix-hydra-jobset-list-mode-map
))
138 (define-key map
(kbd "B") 'guix-hydra-jobset-list-latest-builds
))
140 (defun guix-hydra-jobset-list-latest-builds (number &rest args
)
141 "Display latest NUMBER of Hydra builds of the current jobset.
142 Interactively, prompt for NUMBER. With prefix argument, prompt
145 (let ((entry (guix-list-current-entry)))
146 (guix-hydra-build-latest-prompt-args
147 :project
(guix-entry-value entry
'project
)
148 :jobset
(guix-entry-value entry
'name
))))
149 (apply #'guix-hydra-latest-builds number args
))
152 ;;; Interactive commands
155 (defun guix-hydra-jobsets (project)
156 "Display jobsets of PROJECT."
157 (interactive (list (guix-hydra-read-project)))
158 (guix-hydra-jobset-get-display 'project project
))
160 (provide 'guix-hydra-jobset
)
162 ;;; guix-hydra-jobset.el ends here