unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
blob a4a55a36f2a0ae9ecf60e291a946bab785dfd047 5415 bytes (raw)

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
 
;;; guix-hydra-jobset.el --- Interface for Hydra jobsets  -*- lexical-binding: t -*-

;; Copyright © 2015 Alex Kost <alezost@gmail.com>

;; This file is part of GNU Guix.

;; GNU Guix is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.

;; GNU Guix is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with this program.  If not, see <http://www.gnu.org/licenses/>.

;;; Commentary:

;; This file provides an interface for displaying Hydra jobsets in
;; 'list' and 'info' buffers.

;;; Code:

(require 'cl-lib)
(require 'guix-buffer)
(require 'guix-list)
(require 'guix-info)
(require 'guix-hydra)
(require 'guix-hydra-build)
(require 'guix-utils)

(guix-hydra-define-entry-type hydra-jobset
  :search-types '((project . guix-hydra-jobset-api-url))
  :filters '(guix-hydra-jobset-filter-id)
  :filter-names '((nrscheduled . scheduled)
                  (nrsucceeded . succeeded)
                  (nrfailed . failed)
                  (nrtotal . total)))

(defun guix-hydra-jobset-get-display (search-type &rest args)
  "Search for Hydra builds and show results."
  (apply #'guix-list-get-display-entries
         'hydra-jobset search-type args))

\f
;;; Defining URLs

(defun guix-hydra-jobset-url (project jobset)
  "Return Hydra URL of a PROJECT's JOBSET."
  (guix-hydra-url "jobset/" project "/" jobset))

(defun guix-hydra-jobset-api-url (project)
  "Return Hydra API URL for jobsets by PROJECT."
  (guix-hydra-api-url "jobsets"
    `(("project" . ,project))))

\f
;;; Filters for processing raw entries

(defun guix-hydra-jobset-filter-id (entry)
  "Add 'ID' parameter to 'hydra-jobset' ENTRY."
  (cons `(id . ,(guix-entry-value entry 'name))
        entry))

\f
;;; Hydra jobset 'info'

(guix-hydra-info-define-interface hydra-jobset
  :mode-name "Hydra-Jobset-Info"
  :buffer-name "*Guix Hydra Jobset Info*"
  :format '((name ignore (simple guix-info-heading))
            ignore
            guix-hydra-jobset-info-insert-url
            (project   format guix-hydra-jobset-info-insert-project)
            (scheduled format (format guix-hydra-jobset-info-scheduled))
            (succeeded format (format guix-hydra-jobset-info-succeeded))
            (failed    format (format guix-hydra-jobset-info-failed))
            (total     format (format guix-hydra-jobset-info-total))))

(defface guix-hydra-jobset-info-scheduled
  '((t))
  "Face used for the number of scheduled builds."
  :group 'guix-hydra-jobset-info-faces)

(defface guix-hydra-jobset-info-succeeded
  '((t :inherit guix-hydra-build-status-succeeded))
  "Face used for the number of succeeded builds."
  :group 'guix-hydra-jobset-info-faces)

(defface guix-hydra-jobset-info-failed
  '((t :inherit guix-hydra-build-status-failed))
  "Face used for the number of failed builds."
  :group 'guix-hydra-jobset-info-faces)

(defface guix-hydra-jobset-info-total
  '((t))
  "Face used for the total number of builds."
  :group 'guix-hydra-jobset-info-faces)

(defun guix-hydra-jobset-info-insert-project (project entry)
  "Insert PROJECT button for the jobset ENTRY."
  (let ((jobset (guix-entry-value entry 'name)))
    (guix-insert-button
     project 'guix-hydra-build-project
     'action (lambda (btn)
               (let ((args (guix-hydra-build-latest-prompt-args
                            :project (button-get btn 'project)
                            :jobset  (button-get btn 'jobset))))
                 (apply #'guix-hydra-build-get-display
                        'latest args)))
     'project project
     'jobset jobset)))

(defun guix-hydra-jobset-info-insert-url (entry)
  "Insert Hydra URL for the jobset ENTRY."
  (guix-insert-button (guix-hydra-jobset-url
                       (guix-entry-value entry 'project)
                       (guix-entry-value entry 'name))
                      'guix-url))

\f
;;; Hydra jobset 'list'

(guix-hydra-list-define-interface hydra-jobset
  :mode-name "Hydra-Jobset-List"
  :buffer-name "*Guix Hydra Jobset List*"
  :format '((name nil 25 t)
            (project nil 10 t)
            (scheduled nil 12 t)
            (succeeded nil 12 t)
            (failed nil 9 t)
            (total nil 10 t)))

(let ((map guix-hydra-jobset-list-mode-map))
  (define-key map (kbd "B") 'guix-hydra-jobset-list-latest-builds))

(defun guix-hydra-jobset-list-latest-builds (number &rest args)
  "Display latest NUMBER of Hydra builds of the current jobset.
Interactively, prompt for NUMBER.  With prefix argument, prompt
for all ARGS."
  (interactive
   (let ((entry (guix-list-current-entry)))
     (guix-hydra-build-latest-prompt-args
      :project (guix-entry-value entry 'project)
      :jobset  (guix-entry-value entry 'name))))
  (apply #'guix-hydra-latest-builds number args))

\f
;;; Interactive commands

;;;###autoload
(defun guix-hydra-jobsets (project)
  "Display jobsets of PROJECT."
  (interactive (list (guix-hydra-read-project)))
  (guix-hydra-jobset-get-display 'project project))

(provide 'guix-hydra-jobset)

;;; guix-hydra-jobset.el ends here

debug log:

solving a4a55a3 ...
found a4a55a3 in https://git.savannah.gnu.org/cgit/guix.git

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).