Skip to content

Commit

Permalink
Improve CI configuration
Browse files Browse the repository at this point in the history
* Remove doctests as a separate test suite section

* Add `cabal.project`

* Organaze stack yaml files

* Take care of compiler warnings
  • Loading branch information
lehins committed Dec 16, 2024
1 parent 46e16c1 commit f0d8ee3
Show file tree
Hide file tree
Showing 30 changed files with 649 additions and 131 deletions.
222 changes: 146 additions & 76 deletions .github/workflows/haskell.yml
Original file line number Diff line number Diff line change
@@ -1,119 +1,189 @@
name: Color-CI
name: CI

on:
push:
branches: [ '*' ]
branches: [ "master", "release/**" ]
pull_request:
branches: [ master ]
branches: [ "**" ]
schedule:
- cron: "0 5 * * 5"

defaults: { run: { shell: bash } }

# Cancel running workflows when a new workflow on the same PR or branch is started,
# but put scheduled workflows into their own group
concurrency:
group: ${{
format('{0}-{1}{2}',
github.workflow,
github.event.pull_request.number || github.ref,
github.event_name == 'schedule' && '-scheduled' || '')}}
cancel-in-progress: true

jobs:
build:
name: CI
test-with-stack:
name: Stack
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
# resolver: [nightly -- disabled for now, some issue with installing ghc
resolver: [lts-20, lts-19, lts-18, lts-16, lts-14, lts-12]
include:
- resolver: lts-12
ghc: 8.4.4
stack-yaml: stack-extra-deps.yaml
- resolver: lts-14
stack-yaml: stack-coveralls.yaml
- resolver: lts-16
ghc: 8.8.4
- resolver: lts-18

# Latest stable for MacOS: ghc-8.8.4
- resolver: lts-16
os: macos-latest
- resolver: lts-19
os: macos-latest
- resolver: lts-20
os: macos-latest
# Latest stable for Windows: ghc-8.6.4
- resolver: lts-14
os: windows-latest
- resolver: lts-19
os: windows-latest
- resolver: lts-20
os: windows-latest
- { os: Ubuntu-latest, resolver: lts-12, ghc: "8.4.4" }
- { os: Ubuntu-latest, resolver: lts-14, ghc: "8.6.5" }
- { os: Ubuntu-latest, resolver: lts-16, ghc: "8.8.4" }
- { os: Ubuntu-latest, resolver: lts-18, ghc: "8.10.7" }
- { os: Ubuntu-latest, resolver: lts-19, ghc: "9.0.2" }
- { os: Ubuntu-latest, resolver: lts-20, ghc: "9.2.8" }
- { os: Ubuntu-latest, resolver: lts-21, ghc: "9.4.8" }
- { os: Ubuntu-latest, resolver: lts-22, ghc: "9.6.6" }
- { os: Ubuntu-latest, resolver: lts-23, ghc: "9.8.4" }
- { os: Ubuntu-latest, resolver: nightly }
- { os: Windows-latest, resolver: lts-12, ghc: "8.4.4" }
- { os: Windows-latest, resolver: lts-14, ghc: "8.6.5" }
- { os: Windows-latest, resolver: lts-16, ghc: "8.8.4" }
- { os: Windows-latest, resolver: lts-18, ghc: "8.10.7" }
- { os: Windows-latest, resolver: lts-19, ghc: "9.0.2" }
- { os: Windows-latest, resolver: lts-20, ghc: "9.2.8" }
- { os: Windows-latest, resolver: lts-21, ghc: "9.4.8" }
- { os: Windows-latest, resolver: lts-22, ghc: "9.6.6" }
- { os: Windows-latest, resolver: lts-23, ghc: "9.8.4" }
- { os: Windows-latest, resolver: nightly }
- { os: MacOS-13, resolver: lts-12, ghc: "8.4.4" }
- { os: MacOS-13, resolver: lts-14, ghc: "8.6.5" }
- { os: MacOS-13, resolver: lts-16, ghc: "8.8.4" }
- { os: MacOS-13, resolver: lts-18, ghc: "8.10.7" }
- { os: MacOS-13, resolver: lts-19, ghc: "9.0.2" }
- { os: MacOS-latest, resolver: lts-20, ghc: "9.2.8" }
- { os: MacOS-latest, resolver: lts-21, ghc: "9.4.8" }
- { os: MacOS-latest, resolver: lts-22, ghc: "9.6.6" }
- { os: MacOS-latest, resolver: lts-23, ghc: "9.8.4" }
- { os: MacOS-latest, resolver: nightly }

