Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cabal 3.12 #1322

Merged
merged 6 commits into from
Jul 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 17 additions & 13 deletions .github/workflows/haskell-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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"
Expand Down Expand Up @@ -183,7 +187,7 @@ jobs:
echo " ghc-options: -Werror=missing-methods" >> cabal.project
cat >> cabal.project <<EOF
EOF
$HCPKG list --simple-output --names-only | perl -ne 'for (split /\s+/) { print "constraints: $_ installed\n" unless /^(Cabal|Cabal-syntax|hackage-server|parsec|process|text)$/; }' >> 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
Expand Down
9 changes: 0 additions & 9 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,6 @@ packages:

-- This project config requires cabal 2.4 or later

-- If in doubt, use GHC 8.8 to build hackage-server; see
-- 'tested-with' in 'hackage-server.cabal' for a list of currently
-- CI-validated GHC versions
--
-- with-compiler: ghc-8.8


allow-newer: rss:time, rss:base

-----------------------------------------------------------------------------
-- Anti-constraints

Expand Down
14 changes: 13 additions & 1 deletion exes/Main.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{-# LANGUAGE CPP #-}

{-# OPTIONS_GHC -fno-warn-incomplete-uni-patterns #-}

module Main where

import qualified Distribution.Server as Server
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
63 changes: 34 additions & 29 deletions hackage-server.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -129,13 +130,13 @@ 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
Expand All @@ -148,32 +149,33 @@ common defaults
-- 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.12.1.0 && < 3.14
, Cabal-syntax >= 3.12.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: -Wall -fwarn-tabs -fno-warn-unused-do-bind -fno-warn-deprecated-flags -funbox-strict-fields

if impl(ghc >= 8.2)
ghc-options: -Werror=incomplete-patterns -Werror=missing-methods
ghc-options:
-funbox-strict-fields
-Wall -fwarn-tabs -fno-warn-unused-do-bind -fno-warn-deprecated-flags
-Werror=incomplete-patterns -Werror=missing-methods

if impl(ghc >= 8.10)
ghc-options: -Wno-unused-record-wildcards

default-extensions: LambdaCase, TupleSections
other-extensions: CPP, TemplateHaskell


library lib-server
library
import: defaults
hs-source-dirs: src

Expand Down Expand Up @@ -407,7 +409,7 @@ library lib-server
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
Expand Down Expand Up @@ -438,7 +440,7 @@ library lib-server
, 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
Expand All @@ -452,7 +454,7 @@ library lib-server
, 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

Expand All @@ -472,7 +474,7 @@ library lib-server
common exe-defaults
import: defaults

build-depends: lib-server
build-depends: hackage-server
hs-source-dirs: exes
ghc-options: -threaded -rtsopts

Expand All @@ -493,7 +495,7 @@ executable hackage-mirror
main-is: MirrorClient.hs

build-depends:
-- version constraints inherited from lib-server
-- version constraints inherited from hackage-server
, HTTP
, hackage-security

Expand All @@ -503,7 +505,7 @@ executable hackage-build
main-is: BuildClient.hs

build-depends:
-- version constraints inherited from lib-server
-- version constraints inherited from hackage-server
, HTTP

-- Runtime dependency only;
Expand All @@ -523,7 +525,7 @@ executable hackage-import
main-is: ImportClient.hs

build-depends:
-- version constraints inherited from lib-server
-- version constraints inherited from hackage-server
, HTTP
, async
, csv
Expand All @@ -533,7 +535,7 @@ executable hackage-import
common test-defaults
import: defaults

build-depends: lib-server
build-depends: hackage-server
hs-source-dirs: tests
ghc-options: -threaded -rtsopts -fno-warn-orphans

Expand Down Expand Up @@ -563,9 +565,9 @@ test-suite HighLevelTest
-- so if this works, it's accidental!
build-tool-depends: hackage-server:hackage-server

-- NOTE: lib-server is not a real dependency; it's only used to inherit version constraints
-- NOTE: hackage-server is not a real dependency; it's only used to inherit version constraints
build-depends:
-- version constraints inherited from lib-server
-- version constraints inherited from hackage-server
, HTTP
, attoparsec-aeson >= 2.1.0.0 && < 2.3
, base64-bytestring
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -640,9 +645,9 @@ test-suite CreateUserTest
-- see note in 'Test-Suite HighLevelTest'
build-tool-depends: hackage-server:hackage-server

-- NOTE: lib-server is not a real dependency; it's only used to inherit version constraints
-- NOTE: hackage-server is not a real dependency; it's only used to inherit version constraints
build-depends:
-- version constraints inherited from lib-server
-- version constraints inherited from hackage-server
, HTTP
, base64-bytestring
, random
Expand All @@ -657,7 +662,7 @@ test-suite PackageTests
other-modules: Distribution.Server.Packages.UnpackTest

build-depends:
-- version constraints inherited from lib-server
-- version constraints inherited from hackage-server
-- component-specific dependencies
, tasty ^>= 1.5
, tasty-hunit ^>= 0.10
Expand All @@ -670,7 +675,7 @@ test-suite HashTests
main-is: HashTestMain.hs

build-depends:
-- version constraints inherited from lib-server
-- version constraints inherited from hackage-server
, base16-bytestring
, cereal
, cryptohash-md5
Expand All @@ -686,7 +691,7 @@ test-suite DocTests
type: exitcode-stdio-1.0
main-is: DocTestMain.hs
build-depends:
, lib-server
, hackage-server
, doctest-parallel ^>= 0.3.0
-- doctest-parallel-0.2.2 is the first to filter out autogen-modules

Expand Down
14 changes: 5 additions & 9 deletions src/Distribution/Server/Features/Tags/State.hs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ import Control.Monad (liftM2)
import Data.SafeCopy (base, deriveSafeCopy)
import Data.Typeable (Typeable)
import qualified Data.Char as Char
import Data.Functor ( (<&>) )
import Data.Maybe (fromMaybe)
import Data.List (foldl')
import Data.List (find, foldl')
import Control.Monad.State (get, put, modify)
import Control.Monad.Reader (ask, asks)
import Control.DeepSeq
Expand Down Expand Up @@ -87,13 +88,9 @@ lookupTagAlias tag
return (Map.lookup tag m)

getTagAlias :: Tag -> Query TagAlias Tag
getTagAlias tag
= do TagAlias m <- ask
if tag `elem` Map.keys m
then return tag
else if tag `Set.member` foldr Set.union Set.empty (Map.elems m)
then return $ head (Map.keys $ Map.filter (tag `Set.member`) m)
else return tag
getTagAlias tag = ask <&> \ (TagAlias m) ->
if Map.member tag m then tag
else maybe tag fst $ find (Set.member tag . snd) $ Map.toList m

emptyPackageTags :: PackageTags
emptyPackageTags = PackageTags Map.empty Map.empty Map.empty
Expand Down Expand Up @@ -279,4 +276,3 @@ $(makeAcidic ''PackageTags ['tagsForPackage
,'lookupReviewTags
,'clearReviewTags
])

Loading
Loading