Skip to content

Commit 1b54abc

Browse files
committed
integrated with travis
1 parent c640906 commit 1b54abc

14 files changed

Lines changed: 171 additions & 106 deletions

File tree

.travis.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
language: c
2+
3+
sudo: false
4+
5+
services:
6+
- postgresql
7+
addons:
8+
postgresql: "9.4"
9+
10+
matrix:
11+
include:
12+
- env: CABALVER=1.18 GHCVER=7.8.4
13+
addons: {apt: {packages: [cabal-install-1.18,ghc-7.8.4], sources: [hvr-ghc]}}
14+
- env: CABALVER=1.22 GHCVER=7.10.3
15+
addons: {apt: {packages: [cabal-install-1.22,ghc-7.10.3], sources: [hvr-ghc]}}
16+
- env: CABALVER=1.24 GHCVER=8.0.1
17+
addons: {apt: {packages: [cabal-install-1.24,ghc-8.0.1], sources: [hvr-ghc]}}
18+
- env: CABALVER=head GHCVER=head
19+
addons: {apt: {packages: [cabal-install-head,ghc-head], sources: [hvr-ghc]}}
20+
21+
allow_failures:
22+
- env: CABALVER=head GHCVER=head
23+
24+
before_install:
25+
- export PATH=/opt/ghc/$GHCVER/bin:/opt/cabal/$CABALVER/bin:$PATH
26+
27+
install:
28+
- cabal --version
29+
- echo "$(ghc --version) [$(ghc --print-project-git-commit-id 2> /dev/null || echo '?')]"
30+
- travis_retry cabal update
31+
- cabal install --only-dependencies --enable-tests
32+
33+
before_script:
34+
- psql -U postgres -c 'create database test_db;'
35+
- psql -U postgres -c "create role test_role with password 'TEST' login;"
36+
37+
script:
38+
- case "$CABALVER" in
39+
"1.18") cabal configure --enable-tests --enable-library-coverage -v2 -f dev ;;
40+
*) cabal configure --enable-tests --enable-coverage -v2 -f dev ;;
41+
esac
42+
- cabal build
43+
- cabal test --show-details=always
44+
- cabal sdist
45+
- cabal haddock | grep "100%" | wc -l | grep "5"
46+
47+
notifications:
48+
email:
49+
recipients:
50+
- zohl@fmap.me

default.nix

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ mkDerivation {
1111
template-haskell text time
1212
];
1313
testHaskellDepends = [
14-
base bytestring case-conversion HUnit postgresql-simple text
14+
attoparsec base bytestring case-conversion HUnit postgresql-simple
15+
text
1516
];
16-
description = "A FFI-like bindings to stored functions";
17+
description = "A FFI-like bindings for PostgreSQL stored functions";
1718
license = stdenv.lib.licenses.gpl3;
1819
}

examples/Common.hs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,19 @@ import qualified Data.ByteString.Char8 as BS
1515

1616

1717
data TestEnv = TestEnv {
18-
connectInfo :: ConnectInfo
18+
envConnectInfo :: ConnectInfo
1919
}
2020

2121
bindOptions :: Options
2222
bindOptions = defaultOptions {
2323
nameModifier = convertCase Snake Camel . ("sql_" ++)
24-
}
24+
}
2525

2626
withConn :: ConnectInfo -> (Connection -> IO a) -> IO a
2727
withConn connectInfo = bracket (connect connectInfo) close
28-
28+
2929
mkTest :: (Connection -> IO ()) -> (Connection -> IO()) -> TestEnv -> Test
30-
mkTest setup run env = TestCase $ withConn (connectInfo env)
30+
mkTest setup run env = TestCase $ withConn (envConnectInfo env)
3131
(\conn -> mapM_ ($ conn) [begin, setup, run, rollback])
3232

3333
include :: Connection -> String -> IO ()

examples/ExMessages.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ module ExMessages (
1818
) where
1919

