diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 0bf8ff40..ea5447f6 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -2,9 +2,9 @@ name: random-CI on: push: - branches: [ "**" ] + branches: [ "master", "release/**" ] pull_request: - branches: [ master ] + branches: [ "**" ] defaults: { run: { shell: bash } } @@ -22,42 +22,57 @@ jobs: matrix: include: # Linux - - { cabal: "3.6", os: ubuntu-latest, ghc: "8.0.2" } - - { cabal: "3.6", os: ubuntu-latest, ghc: "8.2.2" } - - { cabal: "3.6", os: ubuntu-latest, ghc: "8.4.4" } - - { cabal: "3.6", os: ubuntu-latest, ghc: "8.6.5" } - - { cabal: "3.6", os: ubuntu-latest, ghc: "8.8.4" } - # - { cabal: "3.6", os: ubuntu-latest, ghc: "8.10.7" } - - { cabal: "3.6", os: ubuntu-latest, ghc: "9.0.2" } - - { cabal: "3.6", os: ubuntu-latest, ghc: "9.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" } + - { os: ubuntu-latest, ghc: "8.10.7" } + - { os: ubuntu-latest, ghc: "9.0.2" } + - { os: ubuntu-latest, ghc: "9.2.8" } + - { os: ubuntu-latest, ghc: "9.4.8" } + - { os: ubuntu-latest, ghc: "9.6.6" } + - { os: ubuntu-latest, ghc: "9.8.2" } + - { os: ubuntu-latest, ghc: "9.10.1" } # MacOS - - { cabal: "3.6", os: macOS-latest, ghc: "8.0.2" } - - { cabal: "3.6", os: macOS-latest, ghc: "8.2.2" } - - { cabal: "3.6", os: macOS-latest, ghc: "8.4.4" } - - { cabal: "3.6", os: macOS-latest, ghc: "8.6.5" } - - { cabal: "3.6", os: macOS-latest, ghc: "8.8.4" } - # - { cabal: "3.6", os: macOS-latest, ghc: "8.10.7" } - - { cabal: "3.6", os: macOS-latest, ghc: "9.0.2" } - - { cabal: "3.6", os: macOS-latest, ghc: "9.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" } + - { os: macOS-latest, ghc: "8.10.7" } + - { os: macOS-latest, ghc: "9.0.2" } + - { os: macOS-latest, ghc: "9.2.8" } + - { os: macOS-latest, ghc: "9.4.8" } + - { os: macOS-latest, ghc: "9.6.6" } + - { os: macOS-latest, ghc: "9.8.2" } + - { os: macOS-latest, ghc: "9.10.1" } # Windows - - { cabal: "3.6", os: windows-latest, ghc: "8.0.2" } - - { cabal: "3.6", os: windows-latest, ghc: "8.2.2" } - - { cabal: "3.6", os: windows-latest, ghc: "8.4.4" } - - { cabal: "3.6", os: windows-latest, ghc: "8.6.5" } - - { cabal: "3.6", os: windows-latest, ghc: "8.8.4" } - # - { cabal: "3.6", os: windows-latest, ghc: "8.10.7" } - - { cabal: "3.6", os: windows-latest, ghc: "9.0.2" } - - { cabal: "3.6", os: windows-latest, ghc: "9.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" } + - { os: windows-latest, ghc: "8.10.7" } + - { os: windows-latest, ghc: "9.0.2" } + - { os: windows-latest, ghc: "9.2.8" } + - { os: windows-latest, ghc: "9.4.8" } + - { os: windows-latest, ghc: "9.6.6" } + - { os: windows-latest, ghc: "9.8.2" } + - { os: windows-latest, ghc: "9.10.1" } steps: - uses: actions/checkout@v4 - uses: haskell-actions/setup@v2 id: setup-haskell-cabal + name: Setup Haskell with: ghc-version: ${{ matrix.ghc }} - cabal-version: ${{ matrix.cabal }} + - name: Update cabal package database run: cabal update + - uses: actions/cache@v4 name: Cache cabal stuff with: @@ -65,6 +80,7 @@ jobs: ${{ steps.setup-haskell-cabal.outputs.cabal-store }} dist-newstyle key: ${{ runner.os }}-${{ matrix.ghc }} + - name: Build and test run: | cabal sdist -z -o . @@ -73,6 +89,13 @@ jobs: echo $EXTRA_FLAGS cabal $EXTRA_FLAGS configure --haddock-all --enable-tests --enable-benchmarks --benchmark-option=-l cabal $EXTRA_FLAGS build all --write-ghc-environment-files=always + + # Disable doctests, since examples in documentation would need to be fixed in order to pass the new doctest setup + # - name: Doctest + # run: | + # cabal install doctest --ignore-project --overwrite-policy=always + # cabal repl --build-depends=unliftio --with-compiler=doctest --repl-options='-w -Wdefault' + build-stack: name: CI-stack runs-on: ${{ matrix.os }} @@ -80,11 +103,12 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest] - resolver: [nightly, 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 @@ -96,7 +120,7 @@ jobs: stack-yaml: stack-old.yaml - resolver: lts-18 ghc: '8.10.7' - stack-yaml: stack.yaml + stack-yaml: stack.lts-18.yaml - resolver: lts-19 ghc: '9.0.2' stack-yaml: stack-coveralls.yaml @@ -104,24 +128,47 @@ jobs: ghc: '9.2.8' stack-yaml: stack.yaml - resolver: lts-21 - ghc: '9.4.7' + ghc: '9.4.8' + stack-yaml: stack.yaml + - resolver: lts-22 + ghc: '9.6.6' stack-yaml: stack.yaml - resolver: nightly stack-yaml: stack.yaml - # Latest stable for MacOS: ghc-8.8.4 - - resolver: lts-16 - os: macos-latest - ghc: '8.8.4' - stack-yaml: stack-old.yaml - # Latest stable for Windows: ghc-8.6.4 + # MacOS-latest + - resolver: lts-20 + os: macos-13 + ghc: '9.2.8' + stack-yaml: stack.yaml + - resolver: lts-21 + os: macos-13 + ghc: '9.4.8' + stack-yaml: stack.yaml + - resolver: lts-22 + os: macos-13 + ghc: '9.6.6' + stack-yaml: stack.yaml + # Windows-latest - resolver: lts-14 os: windows-latest ghc: '8.6.5' stack-yaml: stack-old.yaml + - resolver: lts-20 + os: windows-latest + ghc: '9.2.8' + stack-yaml: stack.yaml + - resolver: lts-21 + os: windows-latest + ghc: '9.4.8' + stack-yaml: stack.yaml + - resolver: lts-22 + os: windows-latest + ghc: '9.6.6' + stack-yaml: stack.yaml env: STACK_YAML: '${{ matrix.stack-yaml }}' - STACK_ARGS: '--resolver ${{ matrix.resolver }} --system-ghc' - cache-version: v4 # bump up this version to invalidate currently stored cache + STACK_ARGS: '--resolver ${{ matrix.resolver }}' + cache-version: v5 # bump up this version to invalidate currently stored cache steps: - uses: actions/checkout@v4 @@ -131,8 +178,7 @@ jobs: with: ghc-version: ${{ matrix.ghc }} enable-stack: true - stack-version: 'latest' - cabal-version: '3.10' + stack-version: ${{ (matrix.resolver == 'lts-9' || matrix.resolver == 'lts-11') && '2.15.5' || 'latest' }} - name: Cache id: cache @@ -144,14 +190,7 @@ jobs: key: ${{ runner.os }}-${{ matrix.resolver }}-${{ env.cache-version }} restore-keys: | ${{ runner.os }}-${{ matrix.resolver }}-${{ env.cache-version }} - # Executable files somehow become incompatible after restoring on MacOS from a - # previous build, so it needs to be cleaned up. This is very inconvenient and will - # need to be fixed. - - name: MacOS workaround for failure due to setup-exe-cache - if: steps.cache.outputs.cache-hit == 'true' && matrix.os == 'macos-latest' - run: | - rm -r ~/.stack/setup-exe-cache - rm -r .stack-work + - name: Windows Cache id: cache-windows uses: actions/cache@v4 @@ -194,3 +233,77 @@ jobs: else stack $STACK_ARGS test --bench --no-run-benchmarks --haddock --no-haddock-deps fi + + i386: + runs-on: ubuntu-latest + container: + image: i386/ubuntu:bionic + steps: + - 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 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: | + source ~/.ghcup/env + cabal update + cabal test + + # We use github.com/haskell self-hosted runners for ARM testing. + arm: + runs-on: [self-hosted, Linux, ARM64] + strategy: + fail-fast: true + matrix: + arch: [arm32v7, arm64v8] + steps: + - uses: docker://hasufell/arm64v8-ubuntu-haskell:focal + name: Cleanup + with: + args: "find . -mindepth 1 -maxdepth 1 -exec rm -rf -- {} +" + + - name: Checkout code + uses: actions/checkout@v4 + + - if: matrix.arch == 'arm32v7' + uses: docker://hasufell/arm32v7-ubuntu-haskell:focal + name: Run build (arm32v7 linux) + with: + args: sh -c "cabal update && cabal test" + + - if: matrix.arch == 'arm64v8' + uses: docker://hasufell/arm64v8-ubuntu-haskell:focal + name: Run build (arm64v8 linux) + with: + args: sh -c "cabal update && cabal test" + + # Emulation on s390x platform is incredibly slow and memory demanding. + # It seems that any executable with GHC RTS takes at least 7-8 Gb of RAM, so we can + # run `cabal` or `ghc` on their own, but cannot run them both at the same time, striking + # out `cabal test`. Instead we rely on system packages and invoke `ghc --make` manually, + # and even so `ghc -O` is prohibitively expensive. + s390x: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: uraimo/run-on-arch-action@v2.8.1 + timeout-minutes: 60 + with: + arch: s390x + distro: ubuntu_rolling + githubToken: ${{ github.token }} + install: | + apt-get update -y + apt-get install -y git ghc libghc-tasty-smallcheck-dev libghc-tasty-hunit-dev libghc-splitmix-dev curl + run: | + git clone https://github.com/Bodigrim/data-array-byte + cp -r data-array-byte/Data . + ghc --version + ghc --make -isrc:test-legacy -o legacy test-legacy/Legacy.hs + ./legacy + ghc --make -isrc:test -o spec test/Spec.hs + ./spec diff --git a/bench/Main.hs b/bench/Main.hs index 4add6646..4020023e 100644 --- a/bench/Main.hs +++ b/bench/Main.hs @@ -1,4 +1,5 @@ {-# LANGUAGE BangPatterns #-} +{-# LANGUAGE CPP #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE ScopedTypeVariables #-} module Main (main) where @@ -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 @@ -198,7 +201,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)) @@ -212,7 +217,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 $ @@ -320,7 +327,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) @@ -334,3 +341,4 @@ fillMutablePrimArrayM f ma g = do | otherwise = pure () go 0 unsafeFreezePrimArray ma +#endif diff --git a/random.cabal b/random.cabal index 0e034d06..3f192d0d 100644 --- a/random.cabal +++ b/random.cabal @@ -1,6 +1,6 @@ cabal-version: >=1.10 name: random -version: 1.2.1.2 +version: 1.2.1.3 license: BSD3 license-file: LICENSE maintainer: core-libraries-committee@haskell.org @@ -122,8 +122,8 @@ test-suite legacy-test ghc-options: -Wno-deprecations build-depends: - base, - containers >=0.5 && <0.7, + base >=4.8 && <5, + containers >=0.5 && <0.8, random test-suite doctests @@ -132,16 +132,7 @@ test-suite doctests hs-source-dirs: test default-language: Haskell2010 build-depends: - base, - doctest >=0.15 && <0.23 - if impl(ghc >= 8.2) && impl(ghc < 8.10) - build-depends: - mwc-random >=0.13 && <0.16, - primitive >=0.6 && <0.8, - random, - stm, - unliftio >=0.2 && <0.3, - vector >= 0.10 && <0.14 + base >=4.8 && <5 test-suite spec type: exitcode-stdio-1.0 @@ -155,7 +146,7 @@ test-suite spec default-language: Haskell2010 ghc-options: -Wall build-depends: - base, + base >=4.8 && <5, bytestring, random, smallcheck >=1.2 && <1.3, @@ -174,7 +165,7 @@ test-suite spec-inspection default-language: Haskell2010 ghc-options: -Wall build-depends: - base, + base >=4.8 && <5, random, tasty >=1.0 && <1.6 if impl(ghc >= 8.0) @@ -196,7 +187,7 @@ benchmark legacy-bench -Wno-deprecations build-depends: - base, + base >=4.8 && <5, random, rdtsc, split >=0.2 && <0.3, @@ -209,9 +200,9 @@ benchmark bench default-language: Haskell2010 ghc-options: -Wall -O2 build-depends: - base, + base >=4.8 && <5, mtl, - primitive >= 0.7.1, + primitive, random, splitmix >=0.1 && <0.2, tasty-bench diff --git a/stack-coveralls.yaml b/stack-coveralls.yaml index 6a2143bc..30d15974 100644 --- a/stack-coveralls.yaml +++ b/stack-coveralls.yaml @@ -2,4 +2,5 @@ resolver: lts-19.33 system-ghc: true packages: - . -extra-deps: [] +extra-deps: +- data-array-byte-0.1.0.1@sha256:ad89e28b2b046175698fbf542af2ce43e5d2af50aae9f48d12566b1bb3de1d3c,1989 diff --git a/stack-custom.yaml b/stack-custom.yaml new file mode 100644 index 00000000..e7f745cb --- /dev/null +++ b/stack-custom.yaml @@ -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 diff --git a/stack-old.yaml b/stack-old.yaml index 025127c5..f8c19b1c 100644 --- a/stack-old.yaml +++ b/stack-old.yaml @@ -1,10 +1,9 @@ resolver: lts-12.26 +system-ghc: true packages: - . extra-deps: - splitmix-0.1@sha256:d50c4d0801a35be7875a040470c09863342514930c82a7d25780a6c2efc4fda9,5249 -- doctest-0.16.2@sha256:2f96e9bbe9aee11b47453c82c24b3dc76cdbb8a2a7c984dfd60b4906d08adf68,6942 -- cabal-doctest-1.0.8@sha256:34dff6369d417df2699af4e15f06bc181d495eca9c51efde173deae2053c197c,1491 - rdtsc-1.3.0.1@sha256:0a6e8dc715ba82ad72c7e2b1c2f468999559bec059d50540719a80b00dcc4e66,1557 - smallcheck-1.2.0@sha256:8b431572e6a0503223e0e52014d41084c1b01f2aeea3bd499f6f529b3f6dfa89,1482 - tasty-1.3.1@sha256:01e35c97f7ee5ccbc28f21debea02a38cd010d53b4c3087f5677c5d06617a507,2520 @@ -15,4 +14,4 @@ extra-deps: - inspection-testing-0.4.5.0@sha256:938e7ce2ef42033071a5e60198c6e19ab61c411f5879b85821247a504f131768,8058 - tasty-inspection-testing-0.1@sha256:9c5e76345168fd3a59b43d305eebf8df3c792ce324c66bbdee45b54aa7d2c0ad,1214 - primitive-0.7.4.0@sha256:89b88a3e08493b7727fa4089b0692bfbdf7e1e666ef54635f458644eb8358764,2857 -- vector-0.12.3.1@sha256:fffbd00912d69ed7be9bc7eeb09f4f475e0d243ec43f916a9fd5bbd219ce7f3e,8238 +- data-array-byte-0.1.0.1@sha256:ad89e28b2b046175698fbf542af2ce43e5d2af50aae9f48d12566b1bb3de1d3c,1989 diff --git a/stack.lts-18.yaml b/stack.lts-18.yaml new file mode 100644 index 00000000..320440f4 --- /dev/null +++ b/stack.lts-18.yaml @@ -0,0 +1,5 @@ +resolver: lts-18.28 +packages: +- . +extra-deps: +- data-array-byte-0.1.0.1@sha256:ad89e28b2b046175698fbf542af2ce43e5d2af50aae9f48d12566b1bb3de1d3c,1989 diff --git a/stack.yaml b/stack.yaml index d15416fa..6036e063 100644 --- a/stack.yaml +++ b/stack.yaml @@ -1,4 +1,5 @@ -resolver: lts-18.28 +resolver: lts-21.25 +system-ghc: true packages: - . extra-deps: [] diff --git a/test/doctests.hs b/test/doctests.hs index 001b3376..67388462 100644 --- a/test/doctests.hs +++ b/test/doctests.hs @@ -1,18 +1,4 @@ -{-# LANGUAGE CPP #-} module Main where -#if __GLASGOW_HASKELL__ >= 802 && __GLASGOW_HASKELL__ < 810 - -import Test.DocTest (doctest) - -main :: IO () -main = doctest ["src"] - -#else - --- Also disabled in cabal file. --- TODO: fix doctest support main :: IO () -main = putStrLn "\nDoctests are not supported for older ghc version\n" - -#endif +main = putStrLn "Doctest have been removed from the cabal into a standalone CI step in random-1.3"