New .travis.yml using stack instead of cabal-meta.

This commit is contained in:
Felipe Lessa 2015-12-31 12:43:11 -02:00
parent 9d0ee44c06
commit 01b277b11e
4 changed files with 87 additions and 50 deletions

View File

@ -1,8 +1,11 @@
# Travis file upgraded to stack at 2015-31-12 using template from
# <http://docs.haskellstack.org/en/stable/travis_ci.html>.
#
# Travis file initially created at 2015-05-31 using template from
# <https://github.com/hvr/multi-ghc-travis/commit/c9c87d36c450d7f9cb3183dcaf1f77b60f916f28>
# and taking the idea of using cabal-meta from yesodweb/yesod.
# NB: don't set `language: haskell` here
sudo: false
services:
- redis-server
@ -10,55 +13,69 @@ services:
addons:
postgresql: "9.3"
# The following enables several GHC versions to be tested; often it's enough to test only against the last release in a major GHC version. Feel free to omit lines listings versions you don't need/want testing for.
env:
#- CABALVER=1.16 GHCVER=6.12.3
#- CABALVER=1.16 GHCVER=7.0.1
#- CABALVER=1.16 GHCVER=7.0.2
#- CABALVER=1.16 GHCVER=7.0.3
#- CABALVER=1.16 GHCVER=7.0.4
#- CABALVER=1.16 GHCVER=7.2.1
#- CABALVER=1.16 GHCVER=7.2.2
#- CABALVER=1.16 GHCVER=7.4.1
#- CABALVER=1.16 GHCVER=7.4.2
#- CABALVER=1.16 GHCVER=7.6.1
#- CABALVER=1.16 GHCVER=7.6.2
#- CABALVER=1.18 GHCVER=7.6.3
#- CABALVER=1.18 GHCVER=7.8.1 # see note about Alex/Happy for GHC >= 7.8
#- CABALVER=1.18 GHCVER=7.8.2
#- CABALVER=1.18 GHCVER=7.8.3
#- CABALVER=1.18 GHCVER=7.8.4
- CABALVER=1.20 GHCVER=7.8.4
- CABALVER=1.22 GHCVER=7.10.1
#- CABALVER=1.22 GHCVER=7.10.2
#- CABALVER=head GHCVER=head # see section about GHC HEAD snapshots
cache:
directories:
- $HOME/.stack
matrix:
include:
- env: GHCVER=7.8.4 RESOLVER=lts-2.22 EXTRADEPS="hedis-0.6.6" STACKARGS="--flag serversession-backend-redis:old-locale"
addons:
apt:
sources:
- hvr-ghc
packages:
- ghc-7.8.4
- env: GHCVER=7.10.2 RESOLVER=lts-3.4 EXTRADEPS="" STACKARGS=""
addons:
apt:
sources:
- hvr-ghc
packages:
- ghc-7.10.2
- env: GHCVER=7.10.2 RESOLVER=lts-3.20 EXTRADEPS="" STACKARGS=""
addons:
apt:
sources:
- hvr-ghc
packages:
- ghc-7.10.2
- env: GHCVER=head RESOLVER=nightly EXTRADEPS="" STACKARGS=""
addons:
apt:
sources:
- hvr-ghc
packages:
- ghc-head
allow_failures:
- env: GHCVER=head RESOLVER=nightly EXTRADEPS="" STACKARGS=""
# Note: the distinction between `before_install` and `install` is not important.
before_install:
- travis_retry sudo add-apt-repository -y ppa:hvr/ghc
- travis_retry sudo apt-get update
- travis_retry sudo apt-get install cabal-install-$CABALVER ghc-$GHCVER # see note about happy/alex
- export PATH=/opt/ghc/$GHCVER/bin:/opt/cabal/$CABALVER/bin:$HOME/.cabal/bin:$PATH
# Download and unpack the stack executable
- 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'
- export PATH=/opt/ghc/$GHCVER/bin:$PATH
- export RUNSTACK="stack --no-terminal --skip-ghc-check --resolver=$RESOLVER"
install:
- cabal --version
- echo "$(ghc --version) [$(ghc --print-project-git-commit-id 2> /dev/null || echo '?')]"
- travis_retry cabal update
- cabal install cabal-src cabal-meta alex happy
- $RUNSTACK --version
- echo "$(ghc --version) [$(ghc --print-project-git-commit-id 2> /dev/null || echo '?')]"
- $RUNSTACK install alex happy
before_script:
- psql -c "CREATE USER test WITH PASSWORD 'test';" -U postgres
- psql -c "CREATE DATABASE test;" -U postgres
- psql -c "GRANT ALL PRIVILEGES ON DATABASE test TO test;" -U postgres
- psql -c "CREATE USER test WITH PASSWORD 'test';" -U postgres
- psql -c "CREATE DATABASE test;" -U postgres
- psql -c "GRANT ALL PRIVILEGES ON DATABASE test TO test;" -U postgres
- for dep in $EXTRADEPS; do echo " - $dep" >> stack.yaml; done
# Here starts the actual work to be performed for the package under test; any command which exits with a non-zero exit code causes the build to fail.
script:
- cabal-meta install --enable-tests --enable-benchmarks --force-reinstalls
- serversession/dist/build/tests/tests
- serversession-backend-acid-state/dist/build/tests/tests
- du -hcs state; rm -Rfv state
- serversession-backend-persistent/dist/build/tests/tests --skip=100\ MiB
- du -hcs test.db*; rm -Rfv test.db*
- psql -c 'SELECT COUNT(*) FROM "persistent_session";' -U test test; psql -c 'DROP DATABASE test;' -U postgres
- serversession-backend-redis/dist/build/tests/tests
- redis-cli FLUSHALL
- $RUNSTACK test $STACKARGS serversession
- $RUNSTACK test $STACKARGS serversession-backend-acid-state
- du -hcs serversession-backend-acid-state/state; rm -Rfv serversession-backend-acid-state/state
- $RUNSTACK test $STACKARGS serversession-backend-persistent --test-arguments='"--skip=100 MiB"'
- du -hcs serversession-backend-persistent/test.db*; rm -Rfv serversession-backend-persistent/test.db*
- psql -c 'SELECT COUNT(*) FROM "persistent_session";' -U test test; psql -c 'DROP DATABASE test;' -U postgres
- $RUNSTACK test $STACKARGS serversession-backend-redis
- redis-cli FLUSHALL
- $RUNSTACK test $STACKARGS --no-run-tests # Make sure everything else builds

