From patchwork Sun Jul 17 14:50:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ludovic_Court=C3=A8s?= X-Patchwork-Id: 3781 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 82A8927BBEA; Sun, 17 Jul 2022 15:51:22 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,SPF_HELO_PASS autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 0E43227BBE9 for ; Sun, 17 Jul 2022 15:51:22 +0100 (BST) Received: from localhost ([::1]:39028 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oD5c9-0003Ny-5s for patchwork@mira.cbaines.net; Sun, 17 Jul 2022 10:51:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46056) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oD5bs-0003NR-5P for guix-patches@gnu.org; Sun, 17 Jul 2022 10:51:05 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:50536) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oD5bq-0004yF-O7 for guix-patches@gnu.org; Sun, 17 Jul 2022 10:51:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oD5bq-0003ke-Hs for guix-patches@gnu.org; Sun, 17 Jul 2022 10:51:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#56616] [PATCH] deploy: Honor '--dry-run'. Resent-From: Ludovic =?utf-8?q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 17 Jul 2022 14:51:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 56616 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 56616@debbugs.gnu.org Cc: Ludovic =?utf-8?q?Court=C3=A8s?= X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.165806943114376 (code B ref -1); Sun, 17 Jul 2022 14:51:02 +0000 Received: (at submit) by debbugs.gnu.org; 17 Jul 2022 14:50:31 +0000 Received: from localhost ([127.0.0.1]:48295 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oD5bL-0003jn-D9 for submit@debbugs.gnu.org; Sun, 17 Jul 2022 10:50:31 -0400 Received: from lists.gnu.org ([209.51.188.17]:54352) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oD5bK-0003jg-2S for submit@debbugs.gnu.org; Sun, 17 Jul 2022 10:50:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45948) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oD5bJ-0003CI-Gu for guix-patches@gnu.org; Sun, 17 Jul 2022 10:50:29 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:46860) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oD5bI-0004uO-DA; Sun, 17 Jul 2022 10:50:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:Date:Subject:To:From:in-reply-to: references; bh=f8lc3Bj6F+n/rAftTW4OtTN+s9eSvYaU5wdN91HOj1w=; b=MX25IiP43WWS3J A/jSamrRZL4E2W83cnwEavV+57Wv3aU3uvLLyx8xsOH9Wy2lkq9l9upempHYsW+ELMDBjq4RUH+Os 14mFM3FuQuSMtQeCEUcE9Y3SDqGGxgRQvV9Yb68IEr59/4I4X5eProox5ITrgoWxpLAHDpdyvugqU In2qv38uJICtKW7F6knlWSeqDC5nnGE9U/ySBQPhRJ/OIWErVwRSS/ReSEqgdY2zi0iwZh29t1tnA Omn9gInTUmb0p8j6CfiFC8i5IO2otOjaguCBsAHAVv5eZE0eJONhSQQsi1uQrfnoD0kA64KHp48Jl UNKZUar54ZS0CzeYSnQA==; Received: from 91-160-117-201.subs.proxad.net ([91.160.117.201]:62710 helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oD5bI-0001Q5-16; Sun, 17 Jul 2022 10:50:28 -0400 From: Ludovic =?utf-8?q?Court=C3=A8s?= Date: Sun, 17 Jul 2022 16:50:21 +0200 Message-Id: <20220717145021.19613-1-ludo@gnu.org> X-Mailer: git-send-email 2.36.1 MIME-Version: 1.0 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+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches * guix/scripts/deploy.scm (%options): Add "dry-run". (show-what-to-deploy): Add #:dry-run? and honor it. (guix-deploy): Honor --dry-run. --- guix/scripts/deploy.scm | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) Hi! ‘guix deploy --help’ would advertise ‘--dry-run’ but it wasn’t actually implemented. This patch fixes that. Note that ‘--dry-run’ doesn’t go beyond loading the deploy file. In particular, it doesn’t attempt to build anything because that is left to backends such as (gnu machine ssh). Thoughts? Ludo’. base-commit: 4ce7f1fb24a111f3e92d5b889d1271bebf109d09 diff --git a/guix/scripts/deploy.scm b/guix/scripts/deploy.scm index 27478eabc0..2c76645173 100644 --- a/guix/scripts/deploy.scm +++ b/guix/scripts/deploy.scm @@ -76,6 +76,9 @@ (define %options (lambda args (show-version-and-exit "guix deploy"))) + (option '(#\n "dry-run") #f #f + (lambda (opt name arg result) + (alist-cons 'dry-run? #t result))) (option '(#\x "execute") #f #f (lambda (opt name arg result) (alist-cons 'execute-command? #t result))) @@ -110,14 +113,20 @@ (module (make-user-module (append '((gnu) (gnu machine)) environment-modules)))) (load* file module))) -(define (show-what-to-deploy machines) +(define* (show-what-to-deploy machines #:key (dry-run? #f)) "Show the list of machines to deploy, MACHINES." (let ((count (length machines))) - (format (current-error-port) - (N_ "The following ~d machine will be deployed:~%" - "The following ~d machines will be deployed:~%" + (if dry-run? + (format (current-error-port) + (N_ "The following ~d machine would be deployed:~%" + "The following ~d machines would be deployed:~%" + count) count) - count) + (format (current-error-port) + (N_ "The following ~d machine will be deployed:~%" + "The following ~d machines will be deployed:~%" + count) + count)) (display (indented-string (fill-paragraph (string-join (map machine-display-name machines) ", ") @@ -241,6 +250,7 @@ (define (handle-argument arg result) #:argument-handler handle-argument)) (file (assq-ref opts 'file)) (machines (and file (load-source-file file))) + (dry-run? (assoc-ref opts 'dry-run?)) (execute-command? (assoc-ref opts 'execute-command?))) (unless file (leave (G_ "missing deployment file argument~%"))) @@ -254,7 +264,8 @@ (define (handle-argument arg result) (with-build-handler (build-notifier #:use-substitutes? (assoc-ref opts 'substitutes?) #:verbosity - (assoc-ref opts 'verbosity)) + (assoc-ref opts 'verbosity) + #:dry-run? dry-run?) (parameterize ((%graft? (assq-ref opts 'graft?))) (if execute-command? (match command @@ -270,7 +281,8 @@ (define (handle-argument arg result) (_ (leave (G_ "'-x' specified but no command given~%")))) (begin - (show-what-to-deploy machines) - (map/accumulate-builds store - (cut deploy-machine* store <>) - machines)))))))))) + (show-what-to-deploy machines #:dry-run? dry-run?) + (unless dry-run? + (map/accumulate-builds store + (cut deploy-machine* store <>) + machines)))))))))))