From 55da9182404f206416429ceb266d0c30510cc708 Mon Sep 17 00:00:00 2001 From: Joe Nelson Date: Wed, 27 Jan 2016 16:12:48 -0800 Subject: [PATCH 1/8] Build with stack on CI and use harsher setttings --- circle.yml | 27 ++++++++++++++++----------- postgrest.cabal | 2 +- stack.yaml | 11 +++++++---- 3 files changed, 24 insertions(+), 16 deletions(-) diff --git a/circle.yml b/circle.yml index f512b7ad7..f6333bfb9 100644 --- a/circle.yml +++ b/circle.yml @@ -1,16 +1,21 @@ -machine: +dependencies: + cache_directories: + - "~/.stack" 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 + 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 --coverage + - stack sdist diff --git a/postgrest.cabal b/postgrest.cabal index 8d855be62..14352ed33 100644 --- a/postgrest.cabal +++ b/postgrest.cabal @@ -30,7 +30,7 @@ executable postgrest 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 diff --git a/stack.yaml b/stack.yaml index 2adf4b173..846ff18cf 100644 --- a/stack.yaml +++ b/stack.yaml @@ -1,8 +1,11 @@ -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 +# Almost all warnings, plus minimal-imports for packunused +ghc-options: + postgrest: -ddump-minimal-imports -Werror -Wall -fwarn-incomplete-uni-patterns -fwarn-incomplete-record-updates -fwarn-monomorphism-restriction -fwarn-auto-orphans -fwarn-missing-local-sigs -fwarn-missing-exported-sigs -fwarn-missing-import-lists -fwarn-identities + +packages: +- '.' From 536acec82084d426db338d304cef28e4d35adef8 Mon Sep 17 00:00:00 2001 From: Joe Nelson Date: Wed, 27 Jan 2016 17:31:57 -0800 Subject: [PATCH 2/8] Turn down warning level a little --- src/PostgREST/App.hs | 2 +- stack.yaml | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) 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 846ff18cf..010ef7e76 100644 --- a/stack.yaml +++ b/stack.yaml @@ -3,9 +3,8 @@ extra-deps: - hasql-0.19.3.3 - Ranged-sets-0.3.0 - packdeps-0.4.2.1 -# Almost all warnings, plus minimal-imports for packunused ghc-options: - postgrest: -ddump-minimal-imports -Werror -Wall -fwarn-incomplete-uni-patterns -fwarn-incomplete-record-updates -fwarn-monomorphism-restriction -fwarn-auto-orphans -fwarn-missing-local-sigs -fwarn-missing-exported-sigs -fwarn-missing-import-lists -fwarn-identities + postgrest: -Werror -Wall -fwarn-monomorphism-restriction -fwarn-missing-exported-sigs -fwarn-identities packages: - '.' From e02dc2e92e3a6310e70099101f86e37793749246 Mon Sep 17 00:00:00 2001 From: Joe Nelson Date: Wed, 27 Jan 2016 18:51:53 -0800 Subject: [PATCH 3/8] Remove redundant do --- test/SpecHelper.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From 4679e2a514ab87b72a9c564ed19fb494ec9d2f3c Mon Sep 17 00:00:00 2001 From: Joe Nelson Date: Thu, 28 Jan 2016 13:17:49 -0800 Subject: [PATCH 4/8] Haddock coverage report not working, removing for now --- circle.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/circle.yml b/circle.yml index f6333bfb9..6e2483ef0 100644 --- a/circle.yml +++ b/circle.yml @@ -17,5 +17,5 @@ test: - git ls-files | grep '\.l\?hs$' | xargs stack exec -- hlint -X QuasiQuotes "$@" - stack exec -- packdeps *.cabal || true - stack exec -- cabal check - - stack haddock --coverage + - stack haddock - stack sdist From 1a3c54793dbba1ed4f4a98d7546068f738e7cce7 Mon Sep 17 00:00:00 2001 From: Joe Nelson Date: Thu, 28 Jan 2016 14:00:33 -0800 Subject: [PATCH 5/8] Build only haddocks for postgrest, not deps --- circle.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/circle.yml b/circle.yml index 6e2483ef0..43ce5f592 100644 --- a/circle.yml +++ b/circle.yml @@ -17,5 +17,5 @@ test: - git ls-files | grep '\.l\?hs$' | xargs stack exec -- hlint -X QuasiQuotes "$@" - stack exec -- packdeps *.cabal || true - stack exec -- cabal check - - stack haddock + - stack haddock --no-haddock-deps - stack sdist From c887f2b3b40fcc35305048248b39d566ab614aa4 Mon Sep 17 00:00:00 2001 From: Joe Nelson Date: Thu, 28 Jan 2016 14:03:44 -0800 Subject: [PATCH 6/8] Move ghc-options in stack config and out of cabal file --- postgrest.cabal | 14 -------------- stack.yaml | 2 +- 2 files changed, 1 insertion(+), 15 deletions(-) diff --git a/postgrest.cabal b/postgrest.cabal index 14352ed33..5374944d4 100644 --- a/postgrest.cabal +++ b/postgrest.cabal @@ -22,11 +22,6 @@ 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 @@ -80,11 +75,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 @@ -136,10 +126,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 diff --git a/stack.yaml b/stack.yaml index 010ef7e76..1774ffffa 100644 --- a/stack.yaml +++ b/stack.yaml @@ -4,7 +4,7 @@ extra-deps: - Ranged-sets-0.3.0 - packdeps-0.4.2.1 ghc-options: - postgrest: -Werror -Wall -fwarn-monomorphism-restriction -fwarn-missing-exported-sigs -fwarn-identities + postgrest: -O2 -Werror -Wall -fwarn-monomorphism-restriction -fwarn-missing-exported-sigs -fwarn-identities packages: - '.' From 2175ae4d287323b94c81828baf992d11ba81cceb Mon Sep 17 00:00:00 2001 From: Joe Nelson Date: Thu, 28 Jan 2016 14:30:00 -0800 Subject: [PATCH 7/8] Build test deps in cacheable phase --- circle.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/circle.yml b/circle.yml index 43ce5f592..6bd867c60 100644 --- a/circle.yml +++ b/circle.yml @@ -1,6 +1,7 @@ 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 @@ -10,6 +11,7 @@ dependencies: override: - stack setup - stack install hlint packdeps cabal-install + - stack build --test --no-run-tests test: override: From e6e324e8ff464e2f3ffc60def0f4328825e00a79 Mon Sep 17 00:00:00 2001 From: Joe Nelson Date: Thu, 28 Jan 2016 17:32:38 -0800 Subject: [PATCH 8/8] Trim unused packages --- postgrest.cabal | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/postgrest.cabal b/postgrest.cabal index 5374944d4..36b7250eb 100644 --- a/postgrest.cabal +++ b/postgrest.cabal @@ -34,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 @@ -46,7 +47,6 @@ executable postgrest , string-conversions , text , time - , transformers , unordered-containers , vector , wai >= 3.0.1 @@ -54,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 @@ -104,7 +103,6 @@ library , wai-extra , wai-middleware-static , HTTP - , MissingH , Ranged-sets Other-Modules: Paths_postgrest @@ -159,7 +157,6 @@ Test-Suite spec , errors , hasql , heredoc - , hlint , hspec == 2.2.* , hspec-wai , hspec-wai-json @@ -167,11 +164,9 @@ Test-Suite spec , interpolatedstring-perl6 , jwt , optparse-applicative - , packdeps , parsec , process , regex-tdfa - , resource-pool , safe , scientific , string-conversions @@ -184,5 +179,4 @@ Test-Suite spec , wai-extra , wai-middleware-static , HTTP - , MissingH , Ranged-sets