From 6f200663b2c92b738d4cf5620819a48f7d6e88b1 Mon Sep 17 00:00:00 2001 From: Lars Kuhtz Date: Mon, 3 Mar 2025 15:57:15 -0800 Subject: [PATCH 1/4] fix build with remote config and update ci --- .github/workflows/cabal-ci.yaml | 53 ++++++++++++++----- .../Utils/Internal/HttpsCertPolicy.hs | 2 +- 2 files changed, 41 insertions(+), 14 deletions(-) diff --git a/.github/workflows/cabal-ci.yaml b/.github/workflows/cabal-ci.yaml index f788429..1fd2bec 100644 --- a/.github/workflows/cabal-ci.yaml +++ b/.github/workflows/cabal-ci.yaml @@ -10,26 +10,23 @@ jobs: strategy: fail-fast: false matrix: - ghc: ['8.10.7', '9.0.1', '9.2', '9.4', '9.6'] - cabal: ['3.10'] - os: ['ubuntu-22.04', 'ubuntu-20.04', 'macOS-latest'] + ghc: ['9.4', '9.6', '9.8', '9.10', '9.12'] + cabal: ['latest'] + os: ['ubuntu-22.04', 'ubuntu-24.04', 'macOS-latest'] remoteConfigs: ['-remote-configs', '+remote-configs'] - include: - - ghc: '9.2' - cabal: '3.6' - os: 'ubuntu-22.04' - remoteConfigs: '+remote-configs' steps: # Setup - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 + - name: Install GHC and Cabal - uses: haskell/actions/setup@v2 + uses: haskell-actions/setup@v2 with: ghc-version: ${{ matrix.ghc }} cabal-version: ${{ matrix.cabal }} + - name: Configure project run: | cat > cabal.project.local < Date: Mon, 3 Mar 2025 17:34:29 -0800 Subject: [PATCH 2/4] support GHC-9.12 in setup scripts --- Setup.hs | 49 ++++++++++++++++++++-------- src/Configuration/Utils/Setup.hs | 56 +++++++++++++++++++++----------- 2 files changed, 72 insertions(+), 33 deletions(-) diff --git a/Setup.hs b/Setup.hs index 2088620..bf70422 100644 --- a/Setup.hs +++ b/Setup.hs @@ -110,6 +110,7 @@ import Distribution.Simple.BuildPaths import Distribution.Simple.LocalBuildInfo import Distribution.Simple.PackageIndex import Distribution.Simple.Setup +import Distribution.Simple.Utils (createDirectoryIfMissingVerbose) import Distribution.Text import Distribution.Utils.Path import Distribution.Utils.ShortText @@ -128,10 +129,17 @@ import Data.Monoid import Prelude hiding (readFile, writeFile) import System.Directory - (canonicalizePath, createDirectoryIfMissing, doesDirectoryExist, - doesFileExist, getCurrentDirectory) + ( canonicalizePath + , doesDirectoryExist + , doesFileExist + , getCurrentDirectory + ) import System.Exit (ExitCode(ExitSuccess)) +#if MIN_VERSION_Cabal(3,14,0) +import System.FilePath (isDrive, takeDirectory) +#else import System.FilePath (isDrive, takeDirectory, ()) +#endif -- | Include this function when your setup doesn't contain any -- extra functionality. @@ -162,6 +170,11 @@ mkPkgInfoModules hooks = hooks prettyLicense :: I.InstalledPackageInfo -> String prettyLicense = either prettyShow prettyShow . I.license +#if !MIN_VERSION_Cabal(3,14,0) +interpretSymbolicPath :: Maybe () -> FilePath -> FilePath +interpretSymbolicPath _ p = p +#endif + -- -------------------------------------------------------------------------- -- -- Cabal 2.0 @@ -173,28 +186,31 @@ mkPkgInfoModulesPostConf -> LocalBuildInfo -> IO () mkPkgInfoModulesPostConf hook args flags pkgDesc bInfo = do - mapM_ (updatePkgInfoModule pkgDesc bInfo) $ Graph.toList $ componentGraph bInfo + mapM_ (updatePkgInfoModule pkgDesc bInfo flags) $ Graph.toList $ componentGraph bInfo hook args flags pkgDesc bInfo -updatePkgInfoModule :: PackageDescription -> LocalBuildInfo -> ComponentLocalBuildInfo -> IO () -updatePkgInfoModule pkgDesc bInfo clbInfo = do - createDirectoryIfMissing True dirName +updatePkgInfoModule + :: PackageDescription + -> LocalBuildInfo + -> ConfigFlags + -> ComponentLocalBuildInfo + -> IO () +updatePkgInfoModule pkgDesc bInfo flags clbInfo = do + createDirectoryIfMissingVerbose verbosity True dirName moduleBytes <- pkgInfoModule moduleName cName pkgDesc bInfo updateFile fileName moduleBytes -- legacy module legacyModuleBytes <- pkgInfoModule legacyModuleName cName pkgDesc bInfo updateFile legacyFileName legacyModuleBytes - where - dirName = autogenComponentModulesDir bInfo clbInfo + verbosity = fromFlag $ configVerbosity flags + dirName = interpretSymbolicPath Nothing $ autogenComponentModulesDir bInfo clbInfo cName = unUnqualComponentName <$> componentNameString (componentLocalName clbInfo) - moduleName = pkgInfoModuleName - fileName = dirName ++ "/" ++ moduleName ++ ".hs" - + fileName = dirName moduleName <> ".hs" legacyModuleName = legacyPkgInfoModuleName cName - legacyFileName = dirName ++ "/" ++ legacyModuleName ++ ".hs" + legacyFileName = dirName legacyModuleName <> ".hs" -- -------------------------------------------------------------------------- -- -- Generate PkgInfo Module @@ -214,7 +230,7 @@ updateFile fileName content = do legacyPkgInfoModuleName :: Maybe String -> String legacyPkgInfoModuleName Nothing = "PkgInfo" -legacyPkgInfoModuleName (Just cn) = "PkgInfo_" ++ map tr cn +legacyPkgInfoModuleName (Just cn) = "PkgInfo_" <> map tr cn where tr '-' = '_' tr c = c @@ -236,7 +252,12 @@ getVCS = getCurrentDirectory >>= getVcsOfDir then return Nothing else getVcsOfDir (takeDirectory canonicDir) -pkgInfoModule :: String -> Maybe String -> PackageDescription -> LocalBuildInfo -> IO B.ByteString +pkgInfoModule + :: String + -> Maybe String + -> PackageDescription + -> LocalBuildInfo + -> IO B.ByteString pkgInfoModule moduleName cName pkgDesc bInfo = do (tag, revision, branch) <- getVCS >>= \case Just Mercurial -> hgInfo diff --git a/src/Configuration/Utils/Setup.hs b/src/Configuration/Utils/Setup.hs index 30e887f..2556473 100644 --- a/src/Configuration/Utils/Setup.hs +++ b/src/Configuration/Utils/Setup.hs @@ -110,6 +110,7 @@ import Distribution.Simple.BuildPaths import Distribution.Simple.LocalBuildInfo import Distribution.Simple.PackageIndex import Distribution.Simple.Setup +import Distribution.Simple.Utils (createDirectoryIfMissingVerbose) import Distribution.Text import Distribution.Utils.Path import Distribution.Utils.ShortText @@ -128,10 +129,17 @@ import Data.Monoid import Prelude hiding (readFile, writeFile) import System.Directory - (canonicalizePath, createDirectoryIfMissing, doesDirectoryExist, - doesFileExist, getCurrentDirectory) + ( canonicalizePath + , doesDirectoryExist + , doesFileExist + , getCurrentDirectory + ) import System.Exit (ExitCode(ExitSuccess)) +#if MIN_VERSION_Cabal(3,14,0) +import System.FilePath (isDrive, takeDirectory) +#else import System.FilePath (isDrive, takeDirectory, ()) +#endif -- | Include this function when your setup doesn't contain any -- extra functionality. @@ -162,8 +170,10 @@ mkPkgInfoModules hooks = hooks prettyLicense :: I.InstalledPackageInfo -> String prettyLicense = either prettyShow prettyShow . I.license -ft :: ShortText -> String -ft = fromShortText +#if !MIN_VERSION_Cabal(3,14,0) +interpretSymbolicPath :: Maybe () -> FilePath -> FilePath +interpretSymbolicPath _ p = p +#endif -- -------------------------------------------------------------------------- -- -- Cabal 2.0 @@ -176,28 +186,31 @@ mkPkgInfoModulesPostConf -> LocalBuildInfo -> IO () mkPkgInfoModulesPostConf hook args flags pkgDesc bInfo = do - mapM_ (updatePkgInfoModule pkgDesc bInfo) $ Graph.toList $ componentGraph bInfo + mapM_ (updatePkgInfoModule pkgDesc bInfo flags) $ Graph.toList $ componentGraph bInfo hook args flags pkgDesc bInfo -updatePkgInfoModule :: PackageDescription -> LocalBuildInfo -> ComponentLocalBuildInfo -> IO () -updatePkgInfoModule pkgDesc bInfo clbInfo = do - createDirectoryIfMissing True dirName +updatePkgInfoModule + :: PackageDescription + -> LocalBuildInfo + -> ConfigFlags + -> ComponentLocalBuildInfo + -> IO () +updatePkgInfoModule pkgDesc bInfo flags clbInfo = do + createDirectoryIfMissingVerbose verbosity True dirName moduleBytes <- pkgInfoModule moduleName cName pkgDesc bInfo updateFile fileName moduleBytes -- legacy module legacyModuleBytes <- pkgInfoModule legacyModuleName cName pkgDesc bInfo updateFile legacyFileName legacyModuleBytes - where - dirName = autogenComponentModulesDir bInfo clbInfo + verbosity = fromFlag $ configVerbosity flags + dirName = interpretSymbolicPath Nothing $ autogenComponentModulesDir bInfo clbInfo cName = unUnqualComponentName <$> componentNameString (componentLocalName clbInfo) - moduleName = pkgInfoModuleName - fileName = dirName ++ "/" ++ moduleName ++ ".hs" - + fileName = dirName moduleName <> ".hs" legacyModuleName = legacyPkgInfoModuleName cName - legacyFileName = dirName ++ "/" ++ legacyModuleName ++ ".hs" + legacyFileName = dirName legacyModuleName <> ".hs" -- -------------------------------------------------------------------------- -- -- Generate PkgInfo Module @@ -217,7 +230,7 @@ updateFile fileName content = do legacyPkgInfoModuleName :: Maybe String -> String legacyPkgInfoModuleName Nothing = "PkgInfo" -legacyPkgInfoModuleName (Just cn) = "PkgInfo_" ++ map tr cn +legacyPkgInfoModuleName (Just cn) = "PkgInfo_" <> map tr cn where tr '-' = '_' tr c = c @@ -239,7 +252,12 @@ getVCS = getCurrentDirectory >>= getVcsOfDir then return Nothing else getVcsOfDir (takeDirectory canonicDir) -pkgInfoModule :: String -> Maybe String -> PackageDescription -> LocalBuildInfo -> IO B.ByteString +pkgInfoModule + :: String + -> Maybe String + -> PackageDescription + -> LocalBuildInfo + -> IO B.ByteString pkgInfoModule moduleName cName pkgDesc bInfo = do (tag, revision, branch) <- getVCS >>= \case Just Mercurial -> hgInfo @@ -302,10 +320,10 @@ pkgInfoModule moduleName cName pkgDesc bInfo = do , " copyright = " <> (pack . show . copyright) pkgDesc , "" , " author :: IsString a => a" - , " author = \"" <> (pack . ft . author) pkgDesc <> "\"" + , " author = \"" <> (pack . fromShortText . author) pkgDesc <> "\"" , "" , " homepage :: IsString a => a" - , " homepage = \"" <> (pack . ft . homepage) pkgDesc <> "\"" + , " homepage = \"" <> (pack . fromShortText . homepage) pkgDesc <> "\"" , "" , " package :: IsString a => a" , " package = \"" <> (pack . display . package) pkgDesc <> "\"" @@ -397,4 +415,4 @@ pkgIdWithLicense a = (display . packageId) a ++ (if cr /= "" then ", " ++ cr else "") ++ "]" where - cr = (unwords . words . ft . I.copyright) a + cr = (unwords . words . fromShortText . I.copyright) a From 9bfb2ca99be6a060abb86faf758d9c3e474a83dc Mon Sep 17 00:00:00 2001 From: Lars Kuhtz Date: Mon, 3 Mar 2025 17:35:08 -0800 Subject: [PATCH 3/4] remove deprecated Typeable deriving --- src/Configuration/Utils/ConfigFile.hs | 5 ++--- src/Configuration/Utils/Internal/ConfigFileReader.hs | 3 +-- src/Configuration/Utils/Internal/HttpsCertPolicy.hs | 5 ++--- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/Configuration/Utils/ConfigFile.hs b/src/Configuration/Utils/ConfigFile.hs index ad21008..7be3854 100644 --- a/src/Configuration/Utils/ConfigFile.hs +++ b/src/Configuration/Utils/ConfigFile.hs @@ -78,7 +78,6 @@ import Data.Maybe import Data.Monoid.Unicode import Data.String import qualified Data.Text as T -import Data.Typeable import Prelude hiding (any, concatMap, mapM_) @@ -254,7 +253,7 @@ infix 6 %.: data ConfigFile = ConfigFileRequired { getConfigFile ∷ !T.Text } | ConfigFileOptional { getConfigFile ∷ !T.Text } - deriving (Show, Read, Eq, Ord, Typeable) + deriving (Show, Read, Eq, Ord) -- | An /internal/ type for the meta configuration that specifies how the -- configuration files are loaded and parsed. @@ -263,7 +262,7 @@ data ConfigFile data ConfigFilesConfig = ConfigFilesConfig { _cfcHttpsPolicy ∷ !HttpsCertPolicy } - deriving (Show, Eq, Typeable) + deriving (Show, Eq) cfcHttpsPolicy ∷ Lens' ConfigFilesConfig HttpsCertPolicy cfcHttpsPolicy = lens _cfcHttpsPolicy $ \a b → a { _cfcHttpsPolicy = b } diff --git a/src/Configuration/Utils/Internal/ConfigFileReader.hs b/src/Configuration/Utils/Internal/ConfigFileReader.hs index 9f24e00..1b7fa1a 100644 --- a/src/Configuration/Utils/Internal/ConfigFileReader.hs +++ b/src/Configuration/Utils/Internal/ConfigFileReader.hs @@ -50,7 +50,6 @@ import Data.Bifunctor import qualified Data.ByteString.Char8 as B8 import Data.Monoid.Unicode import qualified Data.Text as T -import Data.Typeable import qualified Data.Yaml as Yaml import GHC.Generics @@ -155,7 +154,7 @@ data ConfigFileFormat = Yaml | Json | Other - deriving (Show, Read, Eq, Ord, Enum, Bounded, Typeable, Generic) + deriving (Show, Read, Eq, Ord, Enum, Bounded, Generic) instance NFData ConfigFileFormat diff --git a/src/Configuration/Utils/Internal/HttpsCertPolicy.hs b/src/Configuration/Utils/Internal/HttpsCertPolicy.hs index 9d81cc5..a32541f 100644 --- a/src/Configuration/Utils/Internal/HttpsCertPolicy.hs +++ b/src/Configuration/Utils/Internal/HttpsCertPolicy.hs @@ -52,7 +52,6 @@ import Data.Monoid.Unicode import Data.String import qualified Data.Text as T import qualified Data.Text.Encoding as T -import Data.Typeable import qualified Data.X509 as TLS import qualified Data.X509.Validation as TLS @@ -80,7 +79,7 @@ data HttpsCertPolicy = HttpsCertPolicy , _certPolicyHostFingerprints ∷ !(HM.HashMap TLS.ServiceID TLS.Fingerprint) -- ^ a whitelist for services with trusted certificates } - deriving (Show, Eq, Typeable) + deriving (Show, Eq) certPolicyInsecure ∷ Lens' HttpsCertPolicy Bool certPolicyInsecure = lens _certPolicyInsecure $ \s a → s { _certPolicyInsecure = a } @@ -177,7 +176,7 @@ httpWithValidationPolicy request policy = do -- In particular exceptions should include rejected certificates. -- newtype VerboseTlsException = VerboseTlsException T.Text - deriving (Eq, Ord, Typeable) + deriving (Eq, Ord) instance Show VerboseTlsException where show (VerboseTlsException msg) = "TLS exception: " ⊕ T.unpack msg From 5e91cbc61a8c99b598b22bde2172990361315d77 Mon Sep 17 00:00:00 2001 From: Lars Kuhtz Date: Mon, 3 Mar 2025 18:34:46 -0800 Subject: [PATCH 4/4] test with old cabal version --- .github/workflows/cabal-ci.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/cabal-ci.yaml b/.github/workflows/cabal-ci.yaml index 1fd2bec..99825d4 100644 --- a/.github/workflows/cabal-ci.yaml +++ b/.github/workflows/cabal-ci.yaml @@ -14,6 +14,12 @@ jobs: cabal: ['latest'] os: ['ubuntu-22.04', 'ubuntu-24.04', 'macOS-latest'] remoteConfigs: ['-remote-configs', '+remote-configs'] + include: + - ghc: '9.6' + cabal: '3.8' + os: 'ubuntu-22.04' + remoteConfigs: '-remote-configs' + steps: