Skip to content

Commit

Permalink
Include fixes for version 0.2 into master.
Browse files Browse the repository at this point in the history
  • Loading branch information
merijn committed Dec 1, 2021
2 parents 4ce448f + 14acd31 commit f04eeb0
Show file tree
Hide file tree
Showing 22 changed files with 167 additions and 82 deletions.
65 changes: 51 additions & 14 deletions .github/workflows/haskell-ci.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# This GitHub workflow config has been generated by a script via
#
# haskell-ci 'github' 'cabal.project'
# haskell-ci 'github' '--config' 'cabal.haskell-ci' 'cabal.project'
#
# To regenerate the script (for example after adjusting tested-with) run
#
# haskell-ci regenerate
#
# For more information, see https://github.com/haskell-CI/haskell-ci
#
# version: 0.13.20210621
# version: 0.13.20211116
#
# REGENDATA ("0.13.20210621",["github","cabal.project"])
# REGENDATA ("0.13.20211116",["github","--config","cabal.haskell-ci","cabal.project"])
#
name: Haskell-CI
on:
Expand All @@ -20,17 +20,29 @@ jobs:
linux:
name: Haskell-CI - Linux - ${{ matrix.compiler }}
runs-on: ubuntu-18.04
timeout-minutes:
60
container:
image: buildpack-deps:bionic
continue-on-error: ${{ matrix.allow-failure }}
strategy:
matrix:
include:
- compiler: ghc-8.10.2
- compiler: ghc-9.2.1
compilerKind: ghc
compilerVersion: 8.10.2
compilerVersion: 9.2.1
setup-method: ghcup
allow-failure: false
- compiler: ghc-9.0.1
compilerKind: ghc
compilerVersion: 9.0.1
setup-method: hvr-ppa
allow-failure: false
- compiler: ghc-8.10.7
compilerKind: ghc
compilerVersion: 8.10.7
setup-method: ghcup
allow-failure: false
- compiler: ghc-8.8.4
compilerKind: ghc
compilerVersion: 8.8.4
Expand Down Expand Up @@ -62,9 +74,21 @@ jobs:
run: |
apt-get update
apt-get install -y --no-install-recommends gnupg ca-certificates dirmngr curl git software-properties-common libtinfo5
apt-add-repository -y 'ppa:hvr/ghc'
apt-get update
apt-get install -y "$HCNAME" cabal-install-3.4
if [ "${{ matrix.setup-method }}" = ghcup ]; then
mkdir -p "$HOME/.ghcup/bin"
curl -sL https://downloads.haskell.org/ghcup/0.1.17.3/x86_64-linux-ghcup-0.1.17.3 > "$HOME/.ghcup/bin/ghcup"
chmod a+x "$HOME/.ghcup/bin/ghcup"
"$HOME/.ghcup/bin/ghcup" install ghc "$HCVER"
"$HOME/.ghcup/bin/ghcup" install cabal 3.6.2.0
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.17.3/x86_64-linux-ghcup-0.1.17.3 > "$HOME/.ghcup/bin/ghcup"
chmod a+x "$HOME/.ghcup/bin/ghcup"
"$HOME/.ghcup/bin/ghcup" install cabal 3.6.2.0
fi
env:
HCKIND: ${{ matrix.compilerKind }}
HCNAME: ${{ matrix.compiler }}
Expand All @@ -76,16 +100,25 @@ jobs:
echo "CABAL_DIR=$HOME/.cabal" >> "$GITHUB_ENV"
echo "CABAL_CONFIG=$HOME/.cabal/config" >> "$GITHUB_ENV"
HCDIR=/opt/$HCKIND/$HCVER
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=/opt/cabal/3.4/bin/cabal -vnormal+nowrap" >> "$GITHUB_ENV"
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.6.2.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.6.2.0 -vnormal+nowrap" >> "$GITHUB_ENV"
fi
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"
echo "ARG_BENCH=--enable-benchmarks" >> "$GITHUB_ENV"
if [ $((HCNUMVER > 81002)) -ne 0 ] ; then echo "HEADHACKAGE=true" >> "$GITHUB_ENV" ; else echo "HEADHACKAGE=false" >> "$GITHUB_ENV" ; fi
if [ $((HCNUMVER > 90201)) -ne 0 ] ; then echo "HEADHACKAGE=true" >> "$GITHUB_ENV" ; else echo "HEADHACKAGE=false" >> "$GITHUB_ENV" ; fi
echo "ARG_COMPILER=--$HCKIND --with-compiler=$HC" >> "$GITHUB_ENV"
echo "GHCJSARITH=0" >> "$GITHUB_ENV"
env:
Expand Down Expand Up @@ -125,6 +158,10 @@ jobs:
key-threshold: 3
EOF
fi
cat >> $CABAL_CONFIG <<EOF
program-default-options
ghc-options: $GHCJOBS +RTS -M3G -RTS
EOF
cat $CABAL_CONFIG
- name: versions
run: |
Expand Down
2 changes: 1 addition & 1 deletion broadcast-chan-conduit/BroadcastChan/Conduit.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
-------------------------------------------------------------------------------
-- |
-- Module : BroadcastChan.Conduit
-- Copyright : (C) 2014-2020 Merijn Verstraaten
-- Copyright : (C) 2014-2021 Merijn Verstraaten
-- License : BSD-style (see the file LICENSE)
-- Maintainer : Merijn Verstraaten <[email protected]>
-- Stability : experimental
Expand Down
2 changes: 1 addition & 1 deletion broadcast-chan-conduit/BroadcastChan/Conduit/Throw.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
-------------------------------------------------------------------------------
-- |
-- Module : BroadcastChan.Conduit.Throw
-- Copyright : (C) 2014-2020 Merijn Verstraaten
-- Copyright : (C) 2014-2021 Merijn Verstraaten
-- License : BSD-style (see the file LICENSE)
-- Maintainer : Merijn Verstraaten <[email protected]>
-- Stability : experimental
Expand Down
6 changes: 6 additions & 0 deletions broadcast-chan-conduit/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
* Add missing reexports of `readBChan`, `writeBChan`, and `BChanError` to
`BroadcastChan.Pipes` and `BroadcastChan.Pipes.Throw`.

