Skip to content

Commit

Permalink
Merge branch 'master' into andrea/revert-ghc-cabal-workaround
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored Nov 4, 2023
2 parents 08959e6 + 4e20249 commit f28cf9c
Show file tree
Hide file tree
Showing 14 changed files with 81 additions and 51 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ on:
env:
# We choose a stable ghc version across all os's
# which will be used to do the next release
GHC_FOR_RELEASE: '9.2.7'
GHC_FOR_RELEASE: '9.2.8'
# Ideally we should use the version about to be released for hackage tests and benchmarks
GHC_FOR_SOLVER_BENCHMARKS: '9.2.7'
GHC_FOR_COMPLETE_HACKAGE_TESTS: '9.2.7'
GHC_FOR_SOLVER_BENCHMARKS: '9.2.8'
GHC_FOR_COMPLETE_HACKAGE_TESTS: '9.2.8'
COMMON_FLAGS: '-j 2 -v'

jobs:
Expand All @@ -38,7 +38,7 @@ jobs:
strategy:
matrix:
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
ghc: ["9.6.1", "9.4.4", "9.2.7", "9.0.2", "8.10.7", "8.8.4", "8.6.5", "8.4.4"]
ghc: ["9.6.3", "9.4.7", "9.2.8", "9.0.2", "8.10.7", "8.8.4", "8.6.5", "8.4.4"]
exclude:
# corrupts GHA cache or the fabric of reality itself, see https://github.com/haskell/cabal/issues/8356
- os: "windows-latest"
Expand Down Expand Up @@ -107,7 +107,7 @@ jobs:
echo "FLAGS=$FLAGS" >> $GITHUB_ENV
- name: Allow newer dependencies when built with latest GHC
if: ${{ matrix.ghc }} == '9.6.1'
if: ${{ matrix.ghc }} == '9.6.3'
run: |
echo "allow-newer: rere:base, rere:transformers" >> cabal.project.validate
Expand Down Expand Up @@ -161,15 +161,15 @@ jobs:
# Have to disable *-suite validation:
# - the [email protected] problem is tracked at https://github.com/haskell/cabal/issues/8858
# - but curently can't run it with GHC 9.6, tracking: https://github.com/haskell/cabal/issues/8883
if: (runner.os != 'Windows') || (matrix.ghc != '9.6.1')
if: (runner.os != 'Windows') || (matrix.ghc != '9.6.3')
run: sh validate.sh $FLAGS -s lib-suite

- name: Validate cli-tests
run: sh validate.sh $FLAGS -s cli-tests

- name: Validate cli-suite
# Have to disable *-suite validation, see above the comment for lib-suite
if: (runner.os != 'Windows') || (matrix.ghc != '9.6.1')
if: (runner.os != 'Windows') || (matrix.ghc != '9.6.3')
run: sh validate.sh $FLAGS -s cli-suite

validate-old-ghcs:
Expand Down
24 changes: 12 additions & 12 deletions Cabal-tests/Cabal-tests.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,15 @@ test-suite unit-tests
, Cabal-QuickCheck
, containers
, deepseq
, Diff >=0.4 && <0.5
, Diff >=0.4 && <0.6
, directory
, filepath
, integer-logarithms >=1.0.2 && <1.1
, pretty
, QuickCheck >=2.14 && <2.15
, rere >=0.1 && <0.3
, tagged
, tasty >=1.2.3 && <1.5
, tasty >=1.2.3 && <1.6
, tasty-hunit
, tasty-quickcheck
, temporary
Expand All @@ -84,14 +84,14 @@ test-suite parser-tests
main-is: ParserTests.hs
build-depends:
base
, base-compat >=0.11.0 && <0.13
, base-compat >=0.11.0 && <0.14
, bytestring
, Cabal-syntax
, Cabal-tree-diff
, Diff >=0.4 && <0.5
, Diff >=0.4 && <0.6
, directory
, filepath
, tasty >=1.2.3 && <1.5
, tasty >=1.2.3 && <1.6
, tasty-golden >=2.3.1.1 && <2.4
, tasty-hunit
, tasty-quickcheck
Expand All @@ -109,10 +109,10 @@ test-suite check-tests
, bytestring
, Cabal
, Cabal-syntax
, Diff >=0.4 && <0.5
, Diff >=0.4 && <0.6
, directory
, filepath
, tasty >=1.2.3 && <1.5
, tasty >=1.2.3 && <1.6
, tasty-expected-failure
, tasty-golden >=2.3.1.1 && <2.4

Expand Down Expand Up @@ -155,10 +155,10 @@ test-suite hackage-tests
, filepath