2020
import Test.HUnit
21-
import Database.PostgreSQL.Simple.Bind (bindFunction)
21+
import Database.PostgreSQL.Simple.Bind (bindFunction)
2222
import Database.PostgreSQL.Simple.Bind.Types()
2323
import Database.PostgreSQL.Simple (Connection)
2424
import Prelude hiding (getContents)

examples/ExNumDumpster.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ module ExNumDumpster (
1818
import Test.HUnit
1919
import Database.PostgreSQL.Simple
2020

21-
import Database.PostgreSQL.Simple.Bind (bindFunction)
21+
import Database.PostgreSQL.Simple.Bind (bindFunction)
2222
import Database.PostgreSQL.Simple.Bind.Types()
2323

2424
import Common (bindOptions, TestEnv, mkTest, include)
@@ -46,14 +46,14 @@ iterFib conn = do
4646
sqlClear conn
4747
addManyNums conn [x, x']
4848
return x'
49-
49+
5050

5151
numDumpster :: TestEnv -> Test
5252
numDumpster = mkTest (flip include "./examples/sql/numdumpster.sql")
5353
(\conn -> do
5454
sqlAddNum conn 1
5555
sqlGetLastNum conn >>= \x -> assertEqual "check get_last_num" 1 x
56-
56+
5757
sqlClear conn
5858
addManyNums conn [1, 2, 3, 4]
5959
sqlGetAllNums conn >>= \xs -> assertEqual "check get_all_nums" [1, 2, 3, 4] xs

examples/ExUsers.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ instance FromField User where
5252

5353
parseValue bs = ($ (parseOnly parser bs)) $ either
5454
(returnError ConversionFailed f) pure
55-
55+
5656
parser = do
5757
_ <- char '('
5858
userId' <- decimal
@@ -76,8 +76,8 @@ users = mkTest (flip include "./examples/sql/users.sql")
7676

7777
sqlGetUsers conn (Just "Mr. Ba_") >>=
7878
\xs -> assertEqual "check get_users 2" [mrBarId, mrBazId] (map userId xs)
79-
80-
sqlDelUser conn mrBarId
79+
80+
sqlDelUser conn mrBarId
8181

8282
sqlGetUsers conn Nothing >>=
8383
\xs -> assertEqual "check get_users 3" [mrFooId, mrBazId] (map userId xs))

examples/Main.hs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,18 @@ import System.IO
66
import System.Exit
77
import Database.PostgreSQL.Simple
88

9-
import Common (TestEnv(..), connectInfo)
9+
import Common (TestEnv(..))
1010
import ExNumDumpster
1111
import ExUsers
1212
import ExMessages
1313

1414
testEnv :: TestEnv
1515
testEnv = TestEnv {
16-
connectInfo = ConnectInfo {
16+
envConnectInfo = ConnectInfo {
1717
connectHost = "localhost"
1818
, connectPort = 5432
19-
, connectDatabase = "test"
20-
, connectUser = "test"
19+
, connectDatabase = "test_db"
20+
, connectUser = "test_role"
2121
, connectPassword = "TEST"
2222
}
2323
}
@@ -32,7 +32,7 @@ tests = [
3232
main :: IO ()
3333
main = do
3434
mapM_ (`hSetBuffering` LineBuffering) [stdout, stderr]
35-
35+
3636
Counts {cases, tried, errors, failures} <- runTestTT $ TestList $ map ($ testEnv) tests
3737
when (cases /= tried || errors /= 0 || failures /= 0) $ exitFailure
3838

postgresql-simple-bind.cabal

Lines changed: 42 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,37 @@
11
name: postgresql-simple-bind
22
version: 0.1.0.0
33
synopsis: A FFI-like bindings for PostgreSQL stored functions
4-
description: For tutorial see here: https:\/\/github.com\/zohl\/postgresql-simple-bind\/blob\/master\/README.md
4+
description: For tutorial see here: https:\/\/github.com\/zohl\/postgresql-simple-bind\/blob\/master\/README.md
55
license: GPL-3
66
license-file: LICENSE
77
author: Al Zohali
88
maintainer: Al Zohali <zohl@fmap.me>
9-
-- copyright:
9+
-- copyright:
1010
category: Database
1111
build-type: Simple
12-
-- extra-source-files:
12+
-- extra-source-files:
1313
cabal-version: >=1.10
1414

15+
flag dev
16+
description: Turn on development settings.
17+
manual: True
18+
default: False
19+
1520
source-repository head
1621
type: git
1722
location: https://github.com/zohl/postgresql-simple-bind.git
1823

1924
library
20-
build-depends: base >=4.8 && <4.9
21-
, attoparsec
22-
, bytestring
23-
, heredoc
24-
, postgresql-simple
25-
, template-haskell
26-
, text
27-
, time
28-
29-
hs-source-dirs: src
25+
build-depends: base >= 4.8 && < 5.0
26+
, attoparsec >= 0.13.0 && < 0.14
27+
, bytestring >= 0.10.8 && < 0.11
28+
, heredoc >= 0.2.0 && < 0.3
29+
, postgresql-simple >= 0.5.2 && < 0.6
30+
, template-haskell >= 2.11.0 && < 2.12
31+
, text >= 1.2.2 && < 1.3
32+
, time >= 1.6.0 && < 1.7
33+
34+
hs-source-dirs: src
3035
exposed-modules:
3136
Database.PostgreSQL.Simple.Bind
3237
Database.PostgreSQL.Simple.Bind.Types
@@ -35,9 +40,13 @@ library
3540

3641
other-modules:
3742
Database.PostgreSQL.Simple.Bind.Implementation
38-
43+
3944
default-language: Haskell2010
4045

46+
if flag(dev)
47+
ghc-options: -Wall -Werror
48+
else
49+
ghc-options: -O2 -Wall
4150

4251

4352
test-suite tests
@@ -48,17 +57,21 @@ test-suite tests
4857

4958
ghc-options: -Wall
5059

51-
build-depends: base
52-
, bytestring
60+
build-depends: base >= 4.8 && < 5.0
61+
, bytestring >= 0.10.8 && < 0.11
5362
, HUnit
54-
, postgresql-simple
63+
, postgresql-simple >= 0.5.2 && < 0.6
5564
, postgresql-simple-bind
56-
, text
65+
, text >= 1.2.2 && < 1.3
5766

5867
default-language: Haskell2010
5968

69+
if flag(dev)
70+
ghc-options: -Wall -Werror
71+
else
72+
ghc-options: -O2 -Wall
73+
6074

61-
6275
test-suite examples
6376
type: exitcode-stdio-1.0
6477

@@ -67,13 +80,18 @@ test-suite examples
6780

6881
ghc-options: -Wall
6982

70-
build-depends: attoparsec
71-
, base
72-
, bytestring
83+
build-depends: base >= 4.8 && < 5.0
84+
, attoparsec >= 0.13.0 && < 0.14
85+
, bytestring >= 0.10.8 && < 0.11
7386
, case-conversion
7487
, HUnit
75-
, postgresql-simple
88+
, postgresql-simple >= 0.5.2 && < 0.6
7689
, postgresql-simple-bind
77-
, text
90+
, text >= 1.2.2 && < 1.3
7891

7992
default-language: Haskell2010
93+
94+
if flag(dev)
95+
ghc-options: -Wall -Wno-redundant-constraints -Werror
96+
else
97+
ghc-options: -O2 -Wall -Wno-redundant-constraints

src/Database/PostgreSQL/Simple/Bind.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
faciliates and automates bindings creation. This is especially useful in a
1313
design pattern where an application communicates with a database via API hiding
1414
the internal structure of the latter.
15-
15+
1616
-}
1717

1818
module Database.PostgreSQL.Simple.Bind (

0 commit comments

Comments
 (0)