Skip to content

Commit 88e3678

Browse files
authored
Merge pull request #16 from oscoin/build
Public CI
2 parents 3307ec1 + 45e8da4 commit 88e3678

File tree

10 files changed

+108
-96
lines changed

10 files changed

+108
-96
lines changed

.ci/check-haskell-format.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ set -euo pipefail
44

55
shopt -s globstar
66

7-
PATH=$HOME/.local/bin:$PATH
7+
PATH=$HOME/.cabal/bin:$PATH
88

99
base=$(mktemp -d "/tmp/gossip-base.XXXXX")
1010
for f in **/**.hs; do

.ci/ci-cache.sh

Lines changed: 0 additions & 31 deletions
This file was deleted.

.ci/travis-install.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/env bash
2+
3+
set -xeuo pipefail
4+
5+
: ${GHCVER?}
6+
: ${CABALVER?}
7+
8+
travis_retry () {
9+
$* || (sleep 1 && $*) || (sleep 2 && $*)
10+
}
11+
12+
gpg --version
13+
14+
if ! [ -x $HOME/.ghcup/bin/ghcup ]; then
15+
mkdir -p $HOME/.ghcup/bin
16+
cd $HOME/.ghcup/bin
17+
travis_retry curl -LO https://github.com/haskell/ghcup/releases/download/0.0.7/ghcup
18+
travis_retry curl -LO https://github.com/haskell/ghcup/releases/download/0.0.7/ghcup.asc
19+
travis_retry gpg --keyserver keyserver.ubuntu.com --recv-keys 256844E8AE55008AF197C1B7511B62C09D50CD28
20+
gpg --verify ghcup.asc ghcup
21+
chmod +x $HOME/.ghcup/bin/ghcup
22+
fi
23+
24+
export PATH="$HOME/.cabal/bin:$HOME/.ghcup/bin:$PATH"
25+
26+
ghcup set "$GHCVER" || ghcup install "$GHCVER" && ghcup set "$GHCVER"
27+
ghcup install-cabal "$CABALVER"

.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+
dist: xenial
4+
5+
matrix:
6+
include:
7+
- env: GHCVER=8.6.3 CABALVER=2.4.1.0
8+
os: linux
9+
sudo: required
10+
- env: GHCVER=8.4.4 CABALVER=2.4.1.0
11+
os: linux
12+
sudo: required
13+
14+
addons:
15+
apt:
16+
packages:
17+
- libnuma-dev
18+
19+
before_install:
20+
- .ci/travis-install.sh
21+
- export PATH="$HOME/.cabal/bin:$HOME/.ghcup/bin:$PATH"
22+
23+
install:
24+
- cabal v2-update
25+
- cabal v2-install -j --overwrite-policy=always stylish-haskell hlint
26+
27+
script:
28+
- .ci/check-haskell-format.sh
29+
- hlint .
30+
- cabal v2-configure --enable-tests
31+
# wtflol: passing --ghc-options to v2-configure will enable those for all
32+
# local and external packages.
33+
- 'echo -e "package gossip\n ghc-options: -Werror" >> cabal.project.local'
34+
- cat cabal.project.local
35+
- cabal v2-build -j all
36+
- cabal v2-test -j all
37+
38+
cache:
39+
directories:
40+
- $HOME/.cabal/packages
41+
- $HOME/.cabal/store
42+
- $HOME/.cabal/bin
43+
- $HOME/.ghcup
44+
45+
before_cache:
46+
- rm -fv $HOME/.cabal/packages/hackage.haskell.org/build-reports.log
47+
- rm -fv $HOME/.cabal/packages/hackage.haskell.org/00-index*
48+
- rm -fv $HOME/.cabal/packages/hackage.haskell.org/01-index*
49+
- rm -fv $HOME/.cabal/packages/hackage.haskell.org/*.json
50+
- rm -fv $HOME/.cabal/packages/hackage.haskell.org/hackage-security-lock

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
[![Build Status](https://travis-ci.org/oscoin/gossip.svg?branch=master)](https://travis-ci.org/oscoin/gossip)
2+
13
# Gossip
24

35
Experimental Gossip Protocol(s).

cloudbuild.yaml

Lines changed: 0 additions & 58 deletions
This file was deleted.

src/Network/Gossip/IO/Peer.hs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
{-# LANGUAGE CPP #-}
2+
13
-- |
24
-- Copyright : 2018 Monadic GmbH
35
-- License : BSD3
@@ -17,7 +19,9 @@ import Control.Applicative (liftA2)
1719
import Control.Monad.Fail (fail)
1820
import Data.Hashable (Hashable(..), hashUsing)
1921
import Data.Word (Word8)
22+
#if !MIN_VERSION_network(3,0,0)
2023
import GHC.Stack (HasCallStack)
24+
#endif
2125
import Network.Socket
2226
import Network.Socket.Serialise (decodeSockAddr, encodeSockAddr)
2327
import Prelude hiding (fail)
@@ -59,8 +63,10 @@ instance Hashable n => Hashable (Peer n) where
5963
hashAddr s (SockAddrUnix path) =
6064
s `hashWithSalt` (2 :: Word8) `hashWithSalt` path
6165

66+
#if !MIN_VERSION_network(3,0,0)
6267
-- hashAddr s (SockAddrCan x) = canNotSupported
6368
hashAddr _ _ = canNotSupported
69+
#endif
6470

6571
hashPortNum = hashUsing fromEnum
6672

@@ -77,5 +83,7 @@ knownPeer nid host port = Peer nid <$> resolve
7783

7884
--------------------------------------------------------------------------------
7985

86+
#if !MIN_VERSION_network(3,0,0)
8087
canNotSupported :: HasCallStack => a
8188
canNotSupported = error "CAN addresses not supported"
89+
#endif

src/Network/Gossip/IO/Socket.hs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ import Data.Maybe (isJust)
4141
import Data.Text (Text)
4242
import Data.Void
4343
import qualified Focus
44+
#if !MIN_VERSION_network(3,0,0)
4445
import GHC.Stack (HasCallStack)
46+
#endif
4547
import Network.Socket
4648
( AddrInfo(..)
4749
, AddrInfoFlag(..)
@@ -155,7 +157,9 @@ listen eval host port = do
155157
(Sock.addrProtocol addr)
156158
Sock.setSocketOption sock Sock.ReuseAddr 1
157159
Sock.bind sock (Sock.addrAddress addr)
158-
#if MIN_VERSION_network(2,7,0)
160+
#if MIN_VERSION_network(3,0,0)
161+
Sock.setCloseOnExecIfNeeded =<< Sock.fdSocket sock
162+
#elif MIN_VERSION_network(2,7,0)
159163
Sock.setCloseOnExecIfNeeded $ Sock.fdSocket sock
160164
#endif
161165
Sock.listen sock 10
@@ -280,12 +284,16 @@ family :: SockAddr -> Sock.Family
280284
family Sock.SockAddrInet{} = Sock.AF_INET
281285
family Sock.SockAddrInet6{} = Sock.AF_INET6
282286
family Sock.SockAddrUnix{} = Sock.AF_UNIX
287+
#if !MIN_VERSION_network(3,0,0)
283288
--family Sock.SockAddrCan{} = Sock.AF_CAN
284289
family _ = canNotSupported
290+
#endif
285291

286292
withSocket :: SockAddr -> (Socket -> IO a) -> IO a
287293
withSocket addr =
288294
bracket (Sock.socket (family addr) Stream Sock.defaultProtocol) Sock.close
289295

296+
#if !MIN_VERSION_network(3,0,0)
290297
canNotSupported :: HasCallStack => a
291298
canNotSupported = error "CAN addresses not supported"
299+
#endif

src/Network/Socket/Serialise.hs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{-# LANGUAGE CPP #-}
12
module Network.Socket.Serialise
23
( encodeSockAddr
34
, decodeSockAddr
@@ -8,7 +9,9 @@ import Codec.Serialise (decode, encode)
89
import Codec.Serialise.Decoding (Decoder, decodeListLen, decodeWord)
910
import Codec.Serialise.Encoding (Encoding, encodeListLen, encodeWord)
1011
import Control.Applicative (liftA2)
12+
#if !MIN_VERSION_network(3,0,0)
1113
import GHC.Stack (HasCallStack)
14+
#endif
1215
import Network.Socket (SockAddr(..))
1316
import qualified Network.Socket as Sock
1417

@@ -34,8 +37,10 @@ encodeSockAddr = \case
3437
<> encodeWord 2
3538
<> encode path
3639

40+
#if !MIN_VERSION_network(3,0,0)
3741
-- SockAddrCan{} ->
3842
_ -> canNotSupported
43+
#endif
3944
where
4045
encodePort = encode . fromEnum
4146
encodeHost = encode . Sock.hostAddressToTuple
@@ -52,14 +57,15 @@ decodeSockAddr = do
5257
<*> decodeHost6
5358
<*> decode
5459
(2, 2) -> SockAddrUnix <$> decode
55-
_ -> fail canNotSupported
60+
_ -> fail "Network.Socket.Serialise: Invalid wire tagging"
5661
where
5762
decodePort = toEnum <$> decode
5863
decodeHost = Sock.tupleToHostAddress <$> decode
5964
decodeHost6 = Sock.tupleToHostAddress6 <$> decode
6065

6166
--------------------------------------------------------------------------------
6267

68+
#if !MIN_VERSION_network(3,0,0)
6369
canNotSupported :: HasCallStack => a
6470
canNotSupported = error "CAN addresses not supported"
65-
71+
#endif

stack.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
resolver: lts-12.17
1+
resolver: lts-13.6
22
packages:
33
- .
44
extra-deps:
5-
- hedgehog-quickcheck-0.1
6-
- serialise-0.2.1.0
5+
- focus-0.1.5.2@sha256:fc5c76a5be3a9a1c456106d6f389939299c7e05a1a24938b909f043e36a3e37b
6+
- stm-containers-0.2.16@sha256:e98efa8dcf0045ea8a78a04b4e2763cf2d8bc33aad0750e2f30a67f8f4e933b1

0 commit comments

Comments
 (0)