From: "Ludovic Courtès" <ludo@gnu.org>
To: Antero Mejr <antero@mailbox.org>
Cc: 61970@debbugs.gnu.org
Subject: [bug#61970] [PATCH] lint: Return exit code 1 if there are warnings.
Date: Mon, 06 Mar 2023 16:59:20 +0100 [thread overview]
Message-ID: <87cz5lan1j.fsf@gnu.org> (raw)
In-Reply-To: <20230304231601.13352-1-antero@mailbox.org> (Antero Mejr's message of "Sat, 4 Mar 2023 23:16:01 +0000")
Hi,
Antero Mejr <antero@mailbox.org> skribis:
> * guix/scripts/lint.scm (guix-lint, run-checkers): Modify procedure.
Please expound a little bit. :-)
Could you also add a sentence under “Invoking guix lint” in the manual?
> Exiting 1 makes it a lot easier to include a "guix lint" step in external
> CI pipelines.
Yeah, though some lint warnings are more critical than others, and often
they’re just warnings, which is why ‘guix lint’ always returned zero so
far.
> (define* (run-checkers package checkers #:key store)
> "Run the given CHECKERS on PACKAGE."
> - (let ((tty? (isatty? (current-error-port))))
> - (for-each (lambda (checker)
> - (when tty?
> - (format (current-error-port) "checking ~a@~a [~a]...\x1b[K\r"
> - (package-name package) (package-version package)
> - (lint-checker-name checker))
> - (force-output (current-error-port)))
> - (emit-warnings
> - (if (lint-checker-requires-store? checker)
> - ((lint-checker-check checker) package #:store store)
> - ((lint-checker-check checker) package))))
> - checkers)
> + (let* ((tty? (isatty? (current-error-port)))
> + (results
> + (map (lambda (checker)
> + (when tty?
> + (format (current-error-port) "checking ~a@~a [~a]...\x1b[K\r"
> + (package-name package) (package-version package)
> + (lint-checker-name checker))
> + (force-output (current-error-port)))
> + (let ((results (if (lint-checker-requires-store? checker)
> + ((lint-checker-check checker) package
> + #:store store)
> + ((lint-checker-check checker) package))))
> + (emit-warnings results)
> + results))
> + checkers)))
For clarity I would separate warning collection from warning printing.
So:
(let ((tty? …)
(warnings (append-map (lambda (checker) …) checkers)))
(for-each (lambda (warning) …) warnings)
(null? warnings)) ;return #t when WARNINGS is empty
> + (define (null?-rec lst)
> + (if (list? lst)
> + (not (member #f (map null?-rec lst)))
> + #f))
> +
> + (if (null?-rec
> + (call-maybe-with-store
> + (lambda (store)
> + (cond
> + ((null? args)
> + (fold-packages (lambda (p r)
> + (cons (run-checkers p checkers
> + #:store store) r)) '()))
> + (else
> + (map (lambda (package)
> + (run-checkers package checkers #:store store))
> + args))))))
> + (exit 0)
> + (exit 1))))))
I’d suggest something similar here.
Could you send an updated patch?
Thanks,
Ludo’.
next prev parent reply other threads:[~2023-03-06 16:00 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-04 23:16 [bug#61970] [PATCH] lint: Return exit code 1 if there are warnings Antero Mejr via Guix-patches via
2023-03-06 15:59 ` Ludovic Courtès [this message]
2024-07-24 12:49 ` Simon Tournier
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87cz5lan1j.fsf@gnu.org \
--to=ludo@gnu.org \
--cc=61970@debbugs.gnu.org \
--cc=antero@mailbox.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 external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.