View File

@ -23,7 +23,7 @@ library
, cereal >= 0.4
, path-pieces
, persistent >= 2.1 && < 2.3
, tagged >= 0.8
, tagged >= 0.7
, text
, time
, transformers

View File

@ -13,6 +13,10 @@ homepage: https://github.com/yesodweb/serversession
description: API docs and the README are available at <http://www.stackage.org/package/serversession-backend-redis>
extra-source-files: README.md
flag old-locale
description: Use time-1.4 and old-locale (GHC 7.8).
default: False
library
hs-source-dirs: src
build-depends:
@ -20,17 +24,22 @@ library
, bytestring
, hedis == 0.6.*
, path-pieces
, tagged >= 0.8
, tagged >= 0.7
, text
, time >= 1.5
, time >= 1.4
, transformers
, unordered-containers
, serversession == 1.0.*
if flag(old-locale)
build-depends: time == 1.4.*, old-locale
else
build-depends: time >= 1.5
exposed-modules:
Web.ServerSession.Backend.Redis
Web.ServerSession.Backend.Redis.Internal
extensions:
CPP
DeriveDataTypeable
FlexibleContexts
OverloadedStrings

View File

@ -47,6 +47,11 @@ import qualified Data.Text.Encoding as TE
import qualified Data.Time.Clock as TI
import qualified Data.Time.Format as TI
#if MIN_VERSION_time(1,5,0)
import Data.Time.Format (defaultTimeLocale)
#else
import System.Locale (defaultTimeLocale)
#endif
----------------------------------------------------------------------
@ -184,13 +189,19 @@ printSession Session {..} =
-- | Parse 'UTCTime' from a 'ByteString' stored on Redis. Uses
-- 'error' on parse error.
parseUTCTime :: ByteString -> TI.UTCTime
parseUTCTime = TI.parseTimeOrError True TI.defaultTimeLocale timeFormat . B8.unpack
#if MIN_VERSION_time(1,5,0)
parseUTCTime = TI.parseTimeOrError True defaultTimeLocale timeFormat . B8.unpack
#else
parseUTCTime =
fromMaybe (error "Web.ServerSession.Backend.Redis.Internal.parseUTCTime") .
TI.parseTime defaultTimeLocale timeFormat . B8.unpack
#endif
-- | Convert a 'UTCTime' into a 'ByteString' to be stored on
-- Redis.
printUTCTime :: TI.UTCTime -> ByteString
printUTCTime = B8.pack . TI.formatTime TI.defaultTimeLocale timeFormat
printUTCTime = B8.pack . TI.formatTime defaultTimeLocale timeFormat
-- | Time format used when storing 'UTCTime'.