Skip to content

Commit

Permalink
Merge pull request #2 from sorki/srk/ci
Browse files Browse the repository at this point in the history
Add CI
  • Loading branch information
julialongtin authored Nov 15, 2023
2 parents 302c996 + f117696 commit 59cbeff
Show file tree
Hide file tree
Showing 5 changed files with 132 additions and 9 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/ci.dhall
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
let haskellCi =
https://raw.githubusercontent.com/sorki/github-actions-dhall/main/haskell-ci.dhall

in haskellCi.generalCi
haskellCi.defaultCabalSteps
haskellCi.DhallMatrix::{
, ghc =
[ haskellCi.GHC.GHC963
, haskellCi.GHC.GHC947
, haskellCi.GHC.GHC928
, haskellCi.GHC.GHC8107
, haskellCi.GHC.GHC884
]
, cabal = [ haskellCi.Cabal.Cabal310, haskellCi.Cabal.Cabal34 ]
, os = [ haskellCi.OS.Ubuntu2204, haskellCi.OS.Ubuntu2004 ]
}
: haskellCi.CI.Type
12 changes: 12 additions & 0 deletions .github/workflows/ci.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash
# Script by @fisx

set -eo pipefail

# cd into the dir where this script is placed
cd "$( dirname "${BASH_SOURCE[0]}" )"

echo "regenerating .github/workflows/ci.yaml"

which dhall-to-yaml-ng || cabal install dhall-yaml
dhall-to-yaml-ng --generated-comment --file ci.dhall > ci.yaml
57 changes: 57 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Code generated by dhall-to-yaml. DO NOT EDIT.
jobs:
build:
name: "GHC ${{ matrix.ghc }}, Cabal ${{ matrix.cabal }}, OS ${{ matrix.os }}"
"runs-on": "${{ matrix.os }}"
steps:
- uses: "actions/checkout@v4"
with:
submodules: recursive
- id: "setup-haskell-cabal"
uses: "haskell-actions/setup@v2"
with:
"cabal-version": "${{ matrix.cabal }}"
"ghc-version": "${{ matrix.ghc }}"
- name: Update Hackage repository
run: cabal update
- name: cabal.project.local.ci
run: |
if [ -e cabal.project.local.ci ]; then
cp cabal.project.local.ci cabal.project.local
fi
- name: freeze
run: "cabal freeze --enable-tests --enable-benchmarks"
- uses: "actions/cache@v3"
with:
key: "${{ matrix.os }}-${{ matrix.ghc }}-${{ matrix.cabal}}-${{ hashFiles('cabal.project.freeze') }}"
path: |
${{ steps.setup-haskell-cabal.outputs.cabal-store }}
dist-newstyle
- name: Install dependencies
run: "cabal build all --enable-tests --enable-benchmarks --only-dependencies"
- name: build all
run: "cabal build all --enable-tests --enable-benchmarks"
- name: test all
run: "cabal test all --enable-tests"
- name: haddock all
run: cabal haddock all
strategy:
matrix:
cabal:
- '3.10'
- '3.4'
ghc:
- '9.6.3'
- '9.4.7'
- '9.2.8'
- '8.10.7'
- '8.8.4'
os:
- "ubuntu-22.04"
- "ubuntu-20.04"
name: Haskell CI
'on':
pull_request: {}
push: {}
schedule:
- cron: "4 20 10 * *"
26 changes: 22 additions & 4 deletions src/Data/Bits/Floating/Prim.hs
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,35 @@ import GHC.Word
#define WORD32 Word
#endif

#if WORD_SIZE_IN_BITS == 64
foreign import prim "double2WordBwzh"
double2WordBitwise# :: Double# -> WORD64#
foreign import prim "word2DoubleBwzh"
word2DoubleBitwise# :: WORD64# -> Double#
foreign import prim "float2WordBwzh"
float2WordBitwise# :: Float# -> WORD32#
foreign import prim "word2FloatBwzh"
word2FloatBitwise# :: WORD32# -> Float#
#elif WORD_SIZE_IN_BITS == 32
foreign import prim "double2WordBwzh"
double2WordBitwise# :: Double# -> WORD32#
foreign import prim "word2DoubleBwzh"
word2DoubleBitwise# :: WORD32# -> Double#
#else
#error "Unsupported word size"
#endif

