Skip to content

Commit

Permalink
Merge pull request #170 from haskell/lehins/improve-ci
Browse files Browse the repository at this point in the history
Improve CI
  • Loading branch information
lehins authored Dec 14, 2024
2 parents ff595fa + d5eba95 commit 6b30bd9
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 22 deletions.
34 changes: 19 additions & 15 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: random-CI

on:
push:
branches: [ '*' ]
branches: [ "master", "release/**" ]
pull_request:
branches: [ master ]
branches: [ "**" ]

defaults: { run: { shell: bash } }

Expand All @@ -22,8 +22,9 @@ jobs:
matrix:
include:
# Linux
- { os: ubuntu-latest, ghc: "8.0.2" }
- { os: ubuntu-latest, ghc: "8.2.2" }
# haskell-actions/setup is having trouble installing from hvr/ppa for ghc-8.0 and 8.2
# - { os: ubuntu-latest, ghc: "8.0.2" }
# - { os: ubuntu-latest, ghc: "8.2.2" }
- { os: ubuntu-latest, ghc: "8.4.4" }
- { os: ubuntu-latest, ghc: "8.6.5" }
- { os: ubuntu-latest, ghc: "8.8.4" }
Expand All @@ -35,8 +36,8 @@ jobs:
- { os: ubuntu-latest, ghc: "9.8.2" }
- { os: ubuntu-latest, ghc: "9.10.1" }
# MacOS
- { os: macOS-latest, ghc: "8.0.2" }
- { os: macOS-latest, ghc: "8.2.2" }
# - { os: macOS-latest, ghc: "8.0.2" }
# - { os: macOS-latest, ghc: "8.2.2" }
- { os: macOS-latest, ghc: "8.4.4" }
- { os: macOS-latest, ghc: "8.6.5" }
- { os: macOS-latest, ghc: "8.8.4" }
Expand All @@ -48,8 +49,8 @@ jobs:
- { os: macOS-latest, ghc: "9.8.2" }
- { os: macOS-latest, ghc: "9.10.1" }
# Windows
- { os: windows-latest, ghc: "8.0.2" }
- { os: windows-latest, ghc: "8.2.2" }
# - { os: windows-latest, ghc: "8.0.2" }
# - { os: windows-latest, ghc: "8.2.2" }
- { os: windows-latest, ghc: "8.4.4" }
- { os: windows-latest, ghc: "8.6.5" }
- { os: windows-latest, ghc: "8.8.4" }
Expand Down Expand Up @@ -101,11 +102,12 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
resolver: [nightly, lts-22, lts-21, lts-20, lts-19, lts-18, lts-16, lts-14, lts-12, lts-11]
resolver: [nightly, lts-22, lts-21, lts-20, lts-19, lts-18, lts-16, lts-14, lts-12, lts-11, lts-9]
include:
- resolver: lts-9
stack-yaml: stack-custom.yaml
- resolver: lts-11
ghc: '8.2.2'
stack-yaml: stack-old.yaml
stack-yaml: stack-custom.yaml
- resolver: lts-12
ghc: '8.4.4'
stack-yaml: stack-old.yaml
Expand Down Expand Up @@ -164,7 +166,7 @@ jobs:
stack-yaml: stack.yaml
env:
STACK_YAML: '${{ matrix.stack-yaml }}'
STACK_ARGS: '--resolver ${{ matrix.resolver }} --system-ghc'
STACK_ARGS: '--resolver ${{ matrix.resolver }}'
cache-version: v5 # bump up this version to invalidate currently stored cache
steps:
- uses: actions/checkout@v4
Expand All @@ -175,7 +177,7 @@ jobs:
with:
ghc-version: ${{ matrix.ghc }}
enable-stack: true
stack-version: ${{ matrix.resolver == 'lts-11' && '2.15.5' || 'latest' }}
stack-version: ${{ (matrix.resolver == 'lts-9' || matrix.resolver == 'lts-11') && '2.15.5' || 'latest' }}

- name: Cache
id: cache
Expand Down Expand Up @@ -239,8 +241,10 @@ jobs:
- name: Install
run: |
apt-get update -y
apt-get install -y autoconf build-essential zlib1g-dev libgmp-dev curl libncurses5 libtinfo5 libncurses5-dev libtinfo-dev
curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | BOOTSTRAP_HASKELL_NONINTERACTIVE=1 BOOTSTRAP_HASKELL_INSTALL_NO_STACK=1 sh
apt-get install -y autoconf build-essential zlib1g-dev libgmp-dev curl libncurses5 libtinfo5 libncurses5-dev libtinfo-dev wget
wget https://get-ghcup.haskell.org -O ghcup.sh -t 10 --retry-connrefused
chmod a+x ghcup.sh
BOOTSTRAP_HASKELL_NONINTERACTIVE=1 BOOTSTRAP_HASKELL_INSTALL_NO_STACK=1 ./ghcup.sh
- uses: actions/checkout@v1
- name: Test
run: |
Expand Down
16 changes: 12 additions & 4 deletions bench/Main.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE CPP #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE ScopedTypeVariables #-}
module Main (main) where
Expand All @@ -13,9 +14,11 @@ import Foreign.C.Types
import Numeric.Natural (Natural)
import System.Random.SplitMix as SM
import Test.Tasty.Bench
#if MIN_VERSION_primitive(0,7,1)
import Control.Monad.Primitive
import Data.Primitive.PrimArray
import Data.Primitive.Types
import Data.Primitive.PrimArray
#endif

import System.Random.Stateful

