From 04f90354994dd6656eb7c9292942448a5e46a72d Mon Sep 17 00:00:00 2001 From: Andreas Abel Date: Tue, 2 Jul 2024 19:34:39 +0200 Subject: [PATCH] Support Cabal-3.12 and GHC 9.10 --- .github/workflows/haskell-ci.yml | 30 ++++++++++-------- exes/Main.hs | 14 ++++++++- hackage-server.cabal | 31 +++++++++++-------- .../Server/Framework/Instances.hs | 18 +++++++++++ src/Distribution/Server/Packages/Unpack.hs | 14 +++++++-- .../Server/Util/CabalRevisions.hs | 13 ++++++-- 6 files changed, 87 insertions(+), 33 deletions(-) diff --git a/.github/workflows/haskell-ci.yml b/.github/workflows/haskell-ci.yml index 660f16f8..9445af6b 100644 --- a/.github/workflows/haskell-ci.yml +++ b/.github/workflows/haskell-ci.yml @@ -8,9 +8,9 @@ # # For more information, see https://github.com/andreasabel/haskell-ci # -# version: 0.17.20231012 +# version: 0.19.20240630 # -# REGENDATA ("0.17.20231012",["github","hackage-server.cabal"]) +# REGENDATA ("0.19.20240630",["github","hackage-server.cabal"]) # name: Haskell-CI on: @@ -32,19 +32,24 @@ jobs: strategy: matrix: include: - - compiler: ghc-9.8.1 + - compiler: ghc-9.10.1 compilerKind: ghc - compilerVersion: 9.8.1 + compilerVersion: 9.10.1 setup-method: ghcup allow-failure: false - - compiler: ghc-9.6.3 + - compiler: ghc-9.8.2 compilerKind: ghc - compilerVersion: 9.6.3 + compilerVersion: 9.8.2 setup-method: ghcup allow-failure: false - - compiler: ghc-9.4.7 + - compiler: ghc-9.6.5 compilerKind: ghc - compilerVersion: 9.4.7 + compilerVersion: 9.6.5 + setup-method: ghcup + allow-failure: false + - compiler: ghc-9.4.8 + compilerKind: ghc + compilerVersion: 9.4.8 setup-method: ghcup allow-failure: false - compiler: ghc-9.2.8 @@ -74,11 +79,10 @@ jobs: apt-get update apt-get install -y --no-install-recommends gnupg ca-certificates dirmngr curl git software-properties-common libtinfo5 mkdir -p "$HOME/.ghcup/bin" - curl -sL https://downloads.haskell.org/ghcup/0.1.19.5/x86_64-linux-ghcup-0.1.19.5 > "$HOME/.ghcup/bin/ghcup" + curl -sL https://downloads.haskell.org/ghcup/0.1.20.0/x86_64-linux-ghcup-0.1.20.0 > "$HOME/.ghcup/bin/ghcup" chmod a+x "$HOME/.ghcup/bin/ghcup" - "$HOME/.ghcup/bin/ghcup" config add-release-channel https://raw.githubusercontent.com/haskell/ghcup-metadata/master/ghcup-prereleases-0.0.7.yaml; "$HOME/.ghcup/bin/ghcup" install ghc "$HCVER" || (cat "$HOME"/.ghcup/logs/*.* && false) - "$HOME/.ghcup/bin/ghcup" install cabal 3.10.1.0 || (cat "$HOME"/.ghcup/logs/*.* && false) + "$HOME/.ghcup/bin/ghcup" install cabal 3.12.1.0 || (cat "$HOME"/.ghcup/logs/*.* && false) apt-get update apt-get install -y libbrotli-dev libgd-dev env: @@ -98,7 +102,7 @@ jobs: echo "HC=$HC" >> "$GITHUB_ENV" echo "HCPKG=$HCPKG" >> "$GITHUB_ENV" echo "HADDOCK=$HADDOCK" >> "$GITHUB_ENV" - echo "CABAL=$HOME/.ghcup/bin/cabal-3.10.1.0 -vnormal+nowrap" >> "$GITHUB_ENV" + echo "CABAL=$HOME/.ghcup/bin/cabal-3.12.1.0 -vnormal+nowrap" >> "$GITHUB_ENV" HCNUMVER=$(${HC} --numeric-version|perl -ne '/^(\d+)\.(\d+)\.(\d+)(\.(\d+))?$/; print(10000 * $1 + 100 * $2 + ($3 == 0 ? $5 != 1 : $3))') echo "HCNUMVER=$HCNUMVER" >> "$GITHUB_ENV" echo "ARG_TESTS=--enable-tests" >> "$GITHUB_ENV" @@ -183,7 +187,7 @@ jobs: echo " ghc-options: -Werror=missing-methods" >> cabal.project cat >> cabal.project <> cabal.project.local + $HCPKG list --simple-output --names-only | perl -ne 'for (split /\s+/) { print "constraints: any.$_ installed\n" unless /^(Cabal|Cabal-syntax|hackage-server|parsec|process|text)$/; }' >> cabal.project.local cat cabal.project cat cabal.project.local - name: dump install plan diff --git a/exes/Main.hs b/exes/Main.hs index c8134631..b3ee4605 100644 --- a/exes/Main.hs +++ b/exes/Main.hs @@ -1,4 +1,7 @@ +{-# LANGUAGE CPP #-} + {-# OPTIONS_GHC -fno-warn-incomplete-uni-patterns #-} + module Main where import qualified Distribution.Server as Server @@ -65,7 +68,11 @@ main :: IO () main = topHandler $ do hSetBuffering stdout LineBuffering args <- getArgs +#if !MIN_VERSION_Cabal(3,12,0) case commandsRun (globalCommand commands) commands args of +#else + commandsRun (globalCommand commands) commands args >>= \case +#endif CommandHelp help -> printHelp help CommandList opts -> printOptionsList opts CommandErrors errs -> printErrors errs @@ -79,6 +86,7 @@ main = topHandler $ do where printHelp help = getProgName >>= putStr . help + printOptionsList :: [String] -> IO () printOptionsList = putStr . unlines printErrors errs = do putStr (intercalate "\n" errs) @@ -154,7 +162,11 @@ optionVerbosity getter setter = "Control verbosity (n is 0--3, default verbosity level is 1)" getter setter (optArg "n" (fmap Flag Verbosity.flagToVerbosity) - (Flag Verbosity.verbose) + ( +#if MIN_VERSION_Cabal(3,12,0) + show Verbosity.verbose, +#endif + Flag Verbosity.verbose) (fmap (Just . showForCabal) . flagToList)) optionStateDir :: (a -> Flag FilePath) diff --git a/hackage-server.cabal b/hackage-server.cabal index 44a73bad..e48830a9 100644 --- a/hackage-server.cabal +++ b/hackage-server.cabal @@ -28,9 +28,10 @@ license: BSD-3-Clause license-file: LICENSE tested-with: - GHC == 9.8.1 - GHC == 9.6.3 - GHC == 9.4.7 + GHC == 9.10.1 + GHC == 9.8.2 + GHC == 9.6.5 + GHC == 9.4.8 GHC == 9.2.8 GHC == 9.0.2 GHC == 8.10.7 @@ -129,38 +130,38 @@ common defaults -- see `cabal.project.local-ghc-${VERSION}` files build-depends: , array >= 0.5 && < 0.6 - , base >= 4.13 && < 4.20 + , base >= 4.13 && < 4.21 , binary >= 0.8 && < 0.9 , bytestring >= 0.10 && < 0.13 , containers >= 0.6.0 && < 0.8 , deepseq >= 1.4 && < 1.6 , directory >= 1.3 && < 1.4 - , filepath >= 1.4 && < 1.5 + , filepath >= 1.4 && < 1.6 , mtl >= 2.2.1 && < 2.4 -- we use Control.Monad.Except, introduced in mtl-2.2.1 , pretty >= 1.1 && < 1.2 , process >= 1.6 && < 1.7 , text ^>= 1.2.5.0 || >= 2.0 && < 2.2 - , time >= 1.9 && < 1.13 + , time >= 1.9 && < 1.15 , transformers >= 0.5 && < 0.7 , unix >= 2.7 && < 2.9 , scientific -- other dependencies shared by most components build-depends: , aeson >= 2.1.0.0 && < 2.3 - , Cabal >= 3.10.1.0 && < 3.12 - , Cabal-syntax >= 3.10.1.0 && < 3.12 + , Cabal >= 3.10.1.0 && < 3.14 + , Cabal-syntax >= 3.10.1.0 && < 3.14 -- Cabal-syntax needs to be bound to constrain hackage-security -- see https://github.com/haskell/hackage-server/issues/1130 , fail ^>= 4.9.0 - , network >= 3 && < 3.2 + , network >= 3 && < 3.3 , network-bsd ^>= 2.8 , network-uri ^>= 2.6 , parsec ^>= 3.1.13 , tar ^>= 0.6 , unordered-containers ^>= 0.2.10 , vector ^>= 0.12 || ^>= 0.13.0.0 - , zlib ^>= 0.6.2 + , zlib ^>= 0.6.2 || ^>= 0.7.0.0 ghc-options: -funbox-strict-fields @@ -170,6 +171,7 @@ common defaults if impl(ghc >= 8.10) ghc-options: -Wno-unused-record-wildcards + default-extensions: LambdaCase, TupleSections other-extensions: CPP, TemplateHaskell @@ -407,7 +409,7 @@ library build-depends: , HStringTemplate ^>= 0.8 , HTTP ^>= 4000.3.16 || ^>= 4000.4.1 - , QuickCheck ^>= 2.14 + , QuickCheck >= 2.14 && < 2.16 , acid-state ^>= 0.16 , async ^>= 2.2.1 -- requires bumping http-io-streams @@ -438,7 +440,7 @@ library , haddock-library ^>= 1.11.0 -- haddock-library-1.11.0 changed type of markupOrderedList -- see https://github.com/haskell/hackage-server/issues/1128 - , happstack-server ^>= 7.7.1 || ^>= 7.8.0 + , happstack-server ^>= 7.7.1 || ^>= 7.8.0 || ^>= 7.9.0 , hashable ^>= 1.3 || ^>= 1.4 , hs-captcha ^>= 1.0 , hslogger ^>= 1.3.1 @@ -452,7 +454,7 @@ library , stm ^>= 2.5.0 , stringsearch ^>= 0.3.6.6 , tagged ^>= 0.8.5 - , xhtml ^>= 3000.2.0.0 + , xhtml >= 3000.2.0.0 && < 3000.4 , xmlgen ^>= 0.6 , xss-sanitize ^>= 0.3.6 @@ -611,6 +613,9 @@ benchmark RevDeps build-depends: , random ^>= 1.2 , gauge + -- gauge does not support base-4.20 + if impl(ghc >= 9.10) + buildable: False ghc-options: -with-rtsopts=-s other-modules: RevDepCommon diff --git a/src/Distribution/Server/Framework/Instances.hs b/src/Distribution/Server/Framework/Instances.hs index 27327866..669d8273 100644 --- a/src/Distribution/Server/Framework/Instances.hs +++ b/src/Distribution/Server/Framework/Instances.hs @@ -196,6 +196,12 @@ instance SafeCopy Arch where putCopy AArch64 = contain $ putWord8 17 putCopy S390X = contain $ putWord8 18 putCopy Wasm32 = contain $ putWord8 19 +#if MIN_VERSION_Cabal_syntax(3,12,0) + putCopy PPC64LE = contain $ putWord8 20 + putCopy Sparc64 = contain $ putWord8 21 + putCopy RISCV64 = contain $ putWord8 22 + putCopy LoongArch64 = contain $ putWord8 23 +#endif getCopy = contain $ do tag <- getWord8 @@ -220,6 +226,12 @@ instance SafeCopy Arch where 17 -> return AArch64 18 -> return S390X 19 -> return Wasm32 +#if MIN_VERSION_Cabal_syntax(3,12,0) + 20 -> return PPC64LE + 21 -> return Sparc64 + 22 -> return RISCV64 + 23 -> return LoongArch64 +#endif _ -> fail "SafeCopy Arch getCopy: unexpected tag" instance SafeCopy CompilerFlavor where @@ -238,6 +250,9 @@ instance SafeCopy CompilerFlavor where putCopy (HaskellSuite s) = contain $ putWord8 10 >> safePut s putCopy GHCJS = contain $ putWord8 11 putCopy Eta = contain $ putWord8 12 +#if MIN_VERSION_Cabal_syntax(3,12,1) + putCopy MHS = contain $ putWord8 13 +#endif getCopy = contain $ do tag <- getWord8 @@ -255,6 +270,9 @@ instance SafeCopy CompilerFlavor where 10 -> return HaskellSuite <*> safeGet 11 -> return GHCJS 12 -> return Eta +#if MIN_VERSION_Cabal_syntax(3,12,1) + 13 -> return MHS +#endif _ -> fail "SafeCopy CompilerFlavor getCopy: unexpected tag" diff --git a/src/Distribution/Server/Packages/Unpack.hs b/src/Distribution/Server/Packages/Unpack.hs index 6e8303dc..000df5ea 100644 --- a/src/Distribution/Server/Packages/Unpack.hs +++ b/src/Distribution/Server/Packages/Unpack.hs @@ -292,9 +292,17 @@ extraChecks :: GenericPackageDescription -> UploadMonad () extraChecks genPkgDesc pkgId tarIndex = do let pkgDesc = flattenPackageDescription genPkgDesc - fileChecks <- checkPackageContent (tarOps pkgId tarIndex) pkgDesc - - let pureChecks = checkPackage genPkgDesc (Just pkgDesc) + fileChecks <- checkPackageContent (tarOps pkgId tarIndex) +-- The API change of checkPackage happened somewhere between 3.10 and 3.12. +#if !MIN_VERSION_Cabal(3,12,0) + pkgDesc +#else + genPkgDesc +#endif + let pureChecks = checkPackage genPkgDesc +#if !MIN_VERSION_Cabal(3,12,0) + (Just pkgDesc) +#endif checks = pureChecks ++ fileChecks isDistError (PackageDistSuspicious {}) = False -- just a warning isDistError (PackageDistSuspiciousWarn {}) = False -- just a warning diff --git a/src/Distribution/Server/Util/CabalRevisions.hs b/src/Distribution/Server/Util/CabalRevisions.hs index 9036cf9c..479f0c41 100644 --- a/src/Distribution/Server/Util/CabalRevisions.hs +++ b/src/Distribution/Server/Util/CabalRevisions.hs @@ -178,12 +178,19 @@ checkCabalFileRevision checkXRevision old new = do checkPackageChecks :: Check GenericPackageDescription checkPackageChecks pkg pkg' = - let checks = checkPackage pkg Nothing - checks' = filter notUpperBounds $ checkPackage pkg' Nothing + let checks = checkPackage pkg +-- The API change of checkPackage happened somewhere between 3.10 and 3.12. +#if !MIN_VERSION_Cabal(3,12,0) + Nothing +#endif + checks' = filter notUpperBounds $ checkPackage pkg' +#if !MIN_VERSION_Cabal(3,12,0) + Nothing +#endif -- if multiple upper bounds are missing, then the simple set subtraction might detect a change to -- just one, and fail. Ideally we'd perform a set subtraction directly on just the missing bounds -- warning contents. A simple second best is to discard this check for now. - notUpperBounds (PackageDistSuspiciousWarn (MissingUpperBounds _)) = False + notUpperBounds (PackageDistSuspiciousWarn MissingUpperBounds{}) = False notUpperBounds _ = True in case checks' \\ checks of [] -> return ()