diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 00000000..342b2016 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,65 @@ +name: Continuous Integration + +on: + push: + +jobs: + continuous-integration: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + ghc-version: + - "8.10.7" + - "9.0.2" + - "9.2.8" + - "9.4.8" + - "9.6.6" + - "9.8.2" + - "9.10.1" + flags: + - "" # base case + - "+binary" + + steps: + - uses: actions/checkout@v4 + + - name: Install cabal/ghc + uses: haskell-actions/setup@v2 + id: setup-haskell + with: + ghc-version: ${{ matrix.ghc-version }} + cabal-version: '3.10.3.0' + + - name: Generate freeze file + run: | + cabal update + cabal configure --disable-optimization --flags="${{ matrix.flags }}" --enable-tests + cabal freeze + + - name: Cache cabal work + uses: actions/cache@v4 + with: + path: | + dist-newstyle + ${{ steps.setup-haskell.outputs.cabal-store }} + key: ${{ runner.os }}-${{ hashFiles('cabal.project.freeze', 'cabal.project.local') }}-cabal-install + + - name: Build dependencies + run: | + cabal build --only-dependencies + + - name: Build dimensional + run: | + cabal build + + - name: Run tests + run: | + cabal test + + # Note that we ignore the cabal freeze file (--ignore-project) because + # the `doctest` dependencies may clash with `dimensional` dependencies. + - name: Run doctests + run: | + cabal install doctest --ignore-project --disable-optimization + cabal repl dimensional --build-depends=QuickCheck --with-ghc=doctest \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 0324fa53..00000000 --- a/.travis.yml +++ /dev/null @@ -1,45 +0,0 @@ -# Based on a template from http://docs.haskellstack.org/en/stable/GUIDE.html#travis-with-caching -# Use new container infrastructure to enable caching -sudo: true - -# Choose a lightweight base image; we provide our own build tools. -language: c - -# GHC depends on GMP. You can add other dependencies here as well. -addons: - apt: - packages: - - libgmp-dev - -# The different configurations we want to test. You could also do things like -# change flags or use --stack-yaml to point to a different file. -env: -- ARGS="--resolver lts-7" -- ARGS="--resolver lts-11" -- ARGS="--resolver lts-12" -- ARGS="--resolver lts-13" -- ARGS="--resolver lts-15" -- ARGS="--resolver lts-17" -- ARGS="--resolver lts-17" FLAGS="--flag dimensional:binary" - -before_install: -# Download and unpack the stack executable -- sudo ln -s /lib/libncurses.so.6 /usr/lib/libtinfo.so.6 -- sudo ln -s /usr/lib/libtinfo.so.6 /usr/lib/libtinfo.so -- mkdir -p ~/.local/bin -- export PATH=$HOME/.local/bin:$PATH -- travis_retry curl -L https://www.stackage.org/stack/linux-x86_64 | tar xz --wildcards --strip-components=1 -C ~/.local/bin '*/stack' -# Ask stack to install GHC -- stack $ARGS setup -# Ask stack to install hscolour for haddock source colorization. -- stack $ARGS install hscolour - -# This line does all of the work: build the library, -# executables, and test suites, and runs the test suites. --no-terminal works -# around some quirks in Travis's terminal implementation. -script: stack $ARGS --no-terminal test $FLAGS --haddock --no-haddock-deps --bench - -# Caching so the next build will be fast too. -cache: - directories: - - $HOME/.stack diff --git a/README.md b/README.md index eb293abf..52254d74 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,6 @@ This library provides statically-checked dimensional arithmetic for physical qua Data kinds and closed type families provide a flexible, safe, and discoverable implementation that leads to largely self-documenting client code. -[![Build Status](https://api.travis-ci.com/bjornbm/dimensional.svg?branch=master)](https://app.travis-ci.com/github/bjornbm/dimensional) [![Hackage Version](https://img.shields.io/hackage/v/dimensional.svg)](https://hackage.haskell.org/package/dimensional) [![Stackage version](https://www.stackage.org/package/dimensional/badge/lts?label=Stackage)](https://www.stackage.org/package/dimensional) diff --git a/dimensional.cabal b/dimensional.cabal index 9adb0598..6e6d0ad4 100644 --- a/dimensional.cabal +++ b/dimensional.cabal @@ -11,7 +11,13 @@ bug-reports: https://github.com/bjornbm/dimensional/issues/ category: Math, Physics synopsis: Statically checked physical dimensions cabal-version: >= 1.10 -tested-with: GHC == 8.0.1, GHC == 8.0.2, GHC == 8.2.2, GHC == 8.4.4, GHC == 8.6.1, GHC == 8.8.3, GHC == 8.10.4 +tested-with: GHC == 8.10.7, + GHC == 9.0.2, + GHC == 9.2.8, + GHC == 9.4.8, + GHC == 9.6.6, + GHC == 9.8.2, + GHC == 9.10.1 build-type: Simple description: @@ -99,19 +105,6 @@ test-suite tests base build-tool-depends: hspec-discover:hspec-discover == 2.* -test-suite doctests - type: exitcode-stdio-1.0 - ghc-options: -threaded - main-is: DocTests.hs - hs-source-dirs: tests - default-language: Haskell2010 - build-depends: dimensional, - doctest, - Glob, - QuickCheck, - template-haskell, - base - benchmark simple type: exitcode-stdio-1.0 hs-source-dirs: benchmarks diff --git a/src/Numeric/Units/Dimensional.hs b/src/Numeric/Units/Dimensional.hs index e16f3730..4fac56a8 100644 --- a/src/Numeric/Units/Dimensional.hs +++ b/src/Numeric/Units/Dimensional.hs @@ -240,6 +240,8 @@ import qualified Numeric.Units.Dimensional.Variants as V -- $setup -- >>> :set -XFlexibleInstances -- >>> :set -XNoImplicitPrelude +-- >>> :set -fno-warn-orphans +-- >>> :set -fno-warn-type-defaults -- >>> import Test.QuickCheck.Arbitrary -- >>> import Numeric.Units.Dimensional.Prelude -- >>> import Numeric.Units.Dimensional.Float diff --git a/src/Numeric/Units/Dimensional/Dimensions/TermLevel.hs b/src/Numeric/Units/Dimensional/Dimensions/TermLevel.hs index 38b0bb58..a9e5627d 100644 --- a/src/Numeric/Units/Dimensional/Dimensions/TermLevel.hs +++ b/src/Numeric/Units/Dimensional/Dimensions/TermLevel.hs @@ -48,6 +48,7 @@ import Prelude (id, all, fst, snd, fmap, otherwise, divMod, ($), (+), (-), (.), import qualified Prelude as P -- $setup +-- >>> :set -fno-warn-orphans -- >>> import Prelude (negate) -- >>> import Control.Applicative -- >>> import Test.QuickCheck.Arbitrary diff --git a/src/Numeric/Units/Dimensional/Float.hs b/src/Numeric/Units/Dimensional/Float.hs index 0c334817..488eef8d 100644 --- a/src/Numeric/Units/Dimensional/Float.hs +++ b/src/Numeric/Units/Dimensional/Float.hs @@ -45,6 +45,7 @@ import Numeric.Units.Dimensional.Prelude hiding (RealFloat(..)) import Numeric.Units.Dimensional.Coercion -- $setup +-- >>> :set -fno-warn-type-defaults -- >>> :set -XExtendedDefaultRules -- >>> :set -XNegativeLiterals diff --git a/src/Numeric/Units/Dimensional/Internal.hs b/src/Numeric/Units/Dimensional/Internal.hs index a14a7d11..e6e3a93e 100644 --- a/src/Numeric/Units/Dimensional/Internal.hs +++ b/src/Numeric/Units/Dimensional/Internal.hs @@ -60,6 +60,7 @@ import qualified Prelude as P -- $setup -- >>> :set -XNoImplicitPrelude +-- >>> :set -fno-warn-type-defaults -- >>> import Numeric.Units.Dimensional.Prelude -- | A unit of measurement. diff --git a/src/Numeric/Units/Dimensional/NonSI.hs b/src/Numeric/Units/Dimensional/NonSI.hs index fcef791f..fb3b15a4 100644 --- a/src/Numeric/Units/Dimensional/NonSI.hs +++ b/src/Numeric/Units/Dimensional/NonSI.hs @@ -85,6 +85,7 @@ import Numeric.Units.Dimensional.UnitNames.Internal (ucumMetric, ucum, dimension import qualified Prelude -- $setup +-- >>> :set -fno-warn-type-defaults -- >>> import Data.ExactPi -- >>> import Data.Function (on) -- >>> import Numeric.Units.Dimensional.Coercion diff --git a/src/Numeric/Units/Dimensional/Quantities.hs b/src/Numeric/Units/Dimensional/Quantities.hs index ffd1c23b..9237ccc2 100644 --- a/src/Numeric/Units/Dimensional/Quantities.hs +++ b/src/Numeric/Units/Dimensional/Quantities.hs @@ -418,6 +418,7 @@ to the definitions of 'DArea' and 'DVolume'. -} -- $setup +-- >>> :set -fno-warn-type-defaults -- >>> import Numeric.Units.Dimensional.Prelude -- | Constructs a unit of area from a unit of length, taking the area of a square whose sides are that length. diff --git a/tests/DocTests.hs b/tests/DocTests.hs deleted file mode 100644 index a73fd1e6..00000000 --- a/tests/DocTests.hs +++ /dev/null @@ -1,17 +0,0 @@ -{-# LANGUAGE CPP #-} -{-# LANGUAGE FlexibleInstances #-} -{-# LANGUAGE TypeSynonymInstances #-} - -module Main (main) where - -import System.FilePath.Glob (glob) -import Test.DocTest (doctest) - -#if MIN_VERSION_base(4,12,0) -doctestFlags = ["-XNoStarIsType"] -#else -doctestFlags = [] -#endif - -main :: IO () -main = glob "src/**/*.hs" >>= (doctest . (doctestFlags++))