Skip to content

Build with Cabal-3.8 and GHC 9.4 #1141

New issue

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

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

Already on GitHub? # to your account

Merged
merged 7 commits into from
Oct 29, 2022
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
15 changes: 10 additions & 5 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/haskell-CI/haskell-ci
#
# version: 0.15.20220822
# version: 0.15.20221009
#
# REGENDATA ("0.15.20220822",["github","hackage-server.cabal"])
# REGENDATA ("0.15.20221009",["github","hackage-server.cabal"])
#
name: Haskell-CI
on:
Expand All @@ -34,6 +34,11 @@ jobs:
strategy:
matrix:
include:
- compiler: ghc-9.4.2
compilerKind: ghc
compilerVersion: 9.4.2
setup-method: ghcup
allow-failure: false
- compiler: ghc-9.2.4
compilerKind: ghc
compilerVersion: 9.2.4
Expand Down Expand Up @@ -104,7 +109,7 @@ jobs:

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"
if [ $((HCNUMVER >= 90400)) -ne 0 ] ; then echo "ARG_TESTS=--enable-tests" >> "$GITHUB_ENV" ; else echo "ARG_TESTS=--disable-tests" >> "$GITHUB_ENV" ; fi
echo "ARG_BENCH=--enable-benchmarks" >> "$GITHUB_ENV"
echo "HEADHACKAGE=false" >> "$GITHUB_ENV"
echo "ARG_COMPILER=--$HCKIND --with-compiler=$HC" >> "$GITHUB_ENV"
Expand Down Expand Up @@ -186,7 +191,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|hackage-server|parsec|text)$/; }' >> cabal.project.local
$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
cat cabal.project
cat cabal.project.local
- name: dump install plan
Expand All @@ -211,7 +216,7 @@ jobs:
$CABAL v2-build $ARG_COMPILER $ARG_TESTS $ARG_BENCH all --write-ghc-environment-files=always
- name: tests
run: |
$CABAL v2-test $ARG_COMPILER $ARG_TESTS $ARG_BENCH all --test-show-details=direct
if [ $((HCNUMVER >= 90400)) -ne 0 ] ; then $CABAL v2-test $ARG_COMPILER $ARG_TESTS $ARG_BENCH all --test-show-details=direct ; fi
- name: cabal check
run: |
cd ${PKGDIR_hackage_server} || false
Expand Down
13 changes: 9 additions & 4 deletions cabal.haskell-ci
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
branches: master ci*

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

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

-- Does not work with GHA:
-- -- allow failures with ghc-7.6 and ghc-7.8
Expand All @@ -19,3 +19,8 @@ apt: libbrotli-dev
-- even though we don't define any library.
haddock-components: all
-- since haskell-ci 0.15.20220822

tests: >= 9.4
-- parallel-doctest uses the ghc package
-- and thus does not build with Cabal-3.8.1.0 below GHC 9.4
-- See: https://github.com/haskell/cabal/issues/8554
11 changes: 11 additions & 0 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,17 @@ packages: .

allow-newer: rss:time, rss:base

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

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

Expand Down
10 changes: 5 additions & 5 deletions hackage-server.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ copyright: 2008-2015 Duncan Coutts,
license: BSD-3-Clause
license-file: LICENSE

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

data-dir: datafiles
data-files:
Expand Down Expand Up @@ -99,7 +99,7 @@ common defaults
-- see `cabal.project.local-ghc-${VERSION}` files
build-depends:
, array >= 0.5 && < 0.6
, base >= 4.13 && < 4.17
, base >= 4.13 && < 4.18
, binary >= 0.8 && < 0.9
, bytestring >= 0.10 && < 0.12
, containers ^>= 0.6.0
Expand All @@ -117,8 +117,8 @@ common defaults
-- other dependencies shared by most components
build-depends:
, aeson ^>= 2.0.3.0 || ^>= 2.1.0.0
, Cabal ^>= 3.6.3.0
, Cabal-syntax ^>= 3.6.0.0
, Cabal ^>= 3.8.1.0
, Cabal-syntax ^>= 3.8.1.0
-- Cabal-syntax needs to be bound to constrain hackage-security
-- see https://github.com/haskell/hackage-server/issues/1130
, fail ^>= 4.9.0
Expand Down Expand Up @@ -371,7 +371,7 @@ library lib-server
-- NB: see also build-depends in `common defaults`!
build-depends:
, HStringTemplate ^>= 0.8
, HTTP ^>= 4000.3.16
, HTTP ^>= 4000.3.16 || ^>= 4000.4.1
, QuickCheck ^>= 2.14
, acid-state ^>= 0.16
, async ^>= 2.2.1
Expand Down
14 changes: 13 additions & 1 deletion src/Distribution/Server/Features/BuildReports/BuildReport.hs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeFamilies #-}
Expand Down Expand Up @@ -57,6 +59,10 @@ import Distribution.CabalSpecVersion
( CabalSpecVersion(CabalSpecV2_4) )
import Distribution.Pretty
( Pretty(..), pretty, prettyShow )
#if MIN_VERSION_Cabal(3,7,0)
import Distribution.Fields.Pretty
( pattern NoComment )
#endif
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively, instead of #if, we could burn the bridges and drop Cabal-3.6 entirely.

