From patchwork Sat Mar 4 23:16:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antero Mejr X-Patchwork-Id: 47666 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 C05BA16D2A; Sat, 4 Mar 2023 23:18:24 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-1.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,URIBL_BLOCKED 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 C695E16B8B for ; Sat, 4 Mar 2023 23:18:19 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pYb8e-0004dM-Lo; Sat, 04 Mar 2023 18:18: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 1pYb8d-0004dC-72 for guix-patches@gnu.org; Sat, 04 Mar 2023 18:18: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 1pYb8c-0003ec-SV; Sat, 04 Mar 2023 18:18:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pYb8c-0000Ev-6g; Sat, 04 Mar 2023 18:18:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#61970] [PATCH] lint: Return exit code 1 if there are warnings. Resent-From: Antero Mejr Original-Sender: "Debbugs-submit" Resent-CC: ludo@gnu.org, guix-patches@gnu.org Resent-Date: Sat, 04 Mar 2023 23:18:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 61970 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 61970@debbugs.gnu.org Cc: Antero Mejr , ludo@gnu.org X-Debbugs-Original-To: guix-patches@gnu.org X-Debbugs-Original-Xcc: ludo@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.1677971832847 (code B ref -1); Sat, 04 Mar 2023 23:18:02 +0000 Received: (at submit) by debbugs.gnu.org; 4 Mar 2023 23:17:12 +0000 Received: from localhost ([127.0.0.1]:38043 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pYb7o-0000Db-5e for submit@debbugs.gnu.org; Sat, 04 Mar 2023 18:17:12 -0500 Received: from lists.gnu.org ([209.51.188.17]:45176) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pYb7m-0000DS-2G for submit@debbugs.gnu.org; Sat, 04 Mar 2023 18:17:10 -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 1pYb7g-0004Zg-8j for guix-patches@gnu.org; Sat, 04 Mar 2023 18:17:09 -0500 Received: from mout-p-102.mailbox.org ([80.241.56.152]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_CHACHA20_POLY1305:256) (Exim 4.90_1) (envelope-from ) id 1pYb7B-0003Zu-2A for guix-patches@gnu.org; Sat, 04 Mar 2023 18:17:02 -0500 Received: from smtp202.mailbox.org (smtp202.mailbox.org [10.196.197.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-102.mailbox.org (Postfix) with ESMTPS id 4PTgh25khzz9sW7 for ; Sun, 5 Mar 2023 00:16:18 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677971778; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=6eDjGwIdi718QT6KN2Edn84b83slSfGtCj4M7AKTelg=; b=T7bKV7u7+A2BsMCL9KeFQoq4FFm832gcU/zptFmlCuMz5kGVPhRrn3hm0f3tLMEvNeRDD8 XC6BYFixzzWNnNeDhNWGUE9hH38hF4C8Lb1BRd5vrHGPST0GmFdNkXy//hozNjHYuAfFcn nUDeEFEcD7KtVevfoKr+LW/l7UQH861NgnZYs+rJvQG+SXd/vJ5mi1HSApyK1/zuBrlxf3 AMCbdgwFmP4J1P5zTNMb+MtyoWBGq4TnXbNdnMeE9Zjm/966lqD/8f9PZbRuo8+djhhD2Y QQR2MFIQo1hcv0cG8xK61UQnGFcCptKpiBfG1gMXe3NUIA4j3l88CLofII0WHQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677971776; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=6eDjGwIdi718QT6KN2Edn84b83slSfGtCj4M7AKTelg=; b=ykHwYvxAwB5/nie1T8/FLUkYeJdDcHPjhO4YwgKhhC/rZ9J8hTp+OKqfPzRtlBxCcXt2Mz ZesuiDQaloQGCRYOmtSVkWaH27YoXJtEEQEIHEqZmgsLhZPhHaW7EDwq1BLv4luQ2fFjwr hm0Gk/Gfhpy84jxWkDdGcUKFaIR8mPCYJthSXM38zXOtroxFnmc9fbOXOW52kUrxaCKtkp 4txWJwVXllpjsbrB3HKapr3wGTYk7X44BPWEIbr69nXofRx+kmFJFSJcrSYDp9K5G/Wuol tGUTVWO1CR11RqXFzQIhG8euUZLk1qc1FlnPei7j6XOnxqHMkfp4SCC6KepQXw== Date: Sat, 4 Mar 2023 23:16:01 +0000 Message-Id: <20230304231601.13352-1-antero@mailbox.org> MIME-Version: 1.0 X-MBO-RS-META: z8f1do8kxmn81d8hathq7kbew7i4p89y X-MBO-RS-ID: 6fa18e03f22b1c7db2d Received-SPF: pass client-ip=80.241.56.152; envelope-from=antero@mailbox.org; helo=mout-p-102.mailbox.org X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: , Reply-to: Antero Mejr X-ACL-Warn: , Antero Mejr via Guix-patches X-Patchwork-Original-From: Antero Mejr via Guix-patches via From: Antero Mejr Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * guix/scripts/lint.scm (guix-lint, run-checkers): Modify procedure. --- Exiting 1 makes it a lot easier to include a "guix lint" step in external CI pipelines. guix/scripts/lint.scm | 60 ++++++++++++++++++++++++++----------------- 1 file changed, 36 insertions(+), 24 deletions(-) diff --git a/guix/scripts/lint.scm b/guix/scripts/lint.scm index 9920c3ee62..a4bec357c7 100644 --- a/guix/scripts/lint.scm +++ b/guix/scripts/lint.scm @@ -61,21 +61,25 @@ (define (emit-warnings warnings) (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))) (when tty? (format (current-error-port) "\x1b[K") - (force-output (current-error-port))))) + (force-output (current-error-port))) + results)) (define (list-checkers-and-exit checkers) ;; Print information about all available checkers and exit. @@ -218,14 +222,22 @@ (define (call-maybe-with-store proc) (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 (package) - (run-checkers package checkers - #:store store)) - args))))))))) + (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))))))