Expand Down Expand Up @@ -200,7 +203,9 @@ main = do
in pureUniformRBench (Proxy :: Proxy Natural) range sz
]
, bgroup "floating"
[ bgroup "IO"
[
#if MIN_VERSION_primitive(0,7,1)
bgroup "IO"
[ env ((,) <$> getStdGen <*> newAlignedPinnedPrimArray sz) $ \ ~(gen, ma) ->
bench "uniformFloat01M" $
nfIO (runStateGenT gen (fillMutablePrimArrayM uniformFloat01M ma))
Expand All @@ -214,7 +219,9 @@ main = do
bench "uniformDoublePositive01M" $
nfIO (runStateGenT gen (fillMutablePrimArrayM uniformDoublePositive01M ma))
]
, bgroup "State"
,
#endif
bgroup "State"
[ env getStdGen $
bench "uniformFloat01M" . nf (`runStateGen` (replicateM_ sz . uniformFloat01M))
, env getStdGen $
Expand Down Expand Up @@ -329,7 +336,7 @@ genMany f g0 n = go 0 $ f g0
| i < n = go (i + 1) $ f g
| otherwise = y


#if MIN_VERSION_primitive(0,7,1)
fillMutablePrimArrayM ::
(Prim a, PrimMonad m)
=> (gen -> m a)
Expand All @@ -343,3 +350,4 @@ fillMutablePrimArrayM f ma g = do
| otherwise = pure ()
go 0
unsafeFreezePrimArray ma
#endif
5 changes: 3 additions & 2 deletions random.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ library
bytestring >=0.10.4 && <0.13,
deepseq >=1.1 && <2,
mtl >=2.2 && <2.4,
transformers >=0.4 && <0.7,
splitmix >=0.1 && <0.2
if impl(ghc < 9.4)
build-depends: data-array-byte
Expand All @@ -123,7 +124,7 @@ test-suite legacy-test
-Wno-deprecations
build-depends:
base,
containers >=0.5 && <0.7,
containers >=0.5 && <0.8,
random

test-suite spec
Expand Down Expand Up @@ -192,7 +193,7 @@ benchmark bench
build-depends:
base,
mtl,
primitive >= 0.7.1,
primitive,
random,
splitmix >=0.1 && <0.2,
tasty-bench
2 changes: 1 addition & 1 deletion src/System/Random/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,10 @@ import Control.Arrow
import Control.DeepSeq (NFData)
import Control.Monad (replicateM, when, (>=>))
import Control.Monad.Cont (ContT, runContT)
import Control.Monad.Identity (IdentityT (runIdentityT))
import Control.Monad.ST
import Control.Monad.State.Strict (MonadState(..), State, StateT(..), execStateT, runState)
import Control.Monad.Trans (lift, MonadTrans)
import Control.Monad.Trans.Identity (IdentityT (runIdentityT))
import Data.Array.Byte (ByteArray(..), MutableByteArray(..))
import Data.Bits
import Data.ByteString (ByteString)
Expand Down
18 changes: 18 additions & 0 deletions stack-custom.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
resolver: lts-11.22
packages:
- .
extra-deps:
- splitmix-0.1@sha256:d50c4d0801a35be7875a040470c09863342514930c82a7d25780a6c2efc4fda9,5249
- rdtsc-1.3.0.1@sha256:0a6e8dc715ba82ad72c7e2b1c2f468999559bec059d50540719a80b00dcc4e66,1557
- smallcheck-1.2.0@sha256:8b431572e6a0503223e0e52014d41084c1b01f2aeea3bd499f6f529b3f6dfa89,1482
- tasty-1.3.1@sha256:01e35c97f7ee5ccbc28f21debea02a38cd010d53b4c3087f5677c5d06617a507,2520
- tasty-hunit-0.10.2@sha256:22bc1122e8256664d7cb1e44c6bcace95676c523179947bf2403db71af43dc6d,1473
- ansi-wl-pprint-0.6.8.2@sha256:a890b713942c1aa0109fb632e9fee581ceb5b0763fd936ae8cae22e5f91a0877,2178
- ansi-terminal-0.9.1@sha256:48f53532d0f365ffa568c8cf0adc84c66f800a7d80d3329e4f04fa75392f4af1,3225
- wcwidth-0.0.2@sha256:77531eb6683c505c22ab3fa11bbc43d3ce1e7dac21401d4d5a19677d348bb5f3,1998
- tasty-bench-0.2.3@sha256:daa2221a1b1c65990633a51236f1cb4a52cba8ef0f0731f653e712a8bab07616,1319
- inspection-testing-0.4.5.0@sha256:938e7ce2ef42033071a5e60198c6e19ab61c411f5879b85821247a504f131768,8058
- tasty-inspection-testing-0.1@sha256:9c5e76345168fd3a59b43d305eebf8df3c792ce324c66bbdee45b54aa7d2c0ad,1214
- vector-0.12.3.1@sha256:fffbd00912d69ed7be9bc7eeb09f4f475e0d243ec43f916a9fd5bbd219ce7f3e,8238
- data-array-byte-0.1.0.1@sha256:ad89e28b2b046175698fbf542af2ce43e5d2af50aae9f48d12566b1bb3de1d3c,1989
- optparse-applicative-0.14.2.0@sha256:cfbc2df0d9e144d343ccea6d25ab27543c15ea17d2abcbabcdf76030a2236383,4359
1 change: 1 addition & 0 deletions stack-old.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
resolver: lts-12.26
system-ghc: true
packages:
- .
extra-deps:
Expand Down
1 change: 1 addition & 0 deletions stack.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
resolver: lts-21.25
system-ghc: true
packages:
- .
extra-deps: []

0 comments on commit 6b30bd9

Please sign in to comment.