diff --git a/circle.yml b/circle.yml index f512b7ad7..6bd867c60 100644 --- a/circle.yml +++ b/circle.yml @@ -1,16 +1,23 @@ -machine: +dependencies: + cache_directories: + - "~/.stack" + - ".stack-work" pre: + - sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 575159689BEFB442 + - echo 'deb http://download.fpcomplete.com/ubuntu precise main'|sudo tee /etc/apt/sources.list.d/fpco.list + - sudo apt-get update && sudo apt-get install stack -y - createuser --superuser --no-password postgrest_test - createdb -O postgrest_test -U ubuntu postgrest_test - ghc: - version: 7.10.1 -dependencies: override: - - cabal update - - cabal sandbox init - - cabal install --upgrade-dependencies --constraint="template-haskell installed" --dependencies-only --enable-tests --reorder-goals - - cabal configure --enable-tests -f ci + - stack setup + - stack install hlint packdeps cabal-install + - stack build --test --no-run-tests + test: - post: - - cabal exec hlint -- -X QuasiQuotes src/**/*.hs test/**/*.hs - - cabal exec packdeps postgrest.cabal || true + override: + - stack test + - git ls-files | grep '\.l\?hs$' | xargs stack exec -- hlint -X QuasiQuotes "$@" + - stack exec -- packdeps *.cabal || true + - stack exec -- cabal check + - stack haddock --no-haddock-deps + - stack sdist diff --git a/postgrest.cabal b/postgrest.cabal index 8d855be62..36b7250eb 100644 --- a/postgrest.cabal +++ b/postgrest.cabal @@ -22,15 +22,10 @@ Flag CI Default: False executable postgrest - if flag(ci) - ghc-options: -Wall -W -Werror - else - ghc-options: -Wall -W -O2 - main-is: PostgREST/Main.hs default-extensions: OverloadedStrings, ScopedTypeVariables, QuasiQuotes, LambdaCase default-language: Haskell2010 - build-depends: aeson >= 0.8 + build-depends: aeson >= 0.8 && < 0.10 , base >= 4.8 && < 5 , bytestring , case-insensitive @@ -39,6 +34,7 @@ executable postgrest , contravariant , errors , hasql >= 0.19.3.3 && < 0.20 + , http-types , interpolatedstring-perl6 , jwt , optparse-applicative >= 0.11 && < 0.13 @@ -51,7 +47,6 @@ executable postgrest , string-conversions , text , time - , transformers , unordered-containers , vector , wai >= 3.0.1 @@ -59,8 +54,7 @@ executable postgrest , wai-extra , wai-middleware-static >= 0.6.0 , warp >= 3.1.0 - , HTTP, http-types - , MissingH + , HTTP , Ranged-sets if !os(windows) build-depends: unix >= 2.7 && < 3 @@ -80,11 +74,6 @@ executable postgrest , PostgREST.Types library - if flag(ci) - ghc-options: -Wall -W -Werror - else - ghc-options: -Wall -W -O2 - default-language: Haskell2010 default-extensions: OverloadedStrings, ScopedTypeVariables, QuasiQuotes build-depends: aeson @@ -114,7 +103,6 @@ library , wai-extra , wai-middleware-static , HTTP - , MissingH , Ranged-sets Other-Modules: Paths_postgrest @@ -136,10 +124,6 @@ Test-Suite spec Default-Language: Haskell2010 default-extensions: OverloadedStrings, ScopedTypeVariables, QuasiQuotes, LambdaCase Hs-Source-Dirs: test, src - if flag(ci) - ghc-options: -Wall -W -Werror - else - ghc-options: -Wall -W -O2 Main-Is: Main.hs Other-Modules: Feature.AuthSpec , Feature.CorsSpec @@ -173,7 +157,6 @@ Test-Suite spec , errors , hasql , heredoc - , hlint , hspec == 2.2.* , hspec-wai , hspec-wai-json @@ -181,11 +164,9 @@ Test-Suite spec , interpolatedstring-perl6 , jwt , optparse-applicative - , packdeps , parsec , process , regex-tdfa - , resource-pool , safe , scientific , string-conversions @@ -198,5 +179,4 @@ Test-Suite spec , wai-extra , wai-middleware-static , HTTP - , MissingH , Ranged-sets diff --git a/src/PostgREST/App.hs b/src/PostgREST/App.hs index 623a5890f..dd589c730 100644 --- a/src/PostgREST/App.hs +++ b/src/PostgREST/App.hs @@ -85,7 +85,7 @@ app dbStructure conf reqBody req = then responseLBS status404 [] "" else responseLBS status200 [contentTypeH] (cs body) else do - let frm = toInteger $ rangeOffset range + let frm = rangeOffset range to = frm + toInteger queryTotal - 1 contentRange = contentRangeH frm to (toInteger <$> tableTotal) status = rangeStatus frm to (toInteger <$> tableTotal) diff --git a/stack.yaml b/stack.yaml index 2adf4b173..1774ffffa 100644 --- a/stack.yaml +++ b/stack.yaml @@ -1,8 +1,10 @@ -flags: {} -packages: -- '.' +resolver: lts-5.0 extra-deps: - hasql-0.19.3.3 - Ranged-sets-0.3.0 - packdeps-0.4.2.1 -resolver: lts-5.0 +ghc-options: + postgrest: -O2 -Werror -Wall -fwarn-monomorphism-restriction -fwarn-missing-exported-sigs -fwarn-identities + +packages: +- '.' diff --git a/test/SpecHelper.hs b/test/SpecHelper.hs index 3dc123bd6..886aaf1e0 100644 --- a/test/SpecHelper.hs +++ b/test/SpecHelper.hs @@ -40,7 +40,7 @@ cfgLimitRows = cfg dbString . Just withApp :: AppConfig -> DbStructure -> H.Connection -> ActionWith Application -> IO () -withApp config dbStructure c perform = do +withApp config dbStructure c perform = perform $ defaultMiddle $ \req resp -> do time <- getPOSIXTime body <- strictRequestBody req