0.2.1.2 [2021.12.01]
--------------------
* Updated bounds for GHC 9.0 and 9.2.
* Tighten bound on broadcast-chan to only use version with fixed race
condition.

0.2.1.1 [2020.03.05]
--------------------
* Updated imports to support `unliftio-core` 0.2.x
Expand Down
2 changes: 1 addition & 1 deletion broadcast-chan-conduit/LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2013-2020, Merijn Verstraaten
Copyright (c) 2013-2021, Merijn Verstraaten

All rights reserved.

Expand Down
12 changes: 6 additions & 6 deletions broadcast-chan-conduit/broadcast-chan-conduit.cabal
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
Cabal-Version: 2.2
Name: broadcast-chan-conduit
Version: 0.3.0

Expand All @@ -6,16 +7,15 @@ Bug-Reports: https://github.com/merijn/broadcast-chan/issues

Author: Merijn Verstraaten
Maintainer: Merijn Verstraaten <[email protected]>
Copyright: Copyright © 2014-2020 Merijn Verstraaten
Copyright: Copyright © 2014-2021 Merijn Verstraaten

License: BSD3
License: BSD-3-Clause
License-File: LICENSE

Category: System
Cabal-Version: >= 1.10
Build-Type: Simple
Tested-With: GHC == 8.0.2, GHC == 8.2.2, GHC == 8.4.4, GHC == 8.6.5,
GHC == 8.8.4, GHC == 8.10.2
GHC == 8.8.4, GHC == 8.10.7, GHC == 9.0.1, GHC == 9.2.1

Extra-Source-Files: CHANGELOG.md

Expand All @@ -38,11 +38,11 @@ Library
ScopedTypeVariables
Trustworthy