#undef WORD64
#undef WORD32

#if MIN_VERSION_base(4,15,0)
foreign import prim "float2WordBwzh"
float2WordBitwise# :: Float# -> Word32#
foreign import prim "word2FloatBwzh"
word2FloatBitwise# :: Word32# -> Float#
#else
foreign import prim "float2WordBwzh"
float2WordBitwise# :: Float# -> Word#
foreign import prim "word2FloatBwzh"
word2FloatBitwise# :: Word# -> Float#
#endif

-- | Convert a 'Double' to a 'Word64' while preserving the bit-pattern.
{-# INLINE double2WordBitwise #-}
double2WordBitwise :: Double -> Word64
Expand All @@ -64,3 +81,4 @@ float2WordBitwise (F# f) = W32# (float2WordBitwise# f)
{-# INLINE word2FloatBitwise #-}
word2FloatBitwise :: Word32 -> Float
word2FloatBitwise (W32# w) = F# (word2FloatBitwise# w)

29 changes: 24 additions & 5 deletions test/Test.hs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,16 @@ debug = False
-- test if coercion between these values works.
{-# SPECIALIZE testCoercion :: (Float, Word32) -> IO () #-}
{-# SPECIALIZE testCoercion :: (Double, Word64) -> IO () #-}
testCoercion :: (Show f, Show w, Integral w, RealFloat f, FloatingBits f w, Monad m) => (f, w) -> m ()
testCoercion
:: ( Show f
, Show w
, Integral w
, RealFloat f
, FloatingBits f w
, MonadFail m
)
=> (f, w)
-> m ()
testCoercion (f, w) = do
let w' = coerceToWord f

Check warning on line 43 in test/Test.hs

View workflow job for this annotation

GitHub Actions / GHC 8.10.7, Cabal 3.10, OS ubuntu-20.04

• The Monomorphism Restriction applies to the binding for ‘w'’

Check warning on line 43 in test/Test.hs

View workflow job for this annotation

GitHub Actions / GHC 8.10.7, Cabal 3.10, OS ubuntu-22.04

• The Monomorphism Restriction applies to the binding for ‘w'’

Check warning on line 43 in test/Test.hs

View workflow job for this annotation

GitHub Actions / GHC 9.2.8, Cabal 3.10, OS ubuntu-20.04

• The Monomorphism Restriction applies to the binding for ‘w'’

Check warning on line 43 in test/Test.hs

View workflow job for this annotation

GitHub Actions / GHC 8.8.4, Cabal 3.10, OS ubuntu-20.04

• The Monomorphism Restriction applies to the binding for ‘w'’

Check warning on line 43 in test/Test.hs

View workflow job for this annotation

GitHub Actions / GHC 8.8.4, Cabal 3.10, OS ubuntu-22.04

• The Monomorphism Restriction applies to the binding for ‘w'’

Check warning on line 43 in test/Test.hs

View workflow job for this annotation

GitHub Actions / GHC 9.2.8, Cabal 3.10, OS ubuntu-22.04

• The Monomorphism Restriction applies to the binding for ‘w'’

Check warning on line 43 in test/Test.hs

View workflow job for this annotation

GitHub Actions / GHC 8.10.7, Cabal 3.4, OS ubuntu-22.04

• The Monomorphism Restriction applies to the binding for ‘w'’

Check warning on line 43 in test/Test.hs

View workflow job for this annotation

GitHub Actions / GHC 8.10.7, Cabal 3.4, OS ubuntu-20.04

• The Monomorphism Restriction applies to the binding for ‘w'’

Check warning on line 43 in test/Test.hs

View workflow job for this annotation

GitHub Actions / GHC 9.2.8, Cabal 3.4, OS ubuntu-20.04

• The Monomorphism Restriction applies to the binding for ‘w'’

Check warning on line 43 in test/Test.hs

View workflow job for this annotation

GitHub Actions / GHC 8.8.4, Cabal 3.4, OS ubuntu-20.04

• The Monomorphism Restriction applies to the binding for ‘w'’

Check warning on line 43 in test/Test.hs

View workflow job for this annotation

GitHub Actions / GHC 8.8.4, Cabal 3.4, OS ubuntu-22.04

• The Monomorphism Restriction applies to the binding for ‘w'’

Check warning on line 43 in test/Test.hs

View workflow job for this annotation

GitHub Actions / GHC 8.10.7, Cabal 3.10, OS ubuntu-22.04

• The Monomorphism Restriction applies to the binding for ‘w'’

Check warning on line 43 in test/Test.hs

View workflow job for this annotation

GitHub Actions / GHC 8.10.7, Cabal 3.10, OS ubuntu-20.04

• The Monomorphism Restriction applies to the binding for ‘w'’

Check warning on line 43 in test/Test.hs

View workflow job for this annotation

GitHub Actions / GHC 9.2.8, Cabal 3.4, OS ubuntu-22.04

• The Monomorphism Restriction applies to the binding for ‘w'’

Check warning on line 43 in test/Test.hs

View workflow job for this annotation

GitHub Actions / GHC 9.2.8, Cabal 3.10, OS ubuntu-20.04

• The Monomorphism Restriction applies to the binding for ‘w'’

Check warning on line 43 in test/Test.hs

View workflow job for this annotation

GitHub Actions / GHC 9.2.8, Cabal 3.10, OS ubuntu-22.04

• The Monomorphism Restriction applies to the binding for ‘w'’

Check warning on line 43 in test/Test.hs

View workflow job for this annotation

GitHub Actions / GHC 8.8.4, Cabal 3.10, OS ubuntu-20.04

• The Monomorphism Restriction applies to the binding for ‘w'’

Check warning on line 43 in test/Test.hs

View workflow job for this annotation

GitHub Actions / GHC 8.8.4, Cabal 3.10, OS ubuntu-22.04

• The Monomorphism Restriction applies to the binding for ‘w'’

Check warning on line 43 in test/Test.hs

View workflow job for this annotation

GitHub Actions / GHC 8.10.7, Cabal 3.4, OS ubuntu-22.04

• The Monomorphism Restriction applies to the binding for ‘w'’

Check warning on line 43 in test/Test.hs

View workflow job for this annotation

GitHub Actions / GHC 8.10.7, Cabal 3.4, OS ubuntu-20.04

• The Monomorphism Restriction applies to the binding for ‘w'’

Check warning on line 43 in test/Test.hs

View workflow job for this annotation

GitHub Actions / GHC 9.2.8, Cabal 3.4, OS ubuntu-20.04

• The Monomorphism Restriction applies to the binding for ‘w'’

Check warning on line 43 in test/Test.hs

View workflow job for this annotation

GitHub Actions / GHC 8.8.4, Cabal 3.4, OS ubuntu-20.04

• The Monomorphism Restriction applies to the binding for ‘w'’

Check warning on line 43 in test/Test.hs

View workflow job for this annotation

GitHub Actions / GHC 8.8.4, Cabal 3.4, OS ubuntu-22.04

• The Monomorphism Restriction applies to the binding for ‘w'’

Check warning on line 43 in test/Test.hs

View workflow job for this annotation

GitHub Actions / GHC 9.2.8, Cabal 3.4, OS ubuntu-22.04

• The Monomorphism Restriction applies to the binding for ‘w'’
f' = coerceToFloat w

Check warning on line 44 in test/Test.hs

View workflow job for this annotation

GitHub Actions / GHC 8.10.7, Cabal 3.10, OS ubuntu-20.04

• The Monomorphism Restriction applies to the binding for ‘f'’

Check warning on line 44 in test/Test.hs

View workflow job for this annotation

GitHub Actions / GHC 8.10.7, Cabal 3.10, OS ubuntu-22.04

• The Monomorphism Restriction applies to the binding for ‘f'’

Check warning on line 44 in test/Test.hs

View workflow job for this annotation

GitHub Actions / GHC 9.2.8, Cabal 3.10, OS ubuntu-20.04

• The Monomorphism Restriction applies to the binding for ‘f'’

Check warning on line 44 in test/Test.hs

View workflow job for this annotation

GitHub Actions / GHC 8.8.4, Cabal 3.10, OS ubuntu-20.04

• The Monomorphism Restriction applies to the binding for ‘f'’

Check warning on line 44 in test/Test.hs

View workflow job for this annotation

GitHub Actions / GHC 8.8.4, Cabal 3.10, OS ubuntu-22.04

• The Monomorphism Restriction applies to the binding for ‘f'’

Check warning on line 44 in test/Test.hs

View workflow job for this annotation

GitHub Actions / GHC 9.6.3, Cabal 3.10, OS ubuntu-20.04

• The Monomorphism Restriction applies to the binding for ‘f'’

Check warning on line 44 in test/Test.hs

View workflow job for this annotation

GitHub Actions / GHC 9.6.3, Cabal 3.10, OS ubuntu-22.04

• The Monomorphism Restriction applies to the binding for ‘f'’

Check warning on line 44 in test/Test.hs

View workflow job for this annotation

GitHub Actions / GHC 9.4.7, Cabal 3.10, OS ubuntu-20.04

• The Monomorphism Restriction applies to the binding for ‘f'’

Check warning on line 44 in test/Test.hs

View workflow job for this annotation

GitHub Actions / GHC 9.2.8, Cabal 3.10, OS ubuntu-22.04

• The Monomorphism Restriction applies to the binding for ‘f'’

Check warning on line 44 in test/Test.hs

View workflow job for this annotation

GitHub Actions / GHC 8.10.7, Cabal 3.4, OS ubuntu-22.04

• The Monomorphism Restriction applies to the binding for ‘f'’

Check warning on line 44 in test/Test.hs

View workflow job for this annotation

GitHub Actions / GHC 9.4.7, Cabal 3.10, OS ubuntu-22.04

• The Monomorphism Restriction applies to the binding for ‘f'’

Check warning on line 44 in test/Test.hs

View workflow job for this annotation

GitHub Actions / GHC 8.10.7, Cabal 3.4, OS ubuntu-20.04

• The Monomorphism Restriction applies to the binding for ‘f'’

Check warning on line 44 in test/Test.hs

View workflow job for this annotation

GitHub Actions / GHC 9.2.8, Cabal 3.4, OS ubuntu-20.04

• The Monomorphism Restriction applies to the binding for ‘f'’

Check warning on line 44 in test/Test.hs

View workflow job for this annotation

GitHub Actions / GHC 8.8.4, Cabal 3.4, OS ubuntu-20.04

• The Monomorphism Restriction applies to the binding for ‘f'’

Check warning on line 44 in test/Test.hs

View workflow job for this annotation

GitHub Actions / GHC 8.8.4, Cabal 3.4, OS ubuntu-22.04

• The Monomorphism Restriction applies to the binding for ‘f'’

Check warning on line 44 in test/Test.hs

View workflow job for this annotation

GitHub Actions / GHC 9.6.3, Cabal 3.4, OS ubuntu-22.04

• The Monomorphism Restriction applies to the binding for ‘f'’

Check warning on line 44 in test/Test.hs

View workflow job for this annotation

GitHub Actions / GHC 9.6.3, Cabal 3.4, OS ubuntu-20.04

• The Monomorphism Restriction applies to the binding for ‘f'’

Check warning on line 44 in test/Test.hs

View workflow job for this annotation

GitHub Actions / GHC 9.4.7, Cabal 3.4, OS ubuntu-20.04

• The Monomorphism Restriction applies to the binding for ‘f'’

Check warning on line 44 in test/Test.hs

View workflow job for this annotation

GitHub Actions / GHC 8.10.7, Cabal 3.10, OS ubuntu-22.04

• The Monomorphism Restriction applies to the binding for ‘f'’

Check warning on line 44 in test/Test.hs

View workflow job for this annotation

GitHub Actions / GHC 8.10.7, Cabal 3.10, OS ubuntu-20.04

• The Monomorphism Restriction applies to the binding for ‘f'’

Check warning on line 44 in test/Test.hs

View workflow job for this annotation

GitHub Actions / GHC 9.2.8, Cabal 3.4, OS ubuntu-22.04

• The Monomorphism Restriction applies to the binding for ‘f'’

Check warning on line 44 in test/Test.hs

View workflow job for this annotation

GitHub Actions / GHC 9.4.7, Cabal 3.4, OS ubuntu-22.04

• The Monomorphism Restriction applies to the binding for ‘f'’

Check warning on line 44 in test/Test.hs

View workflow job for this annotation

GitHub Actions / GHC 9.2.8, Cabal 3.10, OS ubuntu-20.04

• The Monomorphism Restriction applies to the binding for ‘f'’

Check warning on line 44 in test/Test.hs

View workflow job for this annotation

GitHub Actions / GHC 9.4.7, Cabal 3.10, OS ubuntu-20.04

• The Monomorphism Restriction applies to the binding for ‘f'’

Check warning on line 44 in test/Test.hs

View workflow job for this annotation

GitHub Actions / GHC 9.2.8, Cabal 3.10, OS ubuntu-22.04

• The Monomorphism Restriction applies to the binding for ‘f'’

Check warning on line 44 in test/Test.hs

View workflow job for this annotation

GitHub Actions / GHC 9.6.3, Cabal 3.10, OS ubuntu-20.04

• The Monomorphism Restriction applies to the binding for ‘f'’

Check warning on line 44 in test/Test.hs

View workflow job for this annotation

GitHub Actions / GHC 8.8.4, Cabal 3.10, OS ubuntu-20.04

• The Monomorphism Restriction applies to the binding for ‘f'’

Check warning on line 44 in test/Test.hs

View workflow job for this annotation

GitHub Actions / GHC 9.4.7, Cabal 3.10, OS ubuntu-22.04

• The Monomorphism Restriction applies to the binding for ‘f'’

Check warning on line 44 in test/Test.hs

View workflow job for this annotation

GitHub Actions / GHC 9.6.3, Cabal 3.10, OS ubuntu-22.04

• The Monomorphism Restriction applies to the binding for ‘f'’

Check warning on line 44 in test/Test.hs

View workflow job for this annotation

GitHub Actions / GHC 8.8.4, Cabal 3.10, OS ubuntu-22.04

• The Monomorphism Restriction applies to the binding for ‘f'’

Check warning on line 44 in test/Test.hs

View workflow job for this annotation

GitHub Actions / GHC 8.10.7, Cabal 3.4, OS ubuntu-22.04

• The Monomorphism Restriction applies to the binding for ‘f'’

Check warning on line 44 in test/Test.hs

View workflow job for this annotation

GitHub Actions / GHC 8.10.7, Cabal 3.4, OS ubuntu-20.04

• The Monomorphism Restriction applies to the binding for ‘f'’

Check warning on line 44 in test/Test.hs

View workflow job for this annotation

GitHub Actions / GHC 9.2.8, Cabal 3.4, OS ubuntu-20.04

• The Monomorphism Restriction applies to the binding for ‘f'’

Check warning on line 44 in test/Test.hs

View workflow job for this annotation

GitHub Actions / GHC 8.8.4, Cabal 3.4, OS ubuntu-20.04

• The Monomorphism Restriction applies to the binding for ‘f'’

Check warning on line 44 in test/Test.hs

View workflow job for this annotation

GitHub Actions / GHC 8.8.4, Cabal 3.4, OS ubuntu-22.04

• The Monomorphism Restriction applies to the binding for ‘f'’

Check warning on line 44 in test/Test.hs

View workflow job for this annotation

GitHub Actions / GHC 9.4.7, Cabal 3.4, OS ubuntu-20.04

• The Monomorphism Restriction applies to the binding for ‘f'’

Check warning on line 44 in test/Test.hs

View workflow job for this annotation

GitHub Actions / GHC 9.6.3, Cabal 3.4, OS ubuntu-20.04

• The Monomorphism Restriction applies to the binding for ‘f'’

Check warning on line 44 in test/Test.hs

View workflow job for this annotation

GitHub Actions / GHC 9.2.8, Cabal 3.4, OS ubuntu-22.04

• The Monomorphism Restriction applies to the binding for ‘f'’

Check warning on line 44 in test/Test.hs

View workflow job for this annotation

GitHub Actions / GHC 9.6.3, Cabal 3.4, OS ubuntu-22.04

• The Monomorphism Restriction applies to the binding for ‘f'’

Check warning on line 44 in test/Test.hs

View workflow job for this annotation

GitHub Actions / GHC 9.4.7, Cabal 3.4, OS ubuntu-22.04

• The Monomorphism Restriction applies to the binding for ‘f'’
Expand All @@ -40,7 +49,7 @@ testCoercion (f, w) = do

-- | Called when a conversion fails.
{-# SPECIALIZE failTest :: String -> String -> String -> IO () #-}
failTest :: Monad m => String -> String -> String -> m ()
failTest :: MonadFail m => String -> String -> String -> m ()
failTest from wanted got = fail $ "Conversion from " ++ from ++ " to " ++ wanted ++ " failed. Got " ++ got

-- | Check if two floats are really equal: Not only equal as defined by the IEEE
Expand Down Expand Up @@ -113,7 +122,7 @@ go cpus cur = do
unless (maxBound - cur < cpus) $ go cpus (cur + cpus)

{-# SPECIALIZE doTest :: Word32 -> IO () #-}
doTest :: Monad m => Word32 -> m ()
doTest :: MonadFail m => Word32 -> m ()
doTest w = do
-- test coercions
let !refFloat = refWordToFloat w :: Float
Expand Down Expand Up @@ -153,7 +162,17 @@ doTest w = do

{-# SPECIALIZE INLINE testNextPrev :: (Float -> Float) -> (Float -> Float) -> Float -> IO () #-}
{-# SPECIALIZE INLINE testNextPrev :: (Double -> Double) -> (Double -> Double) -> Double -> IO () #-}
testNextPrev :: (Monad m, RealFloat f, FloatingBits f w, Show f, HasNaN f) => (f -> f) -> (f -> f) -> f -> m ()
testNextPrev
:: ( MonadFail m
, RealFloat f
, FloatingBits f w
, Show f
, ShowFloat f
)
=> (f -> f)
-> (f -> f)
-> f
-> m ()
testNextPrev refNextUp refNextDown testFloat = do
let !refNextFloat = refNextUp testFloat
!refPrevFloat = refNextDown testFloat
Expand Down Expand Up @@ -181,7 +200,7 @@ testNextPrev refNextUp refNextDown testFloat = do
{-# SPECIALIZE testAssert :: String -> Float -> Float -> (Float -> Float -> Bool) -> String -> String -> IO () #-}
{-# SPECIALIZE testAssert :: String -> Word64 -> Word64 -> (Word64 -> Word64 -> Bool) -> String -> String -> IO () #-}
{-# SPECIALIZE testAssert :: String -> Double -> Double -> (Double -> Double -> Bool) -> String -> String -> IO () #-}
testAssert :: (Monad m, Show a) => String -> a -> a -> (a -> a -> Bool) -> String -> String -> m ()
testAssert :: (MonadFail m, Show a) => String -> a -> a -> (a -> a -> Bool) -> String -> String -> m ()
testAssert ts a b f s s2 = unless (f a b) $
fail $ "Assert failed: " ++ show a ++ " " ++ s ++ " " ++ show b ++ ": " ++ s2 ++ " (" ++ ts ++ ")"

Expand Down

0 comments on commit 59cbeff

Please sign in to comment.