env:
STACK_YAML: stack.yaml
STACK_ARGS: '--resolver ${{ matrix.resolver }}'
cache-version: v5 # bump up this version to invalidate currently stored cache
STACK_YAML: ${{ matrix.stack-yaml || matrix.ghc != '' && format('stack/ghc-{0}.yaml', matrix.ghc) || 'stack.yaml' }}
STACK_ARGS: '--resolver ${{ matrix.resolver }} --system-ghc'
cache-version: v0 # bump up this version to invalidate currently stored cache
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- uses: haskell-actions/setup@v2
id: setup-haskell-cabal
name: Setup Haskell
with:
ghc-version: ${{ matrix.ghc }}
enable-stack: true
stack-version: 'latest'

- name: Cache
id: cache
uses: actions/cache@v2
if: matrix.os != 'macos-latest'
uses: actions/cache@v4
with:
path: |
~/.stack
${{ steps.setup-haskell-cabal.outputs.stack-root }}
.stack-work
Color/.stack-work
key: ${{ runner.os }}-${{ matrix.resolver }}-${{ env.cache-version }}
restore-keys: |
${{ runner.os }}-${{ matrix.resolver }}-${{ env.cache-version }}
- name: Cache
id: cache-macos
uses: actions/cache@v2
if: matrix.os == 'macos-latest'
with:
path: |
~/.stack
key: ${{ runner.os }}-${{ matrix.resolver }}-${{ env.cache-version }}
restore-keys: |
${{ runner.os }}-${{ matrix.resolver }}-${{ env.cache-version }}
- name: Workaround setup-exe-cache failure on macos
if: steps.cache-macos.outputs.cache-hit == 'true' && matrix.os == 'macos-latest'
run: |
rm -r ~/.stack/setup-exe-cache
- name: Windows Cache
id: cache-windows
uses: actions/cache@v2
uses: actions/cache@v4
if: matrix.os == 'windows-latest'
with:
path: |
C:\\Users\\RUNNER~1\\AppData\\Roaming\\stack
C:\\Users\\RUNNER~1\\AppData\\Local\\Programs\\stack
key: ${{ runner.os }}-${{ matrix.resolver }}-programs-${{ env.cache-version }}
restore-keys: |
${{ runner.os }}-${{ matrix.resolver }}-programs-${{ env.cache-version }}
- name: Ubuntu install GHC
if: matrix.ghc != '' && matrix.os == 'ubuntu-latest'
- name: Reset modtime
run: |
sudo add-apt-repository ppa:hvr/ghc -y
sudo apt-get update
sudo apt-get install ghc-${{ matrix.ghc }}
- name: Install Stack and local GHC
set -ex
curl -sSL https://raw.githubusercontent.com/lehins/utils/master/haskell/git-modtime/git-modtime.hs -o git-modtime.hs
runhaskell -- git-modtime.hs -f .stack-work-root/tree-contents.txt
- name: Build
run: |
set -ex
curl -sSL https://get.haskellstack.org/ | sh -s - -f
curl -sSL https://raw.githubusercontent.com/lehins/utils/786c3fe7e9e1345d7b403019f52e344627224edf/haskell/git-modtime/git-modtime.hs -o git-modtime.hs
[ -n "${{ matrix.ghc }}" ] && [ "${{ matrix.os }}" == "ubuntu-latest" ] && STACK_ARGS="$STACK_ARGS --system-ghc"
[ -n "${{ matrix.stack-yaml }}" ] && STACK_YAML=${{ matrix.stack-yaml }}
stack $STACK_ARGS runghc git-modtime.hs
- name: Tests
stack $STACK_ARGS test --no-run-tests --bench --no-run-benchmarks --haddock --no-haddock-deps
- name: Test
env:
COVERALLS_TOKEN: ${{ secrets.COVERALLS_TOKEN }}
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
run: |
set -ex
[ -n "${{ matrix.ghc }}" ] && [ "${{ matrix.os }}" == "ubuntu-latest" ] && STACK_ARGS="$STACK_ARGS --system-ghc"
[ -n "${{ matrix.stack-yaml }}" ] && STACK_YAML=${{ matrix.stack-yaml }}
if [ "${{ matrix.os }}.${{ matrix.resolver }}" == "ubuntu-latest.lts-14" ] && [ -n "${COVERALLS_TOKEN}" ]; then
stack $STACK_ARGS test Color:tests --coverage --haddock --no-haddock-deps
if [ "${{ matrix.os }}.${{ matrix.resolver }}" == "ubuntu-latest.lts-21" ] && [ -n "${COVERALLS_REPO_TOKEN}" ]; then
stack $STACK_ARGS test --coverage
stack $STACK_ARGS hpc report --all
curl -L https://github.com/rubik/stack-hpc-coveralls/releases/download/v0.0.6.1/shc-linux-x64-8.8.4.tar.bz2 | tar xj shc
./shc --repo-token="$COVERALLS_TOKEN" --partial-coverage --fetch-coverage combined custom
curl -L https://github.com/rubik/stack-hpc-coveralls/releases/download/v0.0.7.0/shc-Linux-X64.tar.bz2 | tar xj shc
./shc --repo-token="$COVERALLS_REPO_TOKEN" --partial-coverage --fetch-coverage combined custom
else
stack $STACK_ARGS test Color:tests Color:doctests --bench --no-run-benchmarks --haddock --no-haddock-deps
stack $STACK_ARGS test
fi
test-with-cabal:
name: Cabal
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- { cabal: "3.12", os: ubuntu-latest, ghc: "8.4.4" }
- { cabal: "3.12", os: ubuntu-latest, ghc: "8.6.5" }
- { cabal: "3.12", os: ubuntu-latest, ghc: "8.8.4" }
- { cabal: "3.12", os: ubuntu-latest, ghc: "8.10.7" }
- { cabal: "3.12", os: ubuntu-latest, ghc: "9.0.2" }
- { cabal: "3.12", os: ubuntu-latest, ghc: "9.2.8" }
- { cabal: "3.12", os: ubuntu-latest, ghc: "9.4.8" }
- { cabal: "3.12", os: ubuntu-latest, ghc: "9.6.6" }
- { cabal: "3.12", os: ubuntu-latest, ghc: "9.8.2" }
- { cabal: "3.12", os: ubuntu-latest, ghc: "9.10.1" }
- { cabal: "3.12", os: windows-latest, ghc: "9.0.2" }
- { cabal: "3.12", os: windows-latest, ghc: "9.2.8" }
- { cabal: "3.12", os: windows-latest, ghc: "9.4.8" }
- { cabal: "3.12", os: windows-latest, ghc: "9.6.6" }
- { cabal: "3.12", os: windows-latest, ghc: "9.8.2" }
- { cabal: "3.12", os: windows-latest, ghc: "9.10.1" }
- { cabal: "3.12", os: macOS-13, ghc: "9.0.2" }
- { cabal: "3.12", os: macOS-latest, ghc: "9.2.8" }
- { cabal: "3.12", os: macOS-latest, ghc: "9.4.8" }
- { cabal: "3.12", os: macOS-latest, ghc: "9.6.6" }
- { cabal: "3.12", os: macOS-latest, ghc: "9.8.2" }
- { cabal: "3.12", os: macOS-latest, ghc: "9.10.1" }