Build-Depends: base >= 4.8 && < 4.15
Build-Depends: base >= 4.8 && < 4.17
, broadcast-chan == 0.3.0.*
, conduit >= 1.2 && < 1.4
, resourcet >= 1.1 && < 1.3
, transformers >= 0.2 && < 0.6
, transformers >= 0.2 && < 0.7
, unliftio-core >= 0.1 && < 0.3

Test-Suite conduit
Expand Down
2 changes: 1 addition & 1 deletion broadcast-chan-pipes/BroadcastChan/Pipes.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
-------------------------------------------------------------------------------
-- |
-- Module : BroadcastChan.Pipes
-- Copyright : (C) 2014-2020 Merijn Verstraaten
-- Copyright : (C) 2014-2021 Merijn Verstraaten
-- License : BSD-style (see the file LICENSE)
-- Maintainer : Merijn Verstraaten <[email protected]>
-- Stability : experimental
Expand Down
2 changes: 1 addition & 1 deletion broadcast-chan-pipes/BroadcastChan/Pipes/Throw.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
-------------------------------------------------------------------------------
-- |
-- Module : BroadcastChan.Pipes.Throw
-- Copyright : (C) 2014-2020 Merijn Verstraaten
-- Copyright : (C) 2014-2021 Merijn Verstraaten
-- License : BSD-style (see the file LICENSE)
-- Maintainer : Merijn Verstraaten <[email protected]>
-- Stability : experimental
Expand Down
6 changes: 6 additions & 0 deletions broadcast-chan-pipes/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
* Add missing reexports of `readBChan`, `writeBChan`, and `BChanError` to
`BroadcastChan.Pipes` and `BroadcastChan.Pipes.Throw`.

0.2.1.1 [2021.12.01]
--------------------
* Updated bounds for GHC 9.0 and 9.2.
* Tighten bound on broadcast-chan to only use version with fixed race
condition.

0.2.1 [2019.11.17]
------------------
* Bump for new broadcast-chan release.
Expand Down
2 changes: 1 addition & 1 deletion broadcast-chan-pipes/LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2013-2020, Merijn Verstraaten
Copyright (c) 2013-2021, Merijn Verstraaten

All rights reserved.

Expand Down
10 changes: 5 additions & 5 deletions broadcast-chan-pipes/broadcast-chan-pipes.cabal
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
Cabal-Version: 2.2
Name: broadcast-chan-pipes
Version: 0.3.0

Expand All @@ -6,16 +7,15 @@ Bug-Reports: https://github.com/merijn/broadcast-chan/issues

Author: Merijn Verstraaten
Maintainer: Merijn Verstraaten <[email protected]>
Copyright: Copyright © 2014-2020 Merijn Verstraaten
Copyright: Copyright © 2014-2021 Merijn Verstraaten

License: BSD3
License: BSD-3-Clause
License-File: LICENSE

Category: System
Cabal-Version: >= 1.10
Build-Type: Simple
Tested-With: GHC == 8.0.2, GHC == 8.2.2, GHC == 8.4.4, GHC == 8.6.5,
GHC == 8.8.4, GHC == 8.10.2
GHC == 8.8.4, GHC == 8.10.7, GHC == 9.0.1, GHC == 9.2.1

Synopsis: Pipes-based parallel streaming code for broadcast-chan

Expand All @@ -35,7 +35,7 @@ Library
Safe
ScopedTypeVariables

Build-Depends: base >= 4.8 && < 4.15
Build-Depends: base >= 4.8 && < 4.17
, broadcast-chan == 0.3.0.*
, pipes >= 4.1.6 && < 4.4
, pipes-safe >= 2.2 && < 2.4
Expand Down
37 changes: 32 additions & 5 deletions broadcast-chan-tests/BroadcastChan/Test.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
-------------------------------------------------------------------------------
-- |
-- Module : BroadcastChan.Test
-- Copyright : (C) 2014-2020 Merijn Verstraaten
-- Copyright : (C) 2014-2021 Merijn Verstraaten
-- License : BSD-style (see the file LICENSE)
-- Maintainer : Merijn Verstraaten <[email protected]>
-- Stability : experimental
Expand All @@ -26,9 +26,10 @@ module BroadcastChan.Test
) where

