From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id MBttGiIOBmTYGAEASxT56A (envelope-from ) for ; Mon, 06 Mar 2023 17:00:34 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id 4Ix4GiIOBmTNUwEAauVa8A (envelope-from ) for ; Mon, 06 Mar 2023 17:00:34 +0100 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 53A4C16C34 for ; Mon, 6 Mar 2023 17:00:34 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pZDFs-0000OQ-OV; Mon, 06 Mar 2023 11:00:04 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pZDFr-0000O4-2v for guix-patches@gnu.org; Mon, 06 Mar 2023 11:00:03 -0500 Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pZDFq-0006tC-HK for guix-patches@gnu.org; Mon, 06 Mar 2023 11:00:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pZDFq-0004QT-Ao for guix-patches@gnu.org; Mon, 06 Mar 2023 11:00:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#61970] [PATCH] lint: Return exit code 1 if there are warnings. Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 06 Mar 2023 16:00:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 61970 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Antero Mejr Cc: 61970@debbugs.gnu.org Received: via spool by 61970-submit@debbugs.gnu.org id=B61970.167811837216942 (code B ref 61970); Mon, 06 Mar 2023 16:00:02 +0000 Received: (at 61970) by debbugs.gnu.org; 6 Mar 2023 15:59:32 +0000 Received: from localhost ([127.0.0.1]:43411 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pZDFL-0004PA-Qm for submit@debbugs.gnu.org; Mon, 06 Mar 2023 10:59:32 -0500 Received: from eggs.gnu.org ([209.51.188.92]:43292) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pZDFJ-0004Ot-PC for 61970@debbugs.gnu.org; Mon, 06 Mar 2023 10:59:30 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pZDFD-0006p3-39; Mon, 06 Mar 2023 10:59:23 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:In-Reply-To:Date:References:Subject:To: From; bh=eb+HayWyhJOaH7MsDXHHg/lHnj7xhkUxpz4qlhHXQ4c=; b=IZ5Y7/pTrxYcswC/0sdm Uv5SpGFyvUnheUxTv55rLQbVfGuM9gOQ9OweAvh7YmCHIvd3sNsn9uUKooMlIm3O4QZwViUK4JKzI 4H/2q/HRxcZn0rS7y1VUGWlgMWOPv+aSlEF+CyV0fjAw/ydSHGJu9hUDfhKm/dLULrCjfJAV22K1X VykUF2FtDX7hUL+kTqaF9miLeK+WOin/TEjMZj075i/kOpZC3VpEaU9Y/jCXfs/li830JQigk52jA C1OUg+z0FhQwHEk8UkP2sHdbZ5xYArJEa+7Tgdl4hI7teIeaAm8mHRyyRyZ8fb9wvv+E4ZEbvSyTe SaK0e1k7F3eBwQ==; Received: from [193.50.110.138] (helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pZDFC-0007tn-MU; Mon, 06 Mar 2023 10:59:22 -0500 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= References: <20230304231601.13352-1-antero@mailbox.org> X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: Sextidi 16 =?UTF-8?Q?Vent=C3=B4se?= an 231 de la =?UTF-8?Q?R=C3=A9volution,?= jour de =?UTF-8?Q?l'=C3=89pinard?= X-PGP-Key-ID: 0x090B11993D9AEBB5 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4 0CFB 090B 1199 3D9A EBB5 X-OS: x86_64-pc-linux-gnu Date: Mon, 06 Mar 2023 16:59:20 +0100 In-Reply-To: <20230304231601.13352-1-antero@mailbox.org> (Antero Mejr's message of "Sat, 4 Mar 2023 23:16:01 +0000") Message-ID: <87cz5lan1j.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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-bounces+larch=yhetil.org@gnu.org X-TUID: IV6EQQRut3qV Hi, Antero Mejr skribis: > * guix/scripts/lint.scm (guix-lint, run-checkers): Modify procedure. Please expound a little bit. :-) Could you also add a sentence under =E2=80=9CInvoking guix lint=E2=80=9D 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=E2=80=99re just warnings, which is why =E2=80=98guix lint=E2=80=99 alw= ays 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]...\x= 1b[K\r" > - (package-name package) (package-version packag= e) > - (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 packa= ge) > + (lint-checker-name checker)) > + (force-output (current-error-port))) > + (let ((results (if (lint-checker-requires-store? checke= r) > + ((lint-checker-check checker) package > + #:store store) > + ((lint-checker-check checker) packag= e)))) > + (emit-warnings results) > + results)) > + checkers))) For clarity I would separate warning collection from warning printing. So: (let ((tty? =E2=80=A6) (warnings (append-map (lambda (checker) =E2=80=A6) checkers))) (for-each (lambda (warning) =E2=80=A6) 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=E2=80=99d suggest something similar here. Could you send an updated patch? Thanks, Ludo=E2=80=99.