Skip to content

Commit

Permalink
Drop support for pre-8.0 GHCs
Browse files Browse the repository at this point in the history
  • Loading branch information
RyanGlScott committed Oct 26, 2024
1 parent 4ac74c9 commit 7284791
Show file tree
Hide file tree
Showing 19 changed files with 120 additions and 240 deletions.
113 changes: 45 additions & 68 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.16.2
# version: 0.19.20240708
#
# REGENDATA ("0.16.2",["github","--config=cabal.haskell-ci","cabal.project"])
# REGENDATA ("0.19.20240708",["github","--config=cabal.haskell-ci","cabal.project"])
#
name: Haskell-CI
on:
Expand All @@ -23,24 +23,34 @@ jobs:
timeout-minutes:
60
container:
image: buildpack-deps:bionic
image: buildpack-deps:jammy
continue-on-error: ${{ matrix.allow-failure }}
strategy:
matrix:
include:
- compiler: ghc-9.6.1
- compiler: ghc-9.10.1
compilerKind: ghc
compilerVersion: 9.6.1
compilerVersion: 9.10.1
setup-method: ghcup
allow-failure: false
- compiler: ghc-9.4.5
- compiler: ghc-9.8.2
compilerKind: ghc
compilerVersion: 9.4.5
compilerVersion: 9.8.2
setup-method: ghcup
allow-failure: false
- compiler: ghc-9.2.7
- compiler: ghc-9.6.6
compilerKind: ghc
compilerVersion: 9.2.7
compilerVersion: 9.6.6
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
compilerKind: ghc
compilerVersion: 9.2.8
setup-method: ghcup
allow-failure: false
- compiler: ghc-9.0.2
Expand All @@ -56,69 +66,39 @@ jobs:
- compiler: ghc-8.8.4
compilerKind: ghc
compilerVersion: 8.8.4
setup-method: hvr-ppa
setup-method: ghcup
allow-failure: false
- compiler: ghc-8.6.5
compilerKind: ghc
compilerVersion: 8.6.5
setup-method: hvr-ppa
setup-method: ghcup
allow-failure: false
- compiler: ghc-8.4.4
compilerKind: ghc
compilerVersion: 8.4.4
setup-method: hvr-ppa
setup-method: ghcup
allow-failure: false
- compiler: ghc-8.2.2
compilerKind: ghc
compilerVersion: 8.2.2
setup-method: hvr-ppa
setup-method: ghcup
allow-failure: false
- compiler: ghc-8.0.2
compilerKind: ghc
compilerVersion: 8.0.2
setup-method: hvr-ppa
allow-failure: false
- compiler: ghc-7.10.3
compilerKind: ghc
compilerVersion: 7.10.3
setup-method: hvr-ppa
allow-failure: false
- compiler: ghc-7.8.4
compilerKind: ghc
compilerVersion: 7.8.4
setup-method: hvr-ppa
allow-failure: false
- compiler: ghc-7.6.3
compilerKind: ghc
compilerVersion: 7.6.3
setup-method: hvr-ppa
allow-failure: false
- compiler: ghc-7.4.2
compilerKind: ghc
compilerVersion: 7.4.2
setup-method: hvr-ppa
setup-method: ghcup
allow-failure: false
fail-fast: false
steps:
- name: apt
run: |
apt-get update
apt-get install -y --no-install-recommends gnupg ca-certificates dirmngr curl git software-properties-common libtinfo5
if [ "${{ matrix.setup-method }}" = ghcup ]; then
mkdir -p "$HOME/.ghcup/bin"
curl -sL https://downloads.haskell.org/ghcup/0.1.19.2/x86_64-linux-ghcup-0.1.19.2 > "$HOME/.ghcup/bin/ghcup"
chmod a+x "$HOME/.ghcup/bin/ghcup"
"$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)
else
apt-add-repository -y 'ppa:hvr/ghc'
apt-get update
apt-get install -y "$HCNAME"
mkdir -p "$HOME/.ghcup/bin"
curl -sL https://downloads.haskell.org/ghcup/0.1.19.2/x86_64-linux-ghcup-0.1.19.2 > "$HOME/.ghcup/bin/ghcup"
chmod a+x "$HOME/.ghcup/bin/ghcup"
"$HOME/.ghcup/bin/ghcup" install cabal 3.10.1.0 || (cat "$HOME"/.ghcup/logs/*.* && false)
fi
apt-get install -y --no-install-recommends gnupg ca-certificates dirmngr curl git software-properties-common libtinfo5 libnuma-dev
mkdir -p "$HOME/.ghcup/bin"
curl -sL https://downloads.haskell.org/ghcup/0.1.30.0/x86_64-linux-ghcup-0.1.30.0 > "$HOME/.ghcup/bin/ghcup"
chmod a+x "$HOME/.ghcup/bin/ghcup"
"$HOME/.ghcup/bin/ghcup" install ghc "$HCVER" || (cat "$HOME"/.ghcup/logs/*.* && false)
"$HOME/.ghcup/bin/ghcup" install cabal 3.12.1.0 || (cat "$HOME"/.ghcup/logs/*.* && false)
env:
HCKIND: ${{ matrix.compilerKind }}
HCNAME: ${{ matrix.compiler }}
Expand All @@ -130,20 +110,13 @@ jobs:
echo "CABAL_DIR=$HOME/.cabal" >> "$GITHUB_ENV"
echo "CABAL_CONFIG=$HOME/.cabal/config" >> "$GITHUB_ENV"
HCDIR=/opt/$HCKIND/$HCVER
if [ "${{ matrix.setup-method }}" = ghcup ]; then
HC=$HOME/.ghcup/bin/$HCKIND-$HCVER
echo "HC=$HC" >> "$GITHUB_ENV"
echo "HCPKG=$HOME/.ghcup/bin/$HCKIND-pkg-$HCVER" >> "$GITHUB_ENV"
echo "HADDOCK=$HOME/.ghcup/bin/haddock-$HCVER" >> "$GITHUB_ENV"
echo "CABAL=$HOME/.ghcup/bin/cabal-3.10.1.0 -vnormal+nowrap" >> "$GITHUB_ENV"
else
HC=$HCDIR/bin/$HCKIND
echo "HC=$HC" >> "$GITHUB_ENV"
echo "HCPKG=$HCDIR/bin/$HCKIND-pkg" >> "$GITHUB_ENV"
echo "HADDOCK=$HCDIR/bin/haddock" >> "$GITHUB_ENV"
echo "CABAL=$HOME/.ghcup/bin/cabal-3.10.1.0 -vnormal+nowrap" >> "$GITHUB_ENV"
fi
HC=$("$HOME/.ghcup/bin/ghcup" whereis ghc "$HCVER")
HCPKG=$(echo "$HC" | sed 's#ghc$#ghc-pkg#')
HADDOCK=$(echo "$HC" | sed 's#ghc$#haddock#')
echo "HC=$HC" >> "$GITHUB_ENV"
echo "HCPKG=$HCPKG" >> "$GITHUB_ENV"
echo "HADDOCK=$HADDOCK" >> "$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 @@ -200,7 +173,7 @@ jobs:
chmod a+x $HOME/.cabal/bin/cabal-plan
cabal-plan --version
- name: checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
path: source
- name: initial cabal.project for sdist
Expand Down Expand Up @@ -248,15 +221,15 @@ jobs:
package criterion-examples
ghc-options: -Werror
EOF
$HCPKG list --simple-output --names-only | perl -ne 'for (split /\s+/) { print "constraints: $_ installed\n" unless /^(criterion|criterion-examples|criterion-measurement)$/; }' >> cabal.project.local
$HCPKG list --simple-output --names-only | perl -ne 'for (split /\s+/) { print "constraints: any.$_ installed\n" unless /^(criterion|criterion-examples|criterion-measurement)$/; }' >> cabal.project.local
cat cabal.project
cat cabal.project.local
- name: dump install plan
run: |
$CABAL v2-build $ARG_COMPILER $ARG_TESTS $ARG_BENCH --dry-run all
cabal-plan
- name: restore cache
uses: actions/cache/restore@v3
uses: actions/cache/restore@v4
with:
key: ${{ runner.os }}-${{ matrix.compiler }}-${{ github.sha }}
path: ~/.cabal/store
Expand All @@ -279,17 +252,21 @@ jobs:
rm -f cabal.project.local
- name: constraint set fast
run: |
$CABAL v2-build $ARG_COMPILER --enable-tests --disable-benchmarks --constraint='criterion-measurement +fast' --constraint='criterion +fast' all --dry-run
cabal-plan topo | sort
$CABAL v2-build $ARG_COMPILER --enable-tests --disable-benchmarks --constraint='criterion-measurement +fast' --constraint='criterion +fast' --dependencies-only -j2 all
$CABAL v2-build $ARG_COMPILER --enable-tests --disable-benchmarks --constraint='criterion-measurement +fast' --constraint='criterion +fast' all
$CABAL v2-test $ARG_COMPILER --enable-tests --disable-benchmarks --constraint='criterion-measurement +fast' --constraint='criterion +fast' all
- name: constraint set embed-data-files
run: |
$CABAL v2-build $ARG_COMPILER --enable-tests --enable-benchmarks --constraint='criterion +embed-data-files' all --dry-run
cabal-plan topo | sort
$CABAL v2-build $ARG_COMPILER --enable-tests --enable-benchmarks --constraint='criterion +embed-data-files' --dependencies-only -j2 all
$CABAL v2-build $ARG_COMPILER --enable-tests --enable-benchmarks --constraint='criterion +embed-data-files' all
$CABAL v2-test $ARG_COMPILER --enable-tests --enable-benchmarks --constraint='criterion +embed-data-files' all
$CABAL v2-haddock --disable-documentation --haddock-all $ARG_COMPILER --with-haddock $HADDOCK --enable-tests --enable-benchmarks --constraint='criterion +embed-data-files' all
- name: save cache
uses: actions/cache/save@v3
uses: actions/cache/save@v4
if: always()
with:
key: ${{ runner.os }}-${{ matrix.compiler }}-${{ github.sha }}
Expand Down
17 changes: 1 addition & 16 deletions Criterion/IO.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{-# LANGUAGE Trustworthy #-}
{-# LANGUAGE CPP, OverloadedStrings #-}
{-# LANGUAGE OverloadedStrings #-}

-- |
-- Module : Criterion.IO
Expand Down Expand Up @@ -28,11 +28,7 @@ module Criterion.IO

import qualified Data.Aeson as Aeson
import Data.Binary (Binary(..), encode)
#if MIN_VERSION_binary(0, 6, 3)
import Data.Binary.Get (runGetOrFail)
#else
import Data.Binary.Get (runGetState)
#endif
import Data.Binary.Put (putByteString, putWord16be, runPut)
import qualified Data.ByteString.Char8 as B
import Criterion.Types (Report(..))
Expand Down Expand Up @@ -81,7 +77,6 @@ readRecords path = withFile path ReadMode hGetRecords
writeRecords :: Binary a => FilePath -> [a] -> IO ()
writeRecords path rs = withFile path WriteMode (flip hPutRecords rs)

#if MIN_VERSION_binary(0, 6, 3)
readAll :: Binary a => Handle -> IO [a]
readAll handle = do
let go bs
Expand All @@ -90,16 +85,6 @@ readAll handle = do
Left (_, _, err) -> fail err
Right (bs', _, a) -> (a:) `fmap` go bs'
go =<< L.hGetContents handle
#else
readAll :: Binary a => Handle -> IO [a]
readAll handle = do
let go i bs
| L.null bs = return []
| otherwise =
let (a, bs', i') = runGetState get bs i
in (a:) `fmap` go i' bs'
go 0 =<< L.hGetContents handle
#endif

-- | On disk we store (name,version,reports), where
-- 'version' is the version of Criterion used to generate the file.
Expand Down
6 changes: 3 additions & 3 deletions Criterion/Main/Options.hs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import Criterion.Analysis (validateAccessors)
import Criterion.Types (Config(..), Verbosity(..), measureAccessors,
measureKeys)
import Data.Char (isSpace, toLower)
import Data.Data (Data, Typeable)
import Data.Data (Data)
import Data.Int (Int64)
import Data.List (isPrefixOf)
import Data.Version (showVersion)
Expand Down Expand Up @@ -60,7 +60,7 @@ data MatchType = Prefix
-- paths.
| IPattern
-- ^ Same as 'Pattern', but case insensitive.
deriving (Eq, Ord, Bounded, Enum, Read, Show, Typeable, Data,
deriving (Eq, Ord, Bounded, Enum, Read, Show, Data,
Generic)

-- | Execution mode for a benchmark program.
Expand All @@ -73,7 +73,7 @@ data Mode = List
-- analysing performance numbers.
| Run Config MatchType [String]
-- ^ Run and analyse the given benchmarks.
deriving (Eq, Read, Show, Typeable, Data, Generic)
deriving (Eq, Read, Show, Data, Generic)

-- | Default benchmarking configuration.
defaultConfig :: Config
Expand Down
32 changes: 7 additions & 25 deletions Criterion/Report.hs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ import Control.Monad.Reader (ask)
import Criterion.Monad (Criterion)
import Criterion.Types
import Data.Aeson (ToJSON (..), Value(..), object, (.=), Value)
import qualified Data.Aeson.Key as Key
import Data.Aeson.Text (encodeToLazyText)
import Data.Data (Data, Typeable)
import Data.Data (Data)
import Data.Foldable (forM_)
import GHC.Generics (Generic)
import Paths_criterion (getDataFileName)
Expand Down Expand Up @@ -70,10 +71,6 @@ import qualified Data.Text.Encoding as TE
import qualified Language.Javascript.Chart as Chart
#endif

#if MIN_VERSION_aeson(2,0,0)
import qualified Data.Aeson.Key as Key
#endif

-- | Trim long flat tails from a KDE plot.
tidyTails :: KDE -> KDE
tidyTails KDE{..} = KDE { kdeType = kdeType
Expand Down Expand Up @@ -225,7 +222,7 @@ vector :: (G.Vector v a, ToJSON a) =>
-> Value
{-# SPECIALIZE vector :: T.Text -> U.Vector Double -> Value #-}
vector name v = toJSON . map val . G.toList $ v where
val i = object [ toKey name .= i ]
val i = object [ Key.fromText name .= i ]


-- | Render the elements of two vectors.
Expand All @@ -239,19 +236,10 @@ vector2 :: (G.Vector v a, G.Vector v b, ToJSON a, ToJSON b) =>
-> Value #-}
vector2 name1 name2 v1 v2 = toJSON $ zipWith val (G.toList v1) (G.toList v2) where
val i j = object
[ toKey name1 .= i
, toKey name2 .= j
[ Key.fromText name1 .= i
, Key.fromText name2 .= j
]

#if MIN_VERSION_aeson(2,0,0)
toKey :: T.Text -> Key.Key
toKey = Key.fromText
#else
toKey :: T.Text -> T.Text
toKey = id
#endif


-- | Attempt to include the contents of a file based on a search path.
-- Returns 'B.empty' if the search fails or the file could not be read.
--
Expand All @@ -275,7 +263,7 @@ includeFile searchPath name = liftIO $ foldr go (return T.empty) searchPath
-- | A problem arose with a template.
data TemplateException =
TemplateNotFound FilePath -- ^ The template could not be found.
deriving (Eq, Read, Show, Typeable, Data, Generic)
deriving (Eq, Read, Show, Data, Generic)

instance Exception TemplateException

Expand Down Expand Up @@ -320,12 +308,6 @@ readFileCheckEmbedded fp =
#if defined(EMBED)
`E.catch` \(e :: IOException) ->
maybe (throwIO e)
(pure . TLE.decodeUtf8 . fromStrict)
(pure . TLE.decodeUtf8 . BL.fromStrict)
(lookup fp dataFiles)
where
# if MIN_VERSION_bytestring(0,10,0)
fromStrict = BL.fromStrict
# else
fromStrict x = BL.fromChunks [x]
# endif
#endif
Loading

0 comments on commit 7284791

Please sign in to comment.