env:
cache-version: v0 # bump up this version to invalidate currently stored cache
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: Cache Cabal Store
id: cache
uses: actions/cache@v4
with:
path: |
${{ steps.setup-haskell-cabal.outputs.cabal-store }}
dist-newstyle
key: cabal-${{ runner.os }}-${{ matrix.ghc }}-${{ env.cache-version }}
restore-keys: |
cabal-${{ runner.os }}-${{ matrix.ghc }}-${{ env.cache-version }}
- name: Build
run: |
set -ex
cabal configure --haddock-all --enable-tests --enable-benchmarks
cabal build all --write-ghc-environment-files=always
- name: Test
run: |
set -ex
cabal test all
- name: Doctest
run: |
set -ex
cabal install doctest --ignore-project --overwrite-policy=always
cabal repl Color --build-depends=QuickCheck --build-depends=JuicyPixels --build-depends=QuickCheck --with-compiler=doctest --repl-options='-w -Wdefault'
- name: Check Cabal Files
run: |
set -ex
cd Color
cabal -vnormal check
22 changes: 2 additions & 20 deletions Color/Color.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ library
ghc-options: -Wall
-Wincomplete-record-updates
-Wincomplete-uni-patterns
-Wredundant-constraints
if impl(ghc < 9.0) || impl(ghc >= 9.6)
ghc-options: -Wredundant-constraints

