From: Christopher Baines <mail@cbaines.net>
To: 38754@debbugs.gnu.org
Subject: [bug#38754] [PATCH 4/4] scripts: lint: Handle store connections for lint checkers.
Date: Sun, 15 Mar 2020 21:06:31 +0000 [thread overview]
Message-ID: <20200315210631.5334-4-mail@cbaines.net> (raw)
In-Reply-To: <20200315210631.5334-1-mail@cbaines.net>
Rather than individual checkers opening up a connection to the store for each
package to check, if any checker requires a store connection, open a
connection and pass it to all checkers that would use it. This makes running
the derivation checker much faster for multiple packages.
* guix/scripts/lint.scm (run-checkers): Add a #:store argument, and pass the
store to checkers if they require a store connection.
(guix-lint): Establish a store connection if any checker requires one, and
pass it through to run-checkers.
---
guix/scripts/lint.scm | 38 ++++++++++++++++++++++++++++----------
1 file changed, 28 insertions(+), 10 deletions(-)
diff --git a/guix/scripts/lint.scm b/guix/scripts/lint.scm
index 8d08c484f5..97ffd57301 100644
--- a/guix/scripts/lint.scm
+++ b/guix/scripts/lint.scm
@@ -30,6 +30,7 @@
#:use-module (guix packages)
#:use-module (guix lint)
#:use-module (guix ui)
+ #:use-module (guix store)
#:use-module (guix scripts)
#:use-module (guix scripts build)
#:use-module (gnu packages)
@@ -53,7 +54,7 @@
(lint-warning-message lint-warning))))
warnings))
-(define (run-checkers package checkers)
+(define* (run-checkers package checkers #:key store)
"Run the given CHECKERS on PACKAGE."
(let ((tty? (isatty? (current-error-port))))
(for-each (lambda (checker)
@@ -63,7 +64,9 @@
(lint-checker-name checker))
(force-output (current-error-port)))
(emit-warnings
- ((lint-checker-check checker) package)))
+ (if (lint-checker-requires-store? checker)
+ ((lint-checker-check checker) package #:store store)
+ ((lint-checker-check checker) package))))
checkers)
(when tty?
(format (current-error-port) "\x1b[K")
@@ -167,12 +170,27 @@ run the checkers on all packages.\n"))
(_ #f))
(reverse opts)))
(checkers (or (assoc-ref opts 'checkers) %all-checkers)))
- (cond
- ((assoc-ref opts 'list?)
+
+ (when (assoc-ref opts 'list?)
(list-checkers-and-exit checkers))
- ((null? args)
- (fold-packages (lambda (p r) (run-checkers p checkers)) '()))
- (else
- (for-each (lambda (spec)
- (run-checkers (specification->package spec) checkers))
- args)))))
+
+ (let ((any-lint-checker-requires-store?
+ (any lint-checker-requires-store? checkers)))
+
+ (define (call-maybe-with-store proc)
+ (if any-lint-checker-requires-store?
+ (with-store store
+ (proc store))
+ (proc #f)))
+
+ (call-maybe-with-store
+ (lambda (store)
+ (cond
+ ((null? args)
+ (fold-packages (lambda (p r) (run-checkers p checkers
+ #:store store)) '()))
+ (else
+ (for-each (lambda (spec)
+ (run-checkers (specification->package spec) checkers
+ #:store store))
+ args))))))))
--
2.25.0
next prev parent reply other threads:[~2020-03-15 21:07 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-26 17:33 [bug#38754] [PATCH 0/2] Speed up the derivation linter Christopher Baines
2019-12-26 18:01 ` [bug#38754] [PATCH 1/2] guix: lint: Add an optional parameter for a store connection Christopher Baines
2019-12-26 18:01 ` [bug#38754] [PATCH 2/2] scripts: lint: Set the %link-checker-store-connection parameter Christopher Baines
2019-12-30 22:12 ` Ludovic Courtès
2019-12-30 23:34 ` Christopher Baines
2019-12-31 18:15 ` Ludovic Courtès
2020-03-15 21:06 ` [bug#38754] [PATCH 1/4] lint: Add a requires-store? field to the checker record Christopher Baines
2020-03-15 21:06 ` [bug#38754] [PATCH 2/4] lint: Mark the derivation checker as requiring a store connection Christopher Baines
2020-03-15 21:06 ` [bug#38754] [PATCH 3/4] lint: Add a #:store argument to check-derivation Christopher Baines
2020-03-15 21:06 ` Christopher Baines [this message]
2020-03-15 21:35 ` [bug#38754] [PATCH 2/2] scripts: lint: Set the %link-checker-store-connection parameter Christopher Baines
2020-03-24 10:20 ` Ludovic Courtès
2020-03-24 19:50 ` bug#38754: " Christopher Baines
2019-12-30 22:01 ` [bug#38754] [PATCH 0/2] Speed up the derivation linter 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=20200315210631.5334-4-mail@cbaines.net \
--to=mail@cbaines.net \
--cc=38754@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).