From: "Ludovic Courtès" <ludo@gnu.org>
To: 56616@debbugs.gnu.org
Cc: "Ludovic Courtès" <ludo@gnu.org>
Subject: [bug#56616] [PATCH] deploy: Honor '--dry-run'.
Date: Sun, 17 Jul 2022 16:50:21 +0200 [thread overview]
Message-ID: <20220717145021.19613-1-ludo@gnu.org> (raw)
* 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’.
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)))))))))))
base-commit: 4ce7f1fb24a111f3e92d5b889d1271bebf109d09
--
2.36.1
next reply other threads:[~2022-07-17 15:25 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-17 14:50 Ludovic Courtès [this message]
2022-07-21 18:03 ` [bug#56616] [PATCH] deploy: Honor '--dry-run' Maxime Devos
2022-07-22 12:15 ` Ludovic Courtès
2022-07-22 12:18 ` Maxime Devos
2022-07-22 20:56 ` Ludovic Courtès
2022-07-22 22:42 ` bug#56616: " Ludovic Courtès
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220717145021.19613-1-ludo@gnu.org \
--to=ludo@gnu.org \
--cc=56616@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).