From 3c65d9de802a94eaca22a81b5d0ba005ed23c1cd Mon Sep 17 00:00:00 2001 From: Adam Bergmark Date: Sat, 23 Dec 2023 21:38:57 +0100 Subject: [PATCH 1/3] check lts-haskell master for build constraint files --- app-curator/Main.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app-curator/Main.hs b/app-curator/Main.hs index c7a48c9..c19fd91 100644 --- a/app-curator/Main.hs +++ b/app-curator/Main.hs @@ -147,7 +147,7 @@ ltsConstraints major minor = do buildConstraintsPath <- resolveFile' buildConstraintsName exists <- doesFileExist buildConstraintsPath logInfo $ "Downloading " <> fromString (buildConstraintsName) <> " from commercialhaskell/lts-haskell" - req <- parseUrlThrow $ "https://raw.githubusercontent.com/commercialhaskell/lts-haskell/lts-build-constraints/build-constraints/" <> buildConstraintsName + req <- parseUrlThrow $ "https://raw.githubusercontent.com/commercialhaskell/lts-haskell/master/build-constraints/" <> buildConstraintsName man <- liftIO $ newManager tlsManagerSettings liftIO (httpLbs req man) >>= loadStackageConstraintsBs . BL.toStrict . responseBody From 500ee370f2af1455f4c377ecc4aa7f5bd04a4181 Mon Sep 17 00:00:00 2001 From: Adam Bergmark Date: Sat, 23 Dec 2023 22:01:16 +0100 Subject: [PATCH 2/3] Add --no-download option for `curator snapshot` to verify build-constraints working copies. --- app-curator/Main.hs | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/app-curator/Main.hs b/app-curator/Main.hs index c19fd91..5e600c4 100644 --- a/app-curator/Main.hs +++ b/app-curator/Main.hs @@ -1,5 +1,6 @@ {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE LambdaCase #-} +{-# LANGUAGE NamedFieldPuns #-} {-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE TemplateHaskell #-} @@ -44,7 +45,7 @@ options = addCommand "constraints" "Generate constraints file from build-constraints.yaml" constraints - parseTarget + parseConstraintsArgs addCommand "snapshot-incomplete" "Generate incomplete snapshot" snapshotIncomplete @@ -85,6 +86,10 @@ options = "Bulk convert all new snapshots to the legacy LTS/Nightly directories" legacyBulk parseLegacyBulkArgs + + parseConstraintsArgs = ConstraintsArgs + <$> flag True False (long "no-download" <> help "Download constraints file for LTS") + <*> parseTarget parseTarget = option (nightly <|> lts) ( long "target" <> metavar "TARGET" @@ -118,11 +123,16 @@ update :: RIO PantryApp () update = do void $ updateHackageIndex $ Just "Updating hackage index" -constraints :: Target -> RIO PantryApp () -constraints target = do +data ConstraintsArgs = ConstraintsArgs + { downloadLtsConstraints :: Bool + , target :: Target + } + +constraints :: ConstraintsArgs -> RIO PantryApp () +constraints ConstraintsArgs { downloadLtsConstraints, target } = do stackageConstraints <- case target of TargetNightly _ -> nightlyConstraints - TargetLts major minor -> ltsConstraints major minor + TargetLts major minor -> ltsConstraints downloadLtsConstraints major minor logInfo "Writing constraints.yaml" liftIO $ encodeFile constraintsFilename stackageConstraints @@ -140,16 +150,21 @@ nightlyConstraints = do man <- liftIO $ newManager tlsManagerSettings liftIO (httpLbs req man) >>= loadStackageConstraintsBs . BL.toStrict . responseBody -ltsConstraints major minor = do +ltsConstraints download major minor = do when (minor > 0) $ do verifyPreviousLtsMinorExists major minor let buildConstraintsName = "lts-" <> show major <> "-build-constraints.yaml" buildConstraintsPath <- resolveFile' buildConstraintsName exists <- doesFileExist buildConstraintsPath - logInfo $ "Downloading " <> fromString (buildConstraintsName) <> " from commercialhaskell/lts-haskell" - req <- parseUrlThrow $ "https://raw.githubusercontent.com/commercialhaskell/lts-haskell/master/build-constraints/" <> buildConstraintsName - man <- liftIO $ newManager tlsManagerSettings - liftIO (httpLbs req man) >>= loadStackageConstraintsBs . BL.toStrict . responseBody + if download + then do + logInfo $ "Downloading " <> fromString (buildConstraintsName) <> " from commercialhaskell/lts-haskell" + req <- parseUrlThrow $ "https://raw.githubusercontent.com/commercialhaskell/lts-haskell/master/build-constraints/" <> buildConstraintsName + man <- liftIO $ newManager tlsManagerSettings + liftIO (httpLbs req man) >>= loadStackageConstraintsBs . BL.toStrict . responseBody + else do + logInfo $ "Reusing local file " <> fromString (toFilePath buildConstraintsPath) + loadStackageConstraints $ toFilePath buildConstraintsPath -- Performs a download of the previous LTS minor just to verify that it has been published. verifyPreviousLtsMinorExists :: Int -> Int -> RIO PantryApp () From 46c3437ff07d33bff7a113578d6f098a65c3fbe6 Mon Sep 17 00:00:00 2001 From: Adam Bergmark Date: Sat, 23 Dec 2023 22:17:02 +0100 Subject: [PATCH 3/3] Fix typo --- app-curator/Main.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app-curator/Main.hs b/app-curator/Main.hs index 5e600c4..dc9881b 100644 --- a/app-curator/Main.hs +++ b/app-curator/Main.hs @@ -182,7 +182,7 @@ verifyPreviousLtsMinorExists major minor = do exists <- doesFileExist constraintsPath when exists $ removeFile constraintsPath - logInfo $ "Verifying existance of constraints.yaml from " + logInfo $ "Verifying existence of constraints.yaml from " <> "lts-" <> display major <> "." <> display prevMinor req <- parseUrlThrow url downloaded <- download req constraintsPath