From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id gjSQFmsWol+8SAAA0tVLHw (envelope-from ) for ; Wed, 04 Nov 2020 02:48:11 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id gPjyEWsWol8lSwAAB5/wlQ (envelope-from ) for ; Wed, 04 Nov 2020 02:48:11 +0000 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 6AC289405D3 for ; Wed, 4 Nov 2020 02:48:10 +0000 (UTC) Received: from localhost ([::1]:53362 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ka8qH-0007bz-CS for larch@yhetil.org; Tue, 03 Nov 2020 21:48:09 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:58376) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ka8qA-0007bo-9S for guix-patches@gnu.org; Tue, 03 Nov 2020 21:48:02 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:35400) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ka8q9-0003XX-Ut for guix-patches@gnu.org; Tue, 03 Nov 2020 21:48:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ka8q9-0005uA-T1 for guix-patches@gnu.org; Tue, 03 Nov 2020 21:48:01 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#44427] [PATCH] lint: Add 'check-haskell-stackage' checker. Resent-From: Timothy Sample Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 04 Nov 2020 02:48:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 44427 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 44427@debbugs.gnu.org X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.160445807822687 (code B ref -1); Wed, 04 Nov 2020 02:48:01 +0000 Received: (at submit) by debbugs.gnu.org; 4 Nov 2020 02:47:58 +0000 Received: from localhost ([127.0.0.1]:46946 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ka8q0-0005tm-FH for submit@debbugs.gnu.org; Tue, 03 Nov 2020 21:47:58 -0500 Received: from lists.gnu.org ([209.51.188.17]:42124) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ka8py-0005te-8w for submit@debbugs.gnu.org; Tue, 03 Nov 2020 21:47:51 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:58298) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ka8py-0007Zk-1I for guix-patches@gnu.org; Tue, 03 Nov 2020 21:47:50 -0500 Received: from out1-smtp.messagingengine.com ([66.111.4.25]:55013) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ka8pv-0003Ut-Da for guix-patches@gnu.org; Tue, 03 Nov 2020 21:47:49 -0500 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 6E22B5C012B for ; Tue, 3 Nov 2020 21:47:46 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Tue, 03 Nov 2020 21:47:46 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:message-id :mime-version:subject:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; bh=05gS8+rvq7JXOvRZ9bSKwM6LBIyS2 BcjBn/dWAM/V08=; b=ICb0p+7upgD+nGRUYFcIMuXmoBjdYCDUdem2v+cut7M5S PiQOrZKULMlSRdeLKgy+GiFnGwitcge9TA6YrRbwnaVCSeVlTVLg6ojaTXrakB4X nvSp2n1eCwpXc4UEDI9h1hqg7gJYYrmm+/YMJjpiNa0ByxIfKiVZ3O1Ve+cJGnsi syV9S1+ZnRazEiFCpYpGVvOCaWTcIYifjEbrQK8fk/koWZW0sHMdjTWGUnzVO7AB kKhPqE9QZEtjR7OipClUczNsMYjYA+8kgFP9m/g5OchrLVRWI0pESDhpTKdxTgUg IZfyebb7iMY76hIU2VjRoBQkrQPKihpb7J5WhKyJQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedruddtgedggeelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkfgggtgesmhdtreertd erjeenucfhrhhomhepvfhimhhothhhhicuufgrmhhplhgvuceoshgrmhhplhgvthesnhhg hihrohdrtghomheqnecuggftrfgrthhtvghrnhepvdelledvieffffdufefhfffhkeekgf fgfedtudeghfdugedtkeelgfegffelvddtnecukfhppeejgedrudduiedrudekiedrgeeg necuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepshgrmh hplhgvthesnhhghihrohdrtghomh X-ME-Proxy: Received: from mrblack (74-116-186-44.qc.dsl.ebox.net [74.116.186.44]) by mail.messagingengine.com (Postfix) with ESMTPA id 2280B32802F0 for ; Tue, 3 Nov 2020 21:47:46 -0500 (EST) From: Timothy Sample Date: Tue, 03 Nov 2020 21:47:23 -0500 Message-ID: <87pn4ton2c.fsf@ngyro.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=66.111.4.25; envelope-from=samplet@ngyro.com; helo=out1-smtp.messagingengine.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 21:47:46 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_FILL_THIS_FORM_SHORT=0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.6 (-) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-Spam-Score: -0.3 (/) 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" X-Scanner: ns3122888.ip-94-23-21.eu Authentication-Results: aspmx1.migadu.com; dkim=fail (body hash did not verify) header.d=messagingengine.com header.s=fm1 header.b=ICb0p+7u; dmarc=none; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Spam-Score: -0.01 X-TUID: mcKQnYgVadjM --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hello! After the most recent issue with Haskell package versions, I was inspired to finally make it a bit better. This patch adds a lint checker to make sure that a Haskell package=E2=80=99s version is not ahead = of the desired Stackage LTS version! The check itself is nice and simple, but I also added a test that is anything but. To make the test work, I made sure our Hackage and Stackage importers use base URLs that are parameters. Then, I used =E2=80=98with-http-server= =E2=80=99 and =E2=80=98parameterize=E2=80=99d the URLs to use the local server. (This al= l follows the example of the SWH checker.) It might be clearer if the test were split in two, but the Stackage importer memoizes the list of packages sent from the Stackage server. That means that the two tests would have to be run in a certain order to work, which is pretty dodgy. Is the test too complicated to be worth it? I might be able to make it a little clearer, but I=E2=80=99m not sure it=E2=80=99s worth including at = all. Thoughts? -- Tim --=-=-= Content-Type: text/x-patch; charset=utf-8 Content-Disposition: attachment; filename=0001-lint-Add-check-haskell-stackage-checker.patch Content-Transfer-Encoding: quoted-printable >From 7e01e8adddeaba7a2c0b3a79425da26f3c2584df Mon Sep 17 00:00:00 2001 From: Timothy Sample Date: Tue, 3 Nov 2020 15:30:28 -0500 Subject: [PATCH] lint: Add 'check-haskell-stackage' checker. * guix/lint.scm (check-haskell-stackage): New procedure. (%network-dependent-checkers): Add 'haskell-stackage' checker. * guix/import/hackage.scm (%hackage-url): New variable. (hackage-source-url, hackage-cabal-url): Use it in place of a hard-coded string. * guix/import/stackage.scm (%stackage-url): Make it a parameter. (stackage-lts-info-fetch): Update accordingly. * tests/lint.scm ("hackage-stackage"): New test. --- guix/import/hackage.scm | 14 +++++++++----- guix/import/stackage.scm | 8 +++++--- guix/lint.scm | 28 +++++++++++++++++++++++++++- tests/lint.scm | 32 ++++++++++++++++++++++++++++++++ 4 files changed, 73 insertions(+), 9 deletions(-) diff --git a/guix/import/hackage.scm b/guix/import/hackage.scm index 35c67cad8d..6ca4f65cb0 100644 --- a/guix/import/hackage.scm +++ b/guix/import/hackage.scm @@ -40,7 +40,8 @@ #:use-module (guix upstream) #:use-module (guix packages) #:use-module ((guix utils) #:select (call-with-temporary-output-file)) - #:export (hackage->guix-package + #:export (%hackage-url + hackage->guix-package hackage-recursive-import %hackage-updater =20 @@ -92,20 +93,23 @@ =20 (define package-name-prefix "ghc-") =20 +(define %hackage-url + (make-parameter "https://hackage.haskell.org")) + (define (hackage-source-url name version) "Given a Hackage package NAME and VERSION, return a url to the source tarball." - (string-append "https://hackage.haskell.org/package/" name - "/" name "-" version ".tar.gz")) + (string-append (%hackage-url) "/package/" + name "/" name "-" version ".tar.gz")) =20 (define* (hackage-cabal-url name #:optional version) "Given a Hackage package NAME and VERSION, return a url to the correspon= ding .cabal file on Hackage. If VERSION is #f or missing, the url for the late= st version is returned." (if version - (string-append "https://hackage.haskell.org/package/" + (string-append (%hackage-url) "/package/" name "-" version "/" name ".cabal") - (string-append "https://hackage.haskell.org/package/" + (string-append (%hackage-url) "/package/" name "/" name ".cabal"))) =20 (define (hackage-name->package-name name) diff --git a/guix/import/stackage.scm b/guix/import/stackage.scm index 93cf214127..77cc6350cb 100644 --- a/guix/import/stackage.scm +++ b/guix/import/stackage.scm @@ -30,7 +30,8 @@ #:use-module (guix memoization) #:use-module (guix packages) #:use-module (guix upstream) - #:export (stackage->guix-package + #:export (%stackage-url + stackage->guix-package stackage-recursive-import %stackage-updater)) =20 @@ -39,7 +40,8 @@ ;;; Stackage info fetcher and access functions ;;; =20 -(define %stackage-url "https://www.stackage.org") +(define %stackage-url + (make-parameter "https://www.stackage.org")) =20 ;; Latest LTS version compatible with GHC 8.6.5. (define %default-lts-version "14.27") @@ -55,7 +57,7 @@ ;; "Retrieve the information about the LTS Stackage release VERSION." (memoize (lambda* (#:optional (version "")) - (let* ((url (string-append %stackage-url + (let* ((url (string-append (%stackage-url) "/lts-" (if (string-null? version) %default-lts-version version))) diff --git a/guix/lint.scm b/guix/lint.scm index e1a77e8ac7..b552aa5d62 100644 --- a/guix/lint.scm +++ b/guix/lint.scm @@ -10,6 +10,7 @@ ;;; Copyright =C2=A9 2017, 2018, 2020 Efraim Flashner ;;; Copyright =C2=A9 2018, 2019 Arun Isaac ;;; Copyright =C2=A9 2020 Chris Marusich +;;; Copyright =C2=A9 2020 Timothy Sample ;;; ;;; This file is part of GNU Guix. ;;; @@ -50,6 +51,7 @@ #:use-module ((guix swh) #:hide (origin?)) #:autoload (guix git-download) (git-reference? git-reference-url git-reference-commit) + #:use-module (guix import stackage) #:use-module (ice-9 match) #:use-module (ice-9 regex) #:use-module (ice-9 format) @@ -87,6 +89,7 @@ check-formatting check-archival check-profile-collisions + check-haskell-stackage =20 lint-warning lint-warning? @@ -1240,6 +1243,25 @@ Heritage") '() (apply throw key args)))))))) =20 +(define (check-haskell-stackage package) + "Check whether PACKAGE is a Haskell package ahead of the current +Stackage LTS version." + (match (with-networking-fail-safe + (format #f (G_ "while retrieving upstream info for '~a'") + (package-name package)) + #f + (package-latest-release package (list %stackage-updater))) + ((? upstream-source? source) + (if (version>? (package-version package) + (upstream-source-version source)) + (list + (make-warning package + (G_ "ahead of Stackage LTS version ~a") + (list (upstream-source-version source)) + #:field 'version)) + '())) + (#f '()))) + ;;; ;;; Source code formatting. @@ -1462,7 +1484,11 @@ or a list thereof") (lint-checker (name 'archival) (description "Ensure source code archival on Software Heritage") - (check check-archival)))) + (check check-archival)) + (lint-checker + (name 'haskell-stackage) + (description "Ensure Haskell packages use Stackage LTS versions") + (check check-haskell-stackage)))) =20 (define %all-checkers (append %local-checkers diff --git a/tests/lint.scm b/tests/lint.scm index 95abd71378..10a4585c65 100644 --- a/tests/lint.scm +++ b/tests/lint.scm @@ -7,6 +7,7 @@ ;;; Copyright =C2=A9 2017 Alex Kost ;;; Copyright =C2=A9 2017 Efraim Flashner ;;; Copyright =C2=A9 2018, 2019 Arun Isaac +;;; Copyright =C2=A9 2020 Timothy Sample ;;; ;;; This file is part of GNU Guix. ;;; @@ -36,6 +37,8 @@ #:use-module (guix lint) #:use-module (guix ui) #:use-module (guix swh) + #:use-module ((guix import hackage) #:select (%hackage-url)) + #:use-module ((guix import stackage) #:select (%stackage-url)) #:use-module (gnu packages) #:use-module (gnu packages glib) #:use-module (gnu packages pkg-config) @@ -1001,6 +1004,35 @@ (string-contains (single-lint-warning-message warnings) "rate limit reached"))) =20 +(test-skip (if (http-server-can-listen?) 0 1)) +(test-assert "haskell-stackage" + (let* ((stackage (string-append "{ \"packages\": [{" + " \"name\":\"x\"," + " \"version\":\"1.0\" }]}")) + (packages (map (lambda (version) + (dummy-package + (string-append "ghc-x") + (version version) + (source + (dummy-origin + (method url-fetch) + (uri (string-append + "https://hackage.haskell.org/package/" + "x-" version "/x-" version ".tar.gz")))= ))) + '("0.9" "1.0" "2.0"))) + (warnings (pk (with-http-server `((200 ,stackage) ; memoized + (200 "name: x\nversion: 1.0\n") + (200 "name: x\nversion: 1.0\n") + (200 "name: x\nversion: 1.0\n")) + (parameterize ((%hackage-url (%local-url)) + (%stackage-url (%local-url))) + (append-map check-haskell-stackage packages))))= )) + (match warnings + (((? lint-warning? warning)) + (and (string=3D? (package-version (lint-warning-package warning)) "= 2.0") + (string-contains (lint-warning-message warning) + "ahead of Stackage LTS version")))))) + (test-end "lint") =20 ;; Local Variables: --=20 2.29.2 --=-=-=--