build-depends:
base-compat >=0.11.0 && <0.13
, base-orphans >=0.6 && <0.9
base-compat >=0.11.0 && <0.14
, base-orphans >=0.6 && <0.10
, clock >=0.8 && <0.9
, optparse-applicative >=0.13.2.0 && <0.17
, optparse-applicative >=0.13.2.0 && <0.19
, stm >=2.4.5.0 && <2.6
, tar >=0.5.0.3 && <0.6
, tree-diff >=0.1 && <0.4
Expand All @@ -178,7 +178,7 @@ test-suite rpmvercmp

build-depends:
QuickCheck
, tasty >=1.2.3 && <1.5
, tasty >=1.2.3 && <1.6
, tasty-hunit
, tasty-quickcheck

Expand All @@ -197,7 +197,7 @@ test-suite no-thunks-test
base
, bytestring
, Cabal-syntax
, tasty >=1.2.3 && <1.5
, tasty >=1.2.3 && <1.6
, tasty-hunit

-- this is test is buildable on old GHCs
Expand Down
7 changes: 5 additions & 2 deletions Cabal/src/Distribution/Make.hs
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,10 @@ defaultMainArgs :: [String] -> IO ()
defaultMainArgs = defaultMainHelper

defaultMainHelper :: [String] -> IO ()
defaultMainHelper args =
case commandsRun (globalCommand commands) commands args of
defaultMainHelper args = do
command <- commandsRun (globalCommand commands) commands args
case command of
CommandDelegate -> pure ()
CommandHelp help -> printHelp help
CommandList opts -> printOptionsList opts
CommandErrors errs -> printErrors errs
Expand All @@ -98,6 +100,7 @@ defaultMainHelper args =
_
| fromFlag (globalVersion flags) -> printVersion
| fromFlag (globalNumericVersion flags) -> printNumericVersion
CommandDelegate -> pure ()
CommandHelp help -> printHelp help
CommandList opts -> printOptionsList opts
CommandErrors errs -> printErrors errs
Expand Down
5 changes: 4 additions & 1 deletion Cabal/src/Distribution/Simple.hs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,9 @@ defaultMainWithHooksNoReadArgs hooks pkg_descr =
defaultMainHelper :: UserHooks -> Args -> IO ()
defaultMainHelper hooks args = topHandler $ do
args' <- expandResponse args
case commandsRun (globalCommand commands) commands args' of
command <- commandsRun (globalCommand commands) commands args'
case command of
CommandDelegate -> pure ()
CommandHelp help -> printHelp help
CommandList opts -> printOptionsList opts
CommandErrors errs -> printErrors errs
Expand All @@ -177,6 +179,7 @@ defaultMainHelper hooks args = topHandler $ do
_
| fromFlag (globalVersion flags) -> printVersion
| fromFlag (globalNumericVersion flags) -> printNumericVersion
CommandDelegate -> pure ()
CommandHelp help -> printHelp help
CommandList opts -> printOptionsList opts
CommandErrors errs -> printErrors errs
Expand Down
35 changes: 27 additions & 8 deletions Cabal/src/Distribution/Simple/Command.hs
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,15 @@ module Distribution.Simple.Command
import Distribution.Compat.Prelude hiding (get)
import Prelude ()

