Skip to content

Commit 0632086

Browse files
authored
Build with Cabal-3.8 and GHC 9.4 (#1141)
This commit makes `hackage-server` compile with Cabal-3.8, but does not add any Cabal-3.8 specific features. Adds `allow-older: Cabal:process` to solve a conflict arising from these two dependency chains: - Cabal-3.8.1.0 -> process >= 1.6.14 - Cabal-3.8.1.0 -> doctest-parallel -> ghc -> process For `ghc < 9.4`, this means `process < 1.6.14`, and the `ghc` package is not upgradeable, so the only solution is to override `Cabal-3.8.1.0`s request for this very recent version of `process`. The conflict is discussed in haskell/cabal#8554. Likely, the next release of `Cabal-3.8` will drop the request for a specific `process` library and we can drop the `allow-older` workaround, and also reenable the tests on Haskell-CI for GHC < 9.4 (see `cabal.haskell-ci`).
1 parent 2a3ad24 commit 0632086

File tree

7 files changed

+77
-17
lines changed

7 files changed

+77
-17
lines changed

.github/workflows/haskell-ci.yml

+10-5
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
#
99
# For more information, see https://github.com/haskell-CI/haskell-ci
1010
#
11-
# version: 0.15.20220822
11+
# version: 0.15.20221009
1212
#
13-
# REGENDATA ("0.15.20220822",["github","hackage-server.cabal"])
13+
# REGENDATA ("0.15.20221009",["github","hackage-server.cabal"])
1414
#
1515
name: Haskell-CI
1616
on:
@@ -34,6 +34,11 @@ jobs:
3434
strategy:
3535
matrix:
3636
include:
37+
- compiler: ghc-9.4.2
38+
compilerKind: ghc
39+
compilerVersion: 9.4.2
40+
setup-method: ghcup
41+
allow-failure: false
3742
- compiler: ghc-9.2.4
3843
compilerKind: ghc
3944
compilerVersion: 9.2.4
@@ -104,7 +109,7 @@ jobs:
104109
105110
HCNUMVER=$(${HC} --numeric-version|perl -ne '/^(\d+)\.(\d+)\.(\d+)(\.(\d+))?$/; print(10000 * $1 + 100 * $2 + ($3 == 0 ? $5 != 1 : $3))')
106111
echo "HCNUMVER=$HCNUMVER" >> "$GITHUB_ENV"
107-
echo "ARG_TESTS=--enable-tests" >> "$GITHUB_ENV"
112+
if [ $((HCNUMVER >= 90400)) -ne 0 ] ; then echo "ARG_TESTS=--enable-tests" >> "$GITHUB_ENV" ; else echo "ARG_TESTS=--disable-tests" >> "$GITHUB_ENV" ; fi
108113
echo "ARG_BENCH=--enable-benchmarks" >> "$GITHUB_ENV"
109114
echo "HEADHACKAGE=false" >> "$GITHUB_ENV"
110115
echo "ARG_COMPILER=--$HCKIND --with-compiler=$HC" >> "$GITHUB_ENV"
@@ -186,7 +191,7 @@ jobs:
186191
echo " ghc-options: -Werror=missing-methods" >> cabal.project
187192
cat >> cabal.project <<EOF
188193
EOF
189-
$HCPKG list --simple-output --names-only | perl -ne 'for (split /\s+/) { print "constraints: $_ installed\n" unless /^(Cabal|hackage-server|parsec|text)$/; }' >> cabal.project.local
194+
$HCPKG list --simple-output --names-only | perl -ne 'for (split /\s+/) { print "constraints: $_ installed\n" unless /^(Cabal|hackage-server|parsec|process|text)$/; }' >> cabal.project.local
190195
cat cabal.project
191196
cat cabal.project.local
192197
- name: dump install plan
@@ -211,7 +216,7 @@ jobs:
211216
$CABAL v2-build $ARG_COMPILER $ARG_TESTS $ARG_BENCH all --write-ghc-environment-files=always
212217
- name: tests
213218
run: |
214-
$CABAL v2-test $ARG_COMPILER $ARG_TESTS $ARG_BENCH all --test-show-details=direct
219+
if [ $((HCNUMVER >= 90400)) -ne 0 ] ; then $CABAL v2-test $ARG_COMPILER $ARG_TESTS $ARG_BENCH all --test-show-details=direct ; fi
215220
- name: cabal check
216221
run: |
217222
cd ${PKGDIR_hackage_server} || false

cabal.haskell-ci

+9-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
branches: master ci*
22

3-
installed: +all -Cabal -text -parsec
3+
installed: +all -Cabal -text -parsec -process
4+
-- Cabal-3.8.1.0 wants process-1.6.14 or newer
45

5-
-- -- irc-channels works with GHA, but why send to a channel
6-
-- -- when one can subscribe to github notifications?
7-
-- irc-channels: irc.libera.chat#hackage
6+
-- Did not help to salvage ghc-9.2 and below:
7+
-- installed: -all +ghc
88

99
-- Does not work with GHA:
1010
-- -- allow failures with ghc-7.6 and ghc-7.8
@@ -19,3 +19,8 @@ apt: libbrotli-dev
1919
-- even though we don't define any library.
2020
haddock-components: all
2121
-- since haskell-ci 0.15.20220822
22+
23+
tests: >= 9.4
24+
-- parallel-doctest uses the ghc package
25+
-- and thus does not build with Cabal-3.8.1.0 below GHC 9.4
26+
-- See: https://github.com/haskell/cabal/issues/8554

cabal.project

+11
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,17 @@ packages: .
1111

1212
allow-newer: rss:time, rss:base
1313

14+
-- Andreas, 2022-10-28: `Cabal-3.8.1.0` wants `process >= 1.6.14`
15+
-- which is too new for the `ghc < 9.4` package that is pulled in
16+
-- by `doctest-parallel`.
17+
-- Since, Cabal-3.8.1.0 has no reason to want such a new version
18+
-- of process, we can solve the conflict here by allowing
19+
-- `Cabal` to use the shipped version of `process`.
20+
-- This workaround can be removed once `Cabal-3.8` drops
21+
-- its (unreasonable) constraint on `process`.
22+
-- See: https://github.com/haskell/cabal/issues/8554
23+
allow-older: Cabal:process
24+
1425
-----------------------------------------------------------------------------
1526
-- Anti-constraints
1627

hackage-server.cabal

+5-5
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ copyright: 2008-2015 Duncan Coutts,
2727
license: BSD-3-Clause
2828
license-file: LICENSE
2929

30-
tested-with: GHC == { 9.2.4, 9.0.2, 8.10.7, 8.8.4 }
30+
tested-with: GHC == { 9.4.2, 9.2.4, 9.0.2, 8.10.7, 8.8.4 }
3131

3232
data-dir: datafiles
3333
data-files:
@@ -99,7 +99,7 @@ common defaults
9999
-- see `cabal.project.local-ghc-${VERSION}` files
100100
build-depends:
101101
, array >= 0.5 && < 0.6
102-
, base >= 4.13 && < 4.17
102+
, base >= 4.13 && < 4.18
103103
, binary >= 0.8 && < 0.9
104104
, bytestring >= 0.10 && < 0.12
105105
, containers ^>= 0.6.0
@@ -117,8 +117,8 @@ common defaults
117117
-- other dependencies shared by most components
118118
build-depends:
119119
, aeson ^>= 2.0.3.0 || ^>= 2.1.0.0
120-
, Cabal ^>= 3.6.3.0
121-
, Cabal-syntax ^>= 3.6.0.0
120+
, Cabal ^>= 3.8.1.0
121+
, Cabal-syntax ^>= 3.8.1.0
122122
-- Cabal-syntax needs to be bound to constrain hackage-security
123123
-- see https://github.com/haskell/hackage-server/issues/1130
124124
, fail ^>= 4.9.0
@@ -371,7 +371,7 @@ library lib-server
371371
-- NB: see also build-depends in `common defaults`!
372372
build-depends:
373373
, HStringTemplate ^>= 0.8
374-
, HTTP ^>= 4000.3.16
374+
, HTTP ^>= 4000.3.16 || ^>= 4000.4.1
375375
, QuickCheck ^>= 2.14
376376
, acid-state ^>= 0.16
377377
, async ^>= 2.2.1

src/Distribution/Server/Features/BuildReports/BuildReport.hs

+13-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
{-# LANGUAGE CPP #-}
12
{-# LANGUAGE ConstraintKinds #-}
23
{-# LANGUAGE DeriveDataTypeable #-}
34
{-# LANGUAGE FlexibleInstances #-}
45
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
56
{-# LANGUAGE MultiParamTypeClasses #-}
67
{-# LANGUAGE OverloadedStrings #-}
8+
{-# LANGUAGE PatternSynonyms #-}
79
{-# LANGUAGE RecordWildCards #-}
810
{-# LANGUAGE TemplateHaskell #-}
911
{-# LANGUAGE TypeFamilies #-}
@@ -57,6 +59,10 @@ import Distribution.CabalSpecVersion
5759
( CabalSpecVersion(CabalSpecV2_4) )
5860
import Distribution.Pretty
5961
( Pretty(..), pretty, prettyShow )
62+
#if MIN_VERSION_Cabal(3,7,0)
63+
import Distribution.Fields.Pretty
64+
( pattern NoComment )
65+
#endif
6066
import qualified Text.PrettyPrint as Disp
6167

6268
import Distribution.Parsec
@@ -311,7 +317,13 @@ intPair = do
311317
-- Pretty-printing
312318

313319
show :: BuildReport -> String
314-
show = showFields (const []) . prettyFieldGrammar CabalSpecV2_4 fieldDescrs
320+
show = showFields noComment . prettyFieldGrammar CabalSpecV2_4 fieldDescrs
321+
where
322+
#if MIN_VERSION_Cabal(3,7,0)
323+
noComment _ = NoComment
324+
#else
325+
noComment _ = []
326+
#endif
315327

316328
-- -----------------------------------------------------------------------------
317329
-- Description of the fields, for parsing/printing

src/Distribution/Server/Framework/Instances.hs

+6
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ instance SafeCopy OS where
136136
putCopy Ghcjs = contain $ putWord8 14
137137
putCopy Hurd = contain $ putWord8 15
138138
putCopy Android = contain $ putWord8 16
139+
putCopy Wasi = contain $ putWord8 17
139140

140141
getCopy = contain $ do
141142
tag <- getWord8
@@ -157,6 +158,7 @@ instance SafeCopy OS where
157158
14 -> return Ghcjs
158159
15 -> return Hurd
159160
16 -> return Android
161+
17 -> return Wasi
160162
_ -> fail "SafeCopy OS getCopy: unexpected tag"
161163

162164
instance SafeCopy Arch where
@@ -180,6 +182,8 @@ instance SafeCopy Arch where
180182
putCopy Vax = contain $ putWord8 15
181183
putCopy JavaScript = contain $ putWord8 16
182184
putCopy AArch64 = contain $ putWord8 17
185+
putCopy S390X = contain $ putWord8 18
186+
putCopy Wasm32 = contain $ putWord8 19
183187

184188
getCopy = contain $ do
185189
tag <- getWord8
@@ -202,6 +206,8 @@ instance SafeCopy Arch where
202206
15 -> return Vax
203207
16 -> return JavaScript
204208
17 -> return AArch64
209+
18 -> return S390X
210+
19 -> return Wasm32
205211
_ -> fail "SafeCopy Arch getCopy: unexpected tag"
206212

207213
instance SafeCopy CompilerFlavor where

src/Distribution/Server/Util/CabalRevisions.hs

+23-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
{-# LANGUAGE FlexibleContexts #-}
33
{-# LANGUAGE FunctionalDependencies #-}
44
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
5+
{-# LANGUAGE PatternSynonyms #-}
56
{-# LANGUAGE OverloadedStrings #-}
67
{-# LANGUAGE ScopedTypeVariables #-}
78
{-# LANGUAGE TypeFamilies #-}
@@ -39,6 +40,9 @@ import Distribution.Version
3940
import Distribution.Compiler (CompilerFlavor)
4041
import Distribution.FieldGrammar (prettyFieldGrammar)
4142
import Distribution.Fields.Pretty (PrettyField (..), showFields)
43+
#if MIN_VERSION_Cabal(3,7,0)
44+
import Distribution.Fields.Pretty (pattern NoComment)
45+
#endif
4246
import Distribution.PackageDescription
4347
import Distribution.PackageDescription.Parsec (parseGenericPackageDescription, runParseResult)
4448
import Distribution.PackageDescription.FieldGrammar (sourceRepoFieldGrammar)
@@ -340,7 +344,7 @@ checkPackageDescriptions checkXRevision
340344
checkSame "The package-url field is unused, don't bother changing it."
341345
pkgUrlA pkgUrlB
342346
changesOk "bug-reports" fromShortText bugReportsA bugReportsB
343-
changesOkList changesOk "source-repository" (showFields (const []) . (:[]) . ppSourceRepo)
347+
changesOkList changesOk "source-repository" (showFields noComment . (:[]) . ppSourceRepo)
344348
sourceReposA sourceReposB
345349
changesOk "synopsis" fromShortText synopsisA synopsisB
346350
changesOk "description" fromShortText descriptionA descriptionB
@@ -365,6 +369,12 @@ checkPackageDescriptions checkXRevision
365369

366370
when checkXRevision $ checkRevision customFieldsPDA customFieldsPDB
367371
checkCuration customFieldsPDA customFieldsPDB
372+
where
373+
#if MIN_VERSION_Cabal(3,7,0)
374+
noComment _ = NoComment
375+
#else
376+
noComment _ = []
377+
#endif
368378

369379
checkSpecVersionRaw :: Check PackageDescription
370380
checkSpecVersionRaw pdA pdB
@@ -625,10 +635,20 @@ checkExecutable componentName
625635

626636
checkTestSuite :: ComponentName -> Check TestSuite
627637
checkTestSuite componentName
638+
#if MIN_VERSION_Cabal(3,7,0)
639+
(TestSuite _nameA interfaceA buildInfoA testGeneratorsA)
640+
(TestSuite _nameB interfaceB buildInfoB testGeneratorsB)
641+
#else
628642
(TestSuite _nameA interfaceA buildInfoA)
629-
(TestSuite _nameB interfaceB buildInfoB) = do
643+
(TestSuite _nameB interfaceB buildInfoB)
644+
#endif
645+
= do
630646
checkSame "Cannot change test-suite type" interfaceA interfaceB
631647
checkBuildInfo componentName buildInfoA buildInfoB
648+
#if MIN_VERSION_Cabal(3,7,0)
649+
-- @test-generators@
650+
checkSame "Cannot change test-generators" testGeneratorsA testGeneratorsB
651+
#endif
632652

633653
checkBenchmark :: ComponentName -> Check Benchmark
634654
checkBenchmark componentName
@@ -690,6 +710,7 @@ changesOkSet what render old new = do
690710
logChange (Change Normal ("removed " ++ what) (renderSet removed) "")
691711
unless (Set.null added) $
692712
logChange (Change Normal ("added " ++ what) "" (renderSet added))
713+
return ()
693714
where
694715
added = new Set.\\ old
695716
removed = old Set.\\ new

0 commit comments

Comments
 (0)