test-suite tests
type: exitcode-stdio-1.0
Expand Down Expand Up @@ -160,25 +161,6 @@ test-suite tests
-threaded
-freduction-depth=0

test-suite doctests
type: exitcode-stdio-1.0
hs-source-dirs: tests
main-is: doctests.hs
build-depends: base
if impl(ghc >= 8.2) && impl(ghc < 8.10)
build-depends: doctest >=0.16
, QuickCheck
, Color
, JuicyPixels
default-language: Haskell2010
ghc-options: -Wall
-Wincomplete-record-updates
-Wincomplete-uni-patterns
-Wredundant-constraints
-fno-warn-orphans
-threaded


benchmark conversion
type: exitcode-stdio-1.0
hs-source-dirs: bench
Expand Down
1 change: 1 addition & 0 deletions Color/src/Graphics/Color/Adaptation/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
-- |
-- Module : Graphics.Color.Adaptation.Internal
-- Copyright : (c) Alexey Kuleshevich 2019-2020
Expand Down
6 changes: 6 additions & 0 deletions Color/src/Graphics/Color/Adaptation/VonKries.hs
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE NegativeLiterals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
#if __GLASGOW_HASKELL__ >= 906
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE PolyKinds #-}
#else
{-# LANGUAGE TypeInType #-}
#endif
-- |
-- Module : Graphics.Color.Adaptation.VonKries
-- Copyright : (c) Alexey Kuleshevich 2018-2020
Expand Down
4 changes: 3 additions & 1 deletion Color/src/Graphics/Color/Algebra.hs
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,11 @@ module Graphics.Color.Algebra

import Data.Typeable
import Foreign.Ptr
import Control.Applicative
import Foreign.Storable
import Graphics.Color.Algebra.Elevator
#if MIN_VERSION_base(4,10,0) && !MIN_VERSION_base(4,18,0)
import Control.Applicative (liftA2)
#endif


--------
Expand Down
4 changes: 3 additions & 1 deletion Color/src/Graphics/Color/Algebra/Elevator.hs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,9 @@ double2Word64 d'

-- | Differs from `fromIntegral` due to: [GHC #17782](https://gitlab.haskell.org/ghc/ghc/issues/17782)
--
-- >>> fromIntegral (maxBound :: Word64) :: Double
-- This is the value for ghc < 9.2
--
-- > fromIntegral (maxBound :: Word64) :: Double
-- 1.844674407370955e19
--
maxWord64 :: Double
Expand Down
11 changes: 6 additions & 5 deletions Color/src/Graphics/Color/Model/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}
-- |
-- Module : Graphics.Color.Model.Internal
Expand Down Expand Up @@ -43,7 +44,7 @@ module Graphics.Color.Model.Internal
, VU.Vector(V_Color)
) where

import Control.Applicative
import qualified Control.Applicative as A
import Control.DeepSeq (NFData(rnf), deepseq)
import Data.Default.Class (Default(..))
import Data.Foldable
Expand Down Expand Up @@ -94,11 +95,11 @@ instance ColorModel cs e => Default (Color cs e) where


instance ColorModel cs e => Num (Color cs e) where
(+) = liftA2 (+)
(+) = A.liftA2 (+)
{-# INLINE (+) #-}
(-) = liftA2 (-)
(-) = A.liftA2 (-)
{-# INLINE (-) #-}
(*) = liftA2 (*)
(*) = A.liftA2 (*)
{-# INLINE (*) #-}
abs = fmap abs
{-# INLINE abs #-}
Expand All @@ -109,7 +110,7 @@ instance ColorModel cs e => Num (Color cs e) where


instance (ColorModel cs e, Fractional e) => Fractional (Color cs e) where
(/) = liftA2 (/)
(/) = A.liftA2 (/)
{-# INLINE (/) #-}
recip = fmap recip
{-# INLINE recip #-}
Expand Down
Loading

0 comments on commit f0d8ee3

Please sign in to comment.