From 9532d62a28de95c1dd313501edb87fb2199b5508 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laurent=20P=2E=20Ren=C3=A9=20de=20Cotret?= Date: Tue, 20 Aug 2024 14:51:19 -0400 Subject: [PATCH 1/8] Basic Github Actions workflow --- .github/workflows/ci.yaml | 59 +++++++++++++++++++++++++++++++++++++++ dimensional.cabal | 24 ++++++++-------- 2 files changed, 71 insertions(+), 12 deletions(-) create mode 100644 .github/workflows/ci.yaml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..33aca3e --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,59 @@ +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 + # Only activate after #224 has landed + # - "+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 \ No newline at end of file diff --git a/dimensional.cabal b/dimensional.cabal index 949aa47..bd6cc74 100644 --- a/dimensional.cabal +++ b/dimensional.cabal @@ -91,18 +91,18 @@ 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 +-- 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 From 6607c56056d393e690ee1e08613186eaab7c2eaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laurent=20P=2E=20Ren=C3=A9=20de=20Cotret?= Date: Tue, 20 Aug 2024 15:49:05 -0400 Subject: [PATCH 2/8] Remove travis configuration --- .travis.yml | 44 -------------------------------------------- 1 file changed, 44 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index ec62ebd..0000000 --- a/.travis.yml +++ /dev/null @@ -1,44 +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" - -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 --haddock --no-haddock-deps --bench - -# Caching so the next build will be fast too. -cache: - directories: - - $HOME/.stack From 2f9d408da98e56e2799fe53ca974d403ea8a6cbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laurent=20P=2E=20Ren=C3=A9=20de=20Cotret?= Date: Tue, 20 Aug 2024 15:51:07 -0400 Subject: [PATCH 3/8] Updated tested-with clause --- dimensional.cabal | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/dimensional.cabal b/dimensional.cabal index bd6cc74..77cc6e6 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: From 5aedfb512c3dcc40c6941e60de4a59a4b4f8e1fc Mon Sep 17 00:00:00 2001 From: Laurent Rene de Cotret Date: Tue, 20 Aug 2024 20:38:34 -0400 Subject: [PATCH 4/8] Ignore type-default warnings in doctests --- src/Numeric/Units/Dimensional.hs | 2 ++ src/Numeric/Units/Dimensional/Dimensions/TermLevel.hs | 1 + src/Numeric/Units/Dimensional/Float.hs | 1 + src/Numeric/Units/Dimensional/Internal.hs | 1 + src/Numeric/Units/Dimensional/NonSI.hs | 1 + src/Numeric/Units/Dimensional/Quantities.hs | 1 + 6 files changed, 7 insertions(+) diff --git a/src/Numeric/Units/Dimensional.hs b/src/Numeric/Units/Dimensional.hs index e16f373..290595c 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 +-- >>> :seti -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 144d24e..2dd761e 100644 --- a/src/Numeric/Units/Dimensional/Dimensions/TermLevel.hs +++ b/src/Numeric/Units/Dimensional/Dimensions/TermLevel.hs @@ -44,6 +44,7 @@ import Prelude (id, all, fst, snd, fmap, otherwise, divMod, ($), (+), (-), (.), import qualified Prelude as P -- $setup +-- >>> :seti -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 0c33481..488eef8 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 6d9b15b..b075445 100644 --- a/src/Numeric/Units/Dimensional/Internal.hs +++ b/src/Numeric/Units/Dimensional/Internal.hs @@ -57,6 +57,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 fcef791..fb3b15a 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 ffd1c23..9237ccc 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. From 92fff35d7dedd3fd84c4c8c635119887217a615b Mon Sep 17 00:00:00 2001 From: Laurent Rene de Cotret Date: Tue, 20 Aug 2024 20:46:17 -0400 Subject: [PATCH 5/8] Updated doctest pipeline --- .github/workflows/ci.yaml | 7 ++++++- dimensional.cabal | 13 ------------- tests/DocTests.hs | 17 ----------------- 3 files changed, 6 insertions(+), 31 deletions(-) delete mode 100644 tests/DocTests.hs diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 33aca3e..d883751 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -56,4 +56,9 @@ jobs: - name: Run tests run: | - cabal test \ No newline at end of file + cabal test + + - name: Run doctests + run: | + cabal install doctest --ignore-project + cabal repl dimensional --build-depends=QuickCheck --with-ghc=doctest \ No newline at end of file diff --git a/dimensional.cabal b/dimensional.cabal index 77cc6e6..44b0957 100644 --- a/dimensional.cabal +++ b/dimensional.cabal @@ -97,19 +97,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/tests/DocTests.hs b/tests/DocTests.hs deleted file mode 100644 index a73fd1e..0000000 --- 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++)) From 4b4dcf2ac085b776fa2ea680555c3e0691a0b083 Mon Sep 17 00:00:00 2001 From: Laurent Rene de Cotret Date: Tue, 20 Aug 2024 20:55:06 -0400 Subject: [PATCH 6/8] Use more common :set ghci command --- .github/workflows/ci.yaml | 4 +++- src/Numeric/Units/Dimensional.hs | 2 +- src/Numeric/Units/Dimensional/Dimensions/TermLevel.hs | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index d883751..49b80f2 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -58,7 +58,9 @@ jobs: 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 + 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/src/Numeric/Units/Dimensional.hs b/src/Numeric/Units/Dimensional.hs index 290595c..4fac56a 100644 --- a/src/Numeric/Units/Dimensional.hs +++ b/src/Numeric/Units/Dimensional.hs @@ -240,7 +240,7 @@ import qualified Numeric.Units.Dimensional.Variants as V -- $setup -- >>> :set -XFlexibleInstances -- >>> :set -XNoImplicitPrelude --- >>> :seti -fno-warn-orphans +-- >>> :set -fno-warn-orphans -- >>> :set -fno-warn-type-defaults -- >>> import Test.QuickCheck.Arbitrary -- >>> import Numeric.Units.Dimensional.Prelude diff --git a/src/Numeric/Units/Dimensional/Dimensions/TermLevel.hs b/src/Numeric/Units/Dimensional/Dimensions/TermLevel.hs index 2dd761e..7a5c48a 100644 --- a/src/Numeric/Units/Dimensional/Dimensions/TermLevel.hs +++ b/src/Numeric/Units/Dimensional/Dimensions/TermLevel.hs @@ -44,7 +44,7 @@ import Prelude (id, all, fst, snd, fmap, otherwise, divMod, ($), (+), (-), (.), import qualified Prelude as P -- $setup --- >>> :seti -fno-warn-orphans +-- >>> :set -fno-warn-orphans -- >>> import Prelude (negate) -- >>> import Control.Applicative -- >>> import Test.QuickCheck.Arbitrary From 48d621e22df114efc20483847de78d5ed5157a7d Mon Sep 17 00:00:00 2001 From: Laurent Rene de Cotret Date: Wed, 21 Aug 2024 09:59:35 -0400 Subject: [PATCH 7/8] Remove reference to travis build in README --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 7e6f6c3..7289398 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) From 81b41e27645b7b3a9c41039960514f725dcbb4a7 Mon Sep 17 00:00:00 2001 From: Laurent Rene de Cotret Date: Wed, 21 Aug 2024 11:23:26 -0400 Subject: [PATCH 8/8] Test with and without `binary` flag --- .github/workflows/ci.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 49b80f2..342b201 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -19,8 +19,7 @@ jobs: - "9.10.1" flags: - "" # base case - # Only activate after #224 has landed - # - "+binary" + - "+binary" steps: - uses: actions/checkout@v4