import Prelude hiding (seq)
import Control.Concurrent (setNumCapabilities, threadDelay)
import Control.Concurrent (forkIO, setNumCapabilities, threadDelay)
import Control.Concurrent.Async (wait, withAsync)
import Control.Concurrent.MVar
import Control.Concurrent.QSemN
import Control.Concurrent.STM
import Control.Monad (void, when)
import Control.Monad.IO.Class (MonadIO(liftIO))
Expand Down Expand Up @@ -98,6 +99,14 @@ doDrop predicate hnd val
| predicate val = throwIO TestException
| otherwise = doPrint hnd val

doRace :: MVar () -> QSemN -> a -> IO a
doRace mvar sem _ = do
result <- tryReadMVar mvar
case result of
Nothing -> signalQSemN sem 1 >> readMVar mvar
Just () -> return ()
throwIO TestException

fromTimeSpec :: Fractional n => TimeSpec -> n
fromTimeSpec = fromIntegral . toNanoSecs

Expand Down Expand Up @@ -247,6 +256,20 @@ terminationTest parImpl = testCase "termination" $
withSystemTempFile "terminate.out" $ \_ hndl ->
parImpl (Simple Terminate) [1..100] (doDrop even hndl) 4

raceTest
:: (Handler IO Int -> [Int] -> (Int -> IO Int) -> Int -> IO r) -> TestTree
raceTest parImpl = testCase "race" $
expect TestException . void $ do
sem <- newQSemN 0
mvar <- newEmptyMVar
forkIO $ do
waitQSemN sem parCount
putMVar mvar ()
parImpl (Simple Terminate) [1..100] (doRace mvar sem) parCount
where
parCount :: Int
parCount = 4

retryTest
:: (Eq r, Show r)
=> ([Int] -> (Int -> IO Int) -> IO r)
Expand Down Expand Up @@ -278,7 +301,7 @@ retryTest seqImpl parImpl = withRetryCheck $ \getRetryCheck ->
dropAfterPrint checkPresence hnd val = do
hPrint hnd val
when (even val) $ do
isNotPresent <- checkPresence >>= ($val)
isNotPresent <- checkPresence >>= ($ val)
when isNotPresent $ throwIO TestException
return val

Expand Down Expand Up @@ -321,15 +344,19 @@ genStreamTests name seq par = askOption $ \(SlowTests slow) ->
bigInputs | slow = derivedParam (enumFromTo 0) "inputs" [600]
| otherwise = derivedParam (enumFromTo 0) "inputs" [300]
smallInputs = derivedParam (enumFromTo 0) "inputs" [0,1,2]
pause = simpleParam "pause" [10^(5 :: Int)]
pause = simpleParam "pause" [10^(4 :: Int)]

in testGroup name
[ testTree "output" (outputTest seq (par term)) $
threads . paramSets [ smallInputs, bigInputs ]
, testTree "speedup" (speedupTest getCache seq (par term)) $
threads . bigInputs . pause
, testGroup "exceptions"
[ dropTest seq par, terminationTest par, retryTest seq par ]
[ dropTest seq par
, terminationTest par
, raceTest par
, retryTest seq par
]
]
where
term = Simple Terminate
Expand Down
4 changes: 4 additions & 0 deletions broadcast-chan-tests/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
--------------------
* Bump for new release of broadcast-chan.

0.2.1.2 [2021.12.01]
--------------------
* Fix errors/warnings for GHC 9.2.

0.2.1.1 [2020.03.05]
--------------------
* Bump for new release of broadcast-chan.
Expand Down
2 changes: 1 addition & 1 deletion broadcast-chan-tests/LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2013-2020, Merijn Verstraaten
Copyright (c) 2013-2021, Merijn Verstraaten

All rights reserved.

Expand Down
Loading

0 comments on commit f04eeb0

Please sign in to comment.