From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id wE7fOUuSCmBFNgAA0tVLHw (envelope-from ) for ; Fri, 22 Jan 2021 08:52:27 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id CJWWNUuSCmC8cQAAbx9fmQ (envelope-from ) for ; Fri, 22 Jan 2021 08:52:27 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 0529C9403E8 for ; Fri, 22 Jan 2021 08:52:26 +0000 (UTC) Received: from localhost ([::1]:54596 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l2sB7-00034P-Qe for larch@yhetil.org; Fri, 22 Jan 2021 03:52:25 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57814) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l2sAk-00033c-V3 for guix-patches@gnu.org; Fri, 22 Jan 2021 03:52:02 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:48442) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l2sAk-0004tR-NU for guix-patches@gnu.org; Fri, 22 Jan 2021 03:52:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1l2sAk-00027w-LI for guix-patches@gnu.org; Fri, 22 Jan 2021 03:52:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#46031] services: cuirass: Add "simple-cuirass-services". Resent-From: Mathieu Othacehe Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 22 Jan 2021 08:52:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 46031 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: To: 46031@debbugs.gnu.org X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.16113054778116 (code B ref -1); Fri, 22 Jan 2021 08:52:02 +0000 Received: (at submit) by debbugs.gnu.org; 22 Jan 2021 08:51:17 +0000 Received: from localhost ([127.0.0.1]:59988 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l2sA0-00026p-Rb for submit@debbugs.gnu.org; Fri, 22 Jan 2021 03:51:17 -0500 Received: from lists.gnu.org ([209.51.188.17]:48528) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l2s9k-00026A-ER for submit@debbugs.gnu.org; Fri, 22 Jan 2021 03:51:15 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57400) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l2s9k-0002ut-6k for guix-patches@gnu.org; Fri, 22 Jan 2021 03:51:00 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]:59930) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l2s9i-0004Fi-PT for guix-patches@gnu.org; Fri, 22 Jan 2021 03:50:59 -0500 Received: from [2a01:e0a:19b:d9a0:98b7:b002:9499:5e2c] (port=53170 helo=cervin) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1l2s9i-0006SI-CJ for guix-patches@gnu.org; Fri, 22 Jan 2021 03:50:58 -0500 From: Mathieu Othacehe Date: Fri, 22 Jan 2021 09:50:56 +0100 Message-ID: <87czxxz767.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: -2.85 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Queue-Id: 0529C9403E8 X-Spam-Score: -2.85 X-Migadu-Scanner: scn1.migadu.com X-TUID: I4O73dlPSM1/ --=-=-= Content-Type: text/plain Hello, Here is a service that provides some syntactic sugar over the (complex) Cuirass configuration. It uses Guix Channels to declare Cuirass inputs. In the future, it would be nice if Cuirass could operate directly on Channels. For now, this service only act as a translation layer for people willing to setup a simple Cuirass instance. Thanks, Mathieu --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-services-cuirass-Add-simple-cuirass-services.patch >From 14186c2d6ad7dd5a55f35b1364f34669c1e27a5e Mon Sep 17 00:00:00 2001 From: Mathieu Othacehe Date: Fri, 22 Jan 2021 09:44:45 +0100 Subject: [PATCH] services: cuirass: Add "simple-cuirass-services". * gnu/services/cuirass.scm (, ): New records. (build-manifest, build-manifest?, simple-cuirass-configuration, simple-cuirass-configuration?, simple-cuirass-services): New procedures. (%default-cuirass-config): New variable. * doc/guix.texi (Continuous Integration): Document it. Signed-off-by: Mathieu Othacehe --- doc/guix.texi | 102 ++++++++++++++++++++++++++++++++++++++ gnu/services/cuirass.scm | 103 ++++++++++++++++++++++++++++++++++++++- 2 files changed, 204 insertions(+), 1 deletion(-) diff --git a/doc/guix.texi b/doc/guix.texi index 13d95b36d1..8982ad82f5 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -26010,6 +26010,108 @@ The Cuirass package to use. @end table @end deftp +@cindex simple cuirass +@subsubheading Simple Cuirass + +The Cuirass service configuration described above can be a little +intimidating. The @code{simple-cuirass-services} procedure offers a way +to setup a continuous integration server more readily. + +It takes a @code{simple-cuirass-configuration} record as its first +argument. + +@deftp {Data Type} simple-cuirass-configuration +Data type representing the configuration of a simple Cuirass instance. + +@table @asis +@item @code{build} (default: @code{'all}) +The packages to be built by Cuirass. It defaults to @code{'all}, which +means that all the discovered packages in the subsequent @code{channels} +field are to be selected. + +It is also possible to set this field to a list of @code{build-manifest} +records, so that only the packages that are part of the declared +manifests are built. This record is described below. + +@deftp {Data Type} build-manifest +@table @asis +@item @code{channel-name} +The name of the channel where the manifest is located. + +@item @code{manifest} +The manifest path inside the channel. + +@end table +@end deftp + +@item @code{channels} (default: @code{%default-channels}) +The channels to be fetched by Cuirass, see @pxref{Channels}. + +@item @code{non-package-channels} (default: @code{'()}) +List the channel names that must not be searched for packages. That is +often the case for the channel containing the manifest. + +@item @code{systems} (default: @code{(list (%current-system))}) +Build every discovered package for each system in this list. By default +only the current system is selected. + +@end table +@end deftp + +Here is an example of how to setup a Cuirass instance that builds all +the packages declared by Guix and a user repository. The package list +is re-evaluated each time a commit is pushed in one of the declared +channels. + +@lisp +(simple-cuirass-services + (simple-cuirass-configuration + (build 'all) + (channels (cons (channel + (name 'my-guix) + (url "https://my-git-repo/guix.git")) + %default-channels)))) +@end lisp + +In the same spirit, this builds all the packages that are part of the +@code{'guix} or @code{'my-guix} channels and declared in the manifest +located in the @code{'conf} channel. + +@lisp +(simple-cuirass-services + (simple-cuirass-configuration + (build (list + (build-manifest + (channel-name 'conf) + (manifest "guix/manifest.scm")))) + (channels (cons* (channel + (name 'my-guix) + (url "https://my-git-repo/guix.git")) + (channel + (name 'conf) + (url "https://my-git-repo/conf.git")) + %default-channels)) + (non-package-channels '(conf)))) +@end lisp + +Finally, @code{simple-cuirass-services} takes as a second optional +argument a @code{cuirass-configuration} record. It can be used to +customize the configuration of the Cuirass instance. + +@lisp +(simple-cuirass-services + (simple-cuirass-configuration + (build 'all) + (channels (cons (channel + (name 'my-guix) + (url "https://my-git-repo/guix.git")) + %default-channels)) + (non-package-channels '(conf))) + (cuirass-configuration + (inherit %default-cuirass-config) + (host "0.0.0.0"))) ;listen on all interfaces. +@end lisp + @node Power Management Services @subsection Power Management Services diff --git a/gnu/services/cuirass.scm b/gnu/services/cuirass.scm index f426b9a1a7..44b39cb78f 100644 --- a/gnu/services/cuirass.scm +++ b/gnu/services/cuirass.scm @@ -22,10 +22,13 @@ ;;; along with GNU Guix. If not, see . (define-module (gnu services cuirass) + #:use-module (guix channels) #:use-module (guix gexp) #:use-module (guix records) + #:use-module (guix utils) #:use-module (gnu packages admin) #:use-module (gnu packages ci) + #:use-module (gnu packages databases) #:use-module (gnu packages version-control) #:use-module (gnu services) #:use-module (gnu services base) @@ -33,6 +36,8 @@ #:use-module (gnu services shepherd) #:use-module (gnu services admin) #:use-module (gnu system shadow) + #:use-module (srfi srfi-1) + #:use-module (ice-9 match) #:export ( cuirass-remote-server-configuration cuirass-remote-server-configuration? @@ -45,7 +50,18 @@ cuirass-remote-worker-configuration cuirass-remote-worker-configuration? - cuirass-remote-worker-service-type)) + cuirass-remote-worker-service-type + + + build-manifest + build-manifest? + + + simple-cuirass-configuration + simple-cuirass-configuration? + + %default-cuirass-config + simple-cuirass-services)) ;;;; Commentary: ;;; @@ -338,3 +354,88 @@ CONFIG." cuirass-remote-worker-shepherd-service))) (description "Run the Cuirass remote build worker service."))) + +(define-record-type* + build-manifest make-build-manifest + build-manifest? + (channel-name build-manifest-channel-name) ;symbol + (manifest build-manifest-manifest)) ;string + +(define-record-type* + simple-cuirass-configuration make-simple-cuirass-configuration + simple-cuirass-configuration? + (build simple-cuirass-configuration-build + (default 'all)) ;symbol or list of + (channels simple-cuirass-configuration-channels + (default %default-channels)) ;list of + (non-package-channels simple-cuirass-configuration-package-channels + (default '())) ;list of channels name + (systems simple-cuirass-configuration-systems + (default (list (%current-system))))) ;list of strings + +(define %default-cuirass-config + (cuirass-configuration + (specifications #~()))) + +(define* (simple-cuirass-services config + #:optional + (cuirass %default-cuirass-config)) + (define (format-name name) + (if (string? name) + name + (symbol->string name))) + + (define (format-manifests build-manifests) + (map (lambda (build-manifest) + (match-record build-manifest + (channel-name manifest) + (cons (format-name channel-name) manifest))) + build-manifests)) + + (define (channel->input channel) + (let ((name (channel-name channel)) + (url (channel-url channel)) + (branch (channel-branch channel))) + `((#:name . ,(format-name name)) + (#:url . ,url) + (#:load-path . ".") + (#:branch . ,branch) + (#:no-compile? #t)))) + + (define (package-path channels non-package-channels) + (filter-map (lambda (channel) + (let ((name (channel-name channel))) + (and (not (member name non-package-channels)) + (not (eq? name 'guix)) + (format-name name)))) + channels)) + + (define (config->spec config) + (match-record config + (build channels non-package-channels systems) + `((#:name . "simple-config") + (#:load-path-inputs . ("guix")) + (#:package-path-inputs . ,(package-path channels + non-package-channels)) + (#:proc-input . "guix") + (#:proc-file . "build-aux/cuirass/gnu-system.scm") + (#:proc . cuirass-jobs) + (#:proc-args . ((systems . ,systems) + ,@(if (eq? build 'all) + '() + `((subset . "manifests") + (manifests . ,(format-manifests build)))))) + (#:inputs . ,(map channel->input channels)) + (#:build-outputs . ()) + (#:priority . 1)))) + + (list + (service cuirass-service-type + (cuirass-configuration + (inherit cuirass) + (specifications #~(list + '#$(config->spec config))))) + (service postgresql-service-type + (postgresql-configuration + (postgresql postgresql-10))) + (service postgresql-role-service-type))) -- 2.29.2 --=-=-=--