import Control.Exception (try)
import qualified Data.Array as Array
import qualified Data.List as List
import Distribution.Compat.Lens (ALens', (#~), (^#))
import qualified Distribution.GetOpt as GetOpt
import Distribution.ReadE
import Distribution.Simple.Utils
import System.Directory (findExecutable)
import System.Process (callProcess)

data CommandUI flags = CommandUI
{ commandName :: String
Expand Down Expand Up @@ -596,11 +599,13 @@ data CommandParse flags
| CommandList [String]
| CommandErrors [String]
| CommandReadyToGo flags
| CommandDelegate
instance Functor CommandParse where
fmap _ (CommandHelp help) = CommandHelp help
fmap _ (CommandList opts) = CommandList opts
fmap _ (CommandErrors errs) = CommandErrors errs
fmap f (CommandReadyToGo flags) = CommandReadyToGo (f flags)
fmap _ CommandDelegate = CommandDelegate

data CommandType = NormalCommand | HiddenCommand
data Command action
Expand Down Expand Up @@ -631,25 +636,38 @@ commandsRun
:: CommandUI a
-> [Command action]
-> [String]
-> CommandParse (a, CommandParse action)
-> IO (CommandParse (a, CommandParse action))
commandsRun globalCommand commands args =
case commandParseArgs globalCommand True args of
CommandHelp help -> CommandHelp help
CommandList opts -> CommandList (opts ++ commandNames)
CommandErrors errs -> CommandErrors errs
CommandDelegate -> pure CommandDelegate
CommandHelp help -> pure $ CommandHelp help
CommandList opts -> pure $ CommandList (opts ++ commandNames)
CommandErrors errs -> pure $ CommandErrors errs
CommandReadyToGo (mkflags, args') -> case args' of
("help" : cmdArgs) -> handleHelpCommand cmdArgs
("help" : cmdArgs) -> pure $ handleHelpCommand cmdArgs
(name : cmdArgs) -> case lookupCommand name of
[Command _ _ action _] ->
CommandReadyToGo (flags, action cmdArgs)
_ -> CommandReadyToGo (flags, badCommand name)
[] -> CommandReadyToGo (flags, noCommand)
pure $ CommandReadyToGo (flags, action cmdArgs)
_ -> do
mCommand <- findExecutable $ "cabal-" <> name
case mCommand of
Just exec -> callExternal flags exec cmdArgs
Nothing -> pure $ CommandReadyToGo (flags, badCommand name)
[] -> pure $ CommandReadyToGo (flags, noCommand)
where
flags = mkflags (commandDefaultFlags globalCommand)
where
lookupCommand cname =
[ cmd | cmd@(Command cname' _ _ _) <- commands', cname' == cname
]

callExternal :: a -> String -> [String] -> IO (CommandParse (a, CommandParse action))
callExternal flags exec cmdArgs = do
result <- try $ callProcess exec cmdArgs
case result of
Left ex -> pure $ CommandErrors ["Error executing external command: " ++ show (ex :: SomeException)]
Right _ -> pure $ CommandReadyToGo (flags, CommandDelegate)

noCommand = CommandErrors ["no command given (try --help)\n"]

-- Print suggested command if edit distance is < 5
Expand Down Expand Up @@ -679,6 +697,7 @@ commandsRun globalCommand commands args =
-- furthermore, support "prog help command" as "prog command --help"
handleHelpCommand cmdArgs =
case commandParseArgs helpCommandUI True cmdArgs of
CommandDelegate -> CommandDelegate
CommandHelp help -> CommandHelp help
CommandList list -> CommandList (list ++ commandNames)
CommandErrors _ -> CommandHelp globalHelp
Expand Down
2 changes: 1 addition & 1 deletion cabal-benchmarks/cabal-benchmarks.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ test-suite cabal-benchmarks
base
, bytestring
, Cabal-syntax
, criterion >=1.5.6.2 && <1.6
, criterion >=1.5.6.2 && <1.7
6 changes: 3 additions & 3 deletions cabal-install-solver/cabal-install-solver.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ library

build-depends:
, array >=0.4 && <0.6
, base >=4.10 && <4.19
, base >=4.10 && <4.20
, bytestring >=0.10.6.0 && <0.13
, Cabal ^>=3.11
, Cabal-syntax ^>=3.11
Expand Down Expand Up @@ -138,10 +138,10 @@ Test-Suite unit-tests
UnitTests.Distribution.Solver.Modular.MessageUtils

build-depends:
, base >= 4.10 && <4.19
, base >= 4.10 && <4.20
, Cabal
, Cabal-syntax
, cabal-install-solver
, tasty >= 1.2.3 && <1.5
, tasty >= 1.2.3 && <1.6
, tasty-quickcheck
, tasty-hunit >= 0.10
6 changes: 3 additions & 3 deletions cabal-install/cabal-install.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ common warnings
ghc-options: -Wunused-packages

common base-dep
build-depends: base >=4.10 && <4.19
build-depends: base >=4.10 && <4.20

common cabal-dep
build-depends: Cabal ^>=3.11
Expand Down Expand Up @@ -229,7 +229,7 @@ library
time >= 1.5.0.1 && < 1.13,
zlib >= 0.5.3 && < 0.7,
hackage-security >= 0.6.2.0 && < 0.7,
text >= 1.2.3 && < 1.3 || >= 2.0 && < 2.1,
text >= 1.2.3 && < 1.3 || >= 2.0 && < 2.2,
parsec >= 3.1.13.0 && < 3.2,
regex-base >= 0.94.0.0 && <0.95,
regex-posix >= 0.96.0.0 && <0.97,
Expand Down Expand Up @@ -332,7 +332,7 @@ test-suite unit-tests
tar,
time,
zlib,
tasty >= 1.2.3 && <1.5,
tasty >= 1.2.3 && <1.6,
tasty-golden >=2.3.1.1 && <2.4,
tasty-quickcheck,
tasty-hunit >= 0.10,
Expand Down
7 changes: 5 additions & 2 deletions cabal-install/src/Distribution/Client/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -322,8 +322,10 @@ warnIfAssertionsAreEnabled =
-- into IO actions for execution.
mainWorker :: [String] -> IO ()
mainWorker args = do
topHandler $
case commandsRun (globalCommand commands) commands args of
topHandler $ do
command <- commandsRun (globalCommand commands) commands args
case command of
CommandDelegate -> pure ()
CommandHelp help -> printGlobalHelp help
CommandList opts -> printOptionsList opts
CommandErrors errs -> printErrors errs
Expand All @@ -334,6 +336,7 @@ mainWorker args = do
printVersion
| fromFlagOrDefault False (globalNumericVersion globalFlags) ->
printNumericVersion
CommandDelegate -> pure ()
CommandHelp help -> printCommandHelp help
CommandList opts -> printOptionsList opts
CommandErrors errs -> do
Expand Down
1 change: 1 addition & 0 deletions cabal-install/src/Distribution/Client/SavedFlags.hs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ readCommandFlags :: FilePath -> CommandUI flags -> IO flags
readCommandFlags path command = do
savedArgs <- fmap (fromMaybe []) (readSavedArgs path)
case (commandParseArgs command True savedArgs) of
CommandDelegate -> error "CommandDelegate Flags evaluated, this should never occur"
CommandHelp _ -> throwIO (SavedArgsErrorHelp savedArgs)
CommandList _ -> throwIO (SavedArgsErrorList savedArgs)
CommandErrors errs -> throwIO (SavedArgsErrorOther savedArgs errs)
Expand Down
8 changes: 4 additions & 4 deletions cabal-testsuite/cabal-testsuite.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ common shared
default-language: Haskell2010

build-depends:
, base >= 4.9 && <4.19
, base >= 4.9 && <4.20
-- this needs to match the in-tree lib:Cabal version
, Cabal ^>= 3.11.0.0
, Cabal-syntax ^>= 3.11.0.0
Expand Down Expand Up @@ -57,7 +57,7 @@ library
Test.Cabal.ScriptEnv0

build-depends:
, aeson ^>= 1.4.2.0 || ^>=1.5.0.0 || ^>= 2.0.0.0 || ^>= 2.1.0.0
, aeson ^>= 1.4.2.0 || ^>=1.5.0.0 || ^>= 2.0.0.0 || ^>= 2.1.0.0 || ^>= 2.2.1.0
, async ^>= 2.2.1
, attoparsec ^>= 0.13.2.2 || ^>=0.14.1
, base64-bytestring ^>= 1.0.0.0 || ^>= 1.1.0.0 || ^>= 1.2.0.0
Expand All @@ -68,14 +68,14 @@ library
, exceptions ^>= 0.10.0
, filepath ^>= 1.3.0.1 || ^>= 1.4.0.0
, network-wait ^>= 0.1.2.0 || ^>= 0.2.0.0
, optparse-applicative ^>= 0.14.3.0 || ^>=0.15.1.0 || ^>=0.16.0.0 || ^>= 0.17.0.0
, optparse-applicative ^>= 0.14.3.0 || ^>=0.15.1.0 || ^>=0.16.0.0 || ^>= 0.17.0.0 || ^>= 0.18.1.0
, process ^>= 1.2.1.0 || ^>= 1.4.2.0 || ^>= 1.6.1.0
, regex-base ^>= 0.94.0.1
, regex-tdfa ^>= 1.2.3.1 || ^>=1.3.1.0
, retry ^>= 0.9.1.0
, array ^>= 0.4.0.1 || ^>= 0.5.0.0
, temporary ^>= 1.3
, text ^>= 1.2.3.1 || ^>= 2.0.1
, text ^>= 1.2.3.1 || ^>= 2.0.1 || ^>= 2.1
, transformers ^>= 0.3.0.0 || ^>= 0.4.2.0 || ^>= 0.5.2.0 || ^>= 0.6.0.2

if !os(windows)
Expand Down
8 changes: 0 additions & 8 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,9 @@ packages: cabal-benchmarks/

optional-packages: ./vendored/*/*.cabal

allow-newer:
hackage-security:Cabal

-- avoiding extra dependencies
constraints: rere -rere-cfg
constraints: these -assoc

-- Andreas, 2022-08-19, https://github.com/haskell/cabal/issues/8377
-- Force latest dependencies in the development version:
constraints: text >= 2.0
constraints: time >= 1.12

program-options
ghc-options: -fno-ignore-asserts
Loading

0 comments on commit f28cf9c

Please sign in to comment.