import qualified Text.PrettyPrint as Disp

import Distribution.Parsec
Expand Down Expand Up @@ -311,7 +317,13 @@ intPair = do
-- Pretty-printing

show :: BuildReport -> String
show = showFields (const []) . prettyFieldGrammar CabalSpecV2_4 fieldDescrs
show = showFields noComment . prettyFieldGrammar CabalSpecV2_4 fieldDescrs
where
#if MIN_VERSION_Cabal(3,7,0)
noComment _ = NoComment
#else
noComment _ = []
#endif

-- -----------------------------------------------------------------------------
-- Description of the fields, for parsing/printing
Expand Down
6 changes: 6 additions & 0 deletions src/Distribution/Server/Framework/Instances.hs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ instance SafeCopy OS where
putCopy Ghcjs = contain $ putWord8 14
putCopy Hurd = contain $ putWord8 15
putCopy Android = contain $ putWord8 16
putCopy Wasi = contain $ putWord8 17

getCopy = contain $ do
tag <- getWord8
Expand All @@ -157,6 +158,7 @@ instance SafeCopy OS where
14 -> return Ghcjs
15 -> return Hurd
16 -> return Android
17 -> return Wasi
_ -> fail "SafeCopy OS getCopy: unexpected tag"

instance SafeCopy Arch where
Expand All @@ -180,6 +182,8 @@ instance SafeCopy Arch where
putCopy Vax = contain $ putWord8 15
putCopy JavaScript = contain $ putWord8 16
putCopy AArch64 = contain $ putWord8 17
putCopy S390X = contain $ putWord8 18
putCopy Wasm32 = contain $ putWord8 19

getCopy = contain $ do
tag <- getWord8
Expand All @@ -202,6 +206,8 @@ instance SafeCopy Arch where
15 -> return Vax
16 -> return JavaScript
17 -> return AArch64
18 -> return S390X
19 -> return Wasm32
_ -> fail "SafeCopy Arch getCopy: unexpected tag"

instance SafeCopy CompilerFlavor where
Expand Down
25 changes: 23 additions & 2 deletions src/Distribution/Server/Util/CabalRevisions.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-}
Expand Down Expand Up @@ -39,6 +40,9 @@ import Distribution.Version
import Distribution.Compiler (CompilerFlavor)
import Distribution.FieldGrammar (prettyFieldGrammar)
import Distribution.Fields.Pretty (PrettyField (..), showFields)
#if MIN_VERSION_Cabal(3,7,0)
import Distribution.Fields.Pretty (pattern NoComment)
#endif
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want this file to remain in sync with its copy in hackage-cli, so the CPP would stay here.

import Distribution.PackageDescription
import Distribution.PackageDescription.Parsec (parseGenericPackageDescription, runParseResult)
import Distribution.PackageDescription.FieldGrammar (sourceRepoFieldGrammar)
Expand Down Expand Up @@ -340,7 +344,7 @@ checkPackageDescriptions checkXRevision
checkSame "The package-url field is unused, don't bother changing it."
pkgUrlA pkgUrlB
changesOk "bug-reports" fromShortText bugReportsA bugReportsB
changesOkList changesOk "source-repository" (showFields (const []) . (:[]) . ppSourceRepo)
changesOkList changesOk "source-repository" (showFields noComment . (:[]) . ppSourceRepo)
sourceReposA sourceReposB
changesOk "synopsis" fromShortText synopsisA synopsisB
changesOk "description" fromShortText descriptionA descriptionB
Expand All @@ -365,6 +369,12 @@ checkPackageDescriptions checkXRevision

when checkXRevision $ checkRevision customFieldsPDA customFieldsPDB
checkCuration customFieldsPDA customFieldsPDB
where
#if MIN_VERSION_Cabal(3,7,0)
noComment _ = NoComment
#else
noComment _ = []
#endif

checkSpecVersionRaw :: Check PackageDescription
checkSpecVersionRaw pdA pdB
Expand Down Expand Up @@ -625,10 +635,20 @@ checkExecutable componentName

checkTestSuite :: ComponentName -> Check TestSuite
checkTestSuite componentName
#if MIN_VERSION_Cabal(3,7,0)
(TestSuite _nameA interfaceA buildInfoA testGeneratorsA)
(TestSuite _nameB interfaceB buildInfoB testGeneratorsB)
#else
(TestSuite _nameA interfaceA buildInfoA)
(TestSuite _nameB interfaceB buildInfoB) = do
(TestSuite _nameB interfaceB buildInfoB)
#endif
= do
checkSame "Cannot change test-suite type" interfaceA interfaceB
checkBuildInfo componentName buildInfoA buildInfoB
#if MIN_VERSION_Cabal(3,7,0)
-- @test-generators@
checkSame "Cannot change test-generators" testGeneratorsA testGeneratorsB
#endif

checkBenchmark :: ComponentName -> Check Benchmark
checkBenchmark componentName
Expand Down Expand Up @@ -690,6 +710,7 @@ changesOkSet what render old new = do
logChange (Change Normal ("removed " ++ what) (renderSet removed) "")
unless (Set.null added) $
logChange (Change Normal ("added " ++ what) "" (renderSet added))
return ()
where
added = new Set.\\ old
removed = old Set.\\ new
Expand Down