Skip to content

Commit

Permalink
Merge pull request #16 from oscoin/build
Browse files Browse the repository at this point in the history
Public CI
  • Loading branch information
kim authored Feb 12, 2019
2 parents 3307ec1 + 45e8da4 commit 88e3678
Show file tree
Hide file tree
Showing 10 changed files with 108 additions and 96 deletions.
2 changes: 1 addition & 1 deletion .ci/check-haskell-format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -euo pipefail

shopt -s globstar

PATH=$HOME/.local/bin:$PATH
PATH=$HOME/.cabal/bin:$PATH

base=$(mktemp -d "/tmp/gossip-base.XXXXX")
for f in **/**.hs; do
Expand Down
31 changes: 0 additions & 31 deletions .ci/ci-cache.sh

This file was deleted.

27 changes: 27 additions & 0 deletions .ci/travis-install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env bash

set -xeuo pipefail

: ${GHCVER?}
: ${CABALVER?}

travis_retry () {
$* || (sleep 1 && $*) || (sleep 2 && $*)
}

gpg --version

if ! [ -x $HOME/.ghcup/bin/ghcup ]; then
mkdir -p $HOME/.ghcup/bin
cd $HOME/.ghcup/bin
travis_retry curl -LO https://github.com/haskell/ghcup/releases/download/0.0.7/ghcup
travis_retry curl -LO https://github.com/haskell/ghcup/releases/download/0.0.7/ghcup.asc
travis_retry gpg --keyserver keyserver.ubuntu.com --recv-keys 256844E8AE55008AF197C1B7511B62C09D50CD28
gpg --verify ghcup.asc ghcup
chmod +x $HOME/.ghcup/bin/ghcup
fi

export PATH="$HOME/.cabal/bin:$HOME/.ghcup/bin:$PATH"

ghcup set "$GHCVER" || ghcup install "$GHCVER" && ghcup set "$GHCVER"
ghcup install-cabal "$CABALVER"
50 changes: 50 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
language: c

dist: xenial

matrix:
include:
- env: GHCVER=8.6.3 CABALVER=2.4.1.0
os: linux
sudo: required
- env: GHCVER=8.4.4 CABALVER=2.4.1.0
os: linux
sudo: required

addons:
apt:
packages:
- libnuma-dev

before_install:
- .ci/travis-install.sh
- export PATH="$HOME/.cabal/bin:$HOME/.ghcup/bin:$PATH"

install:
- cabal v2-update
- cabal v2-install -j --overwrite-policy=always stylish-haskell hlint

script:
- .ci/check-haskell-format.sh
- hlint .
- cabal v2-configure --enable-tests
# wtflol: passing --ghc-options to v2-configure will enable those for all
# local and external packages.
- 'echo -e "package gossip\n ghc-options: -Werror" >> cabal.project.local'
- cat cabal.project.local
- cabal v2-build -j all
- cabal v2-test -j all

cache:
directories:
- $HOME/.cabal/packages
- $HOME/.cabal/store
- $HOME/.cabal/bin
- $HOME/.ghcup

before_cache:
- rm -fv $HOME/.cabal/packages/hackage.haskell.org/build-reports.log
- rm -fv $HOME/.cabal/packages/hackage.haskell.org/00-index*
- rm -fv $HOME/.cabal/packages/hackage.haskell.org/01-index*
- rm -fv $HOME/.cabal/packages/hackage.haskell.org/*.json
- rm -fv $HOME/.cabal/packages/hackage.haskell.org/hackage-security-lock
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
[![Build Status](https://travis-ci.org/oscoin/gossip.svg?branch=master)](https://travis-ci.org/oscoin/gossip)

# Gossip

Experimental Gossip Protocol(s).
Expand Down
58 changes: 0 additions & 58 deletions cloudbuild.yaml

This file was deleted.

8 changes: 8 additions & 0 deletions src/Network/Gossip/IO/Peer.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{-# LANGUAGE CPP #-}

-- |
-- Copyright : 2018 Monadic GmbH
-- License : BSD3
Expand All @@ -17,7 +19,9 @@ import Control.Applicative (liftA2)
import Control.Monad.Fail (fail)
import Data.Hashable (Hashable(..), hashUsing)
import Data.Word (Word8)
#if !MIN_VERSION_network(3,0,0)
import GHC.Stack (HasCallStack)
#endif
import Network.Socket
import Network.Socket.Serialise (decodeSockAddr, encodeSockAddr)
import Prelude hiding (fail)
Expand Down Expand Up @@ -59,8 +63,10 @@ instance Hashable n => Hashable (Peer n) where
hashAddr s (SockAddrUnix path) =
s `hashWithSalt` (2 :: Word8) `hashWithSalt` path

#if !MIN_VERSION_network(3,0,0)
-- hashAddr s (SockAddrCan x) = canNotSupported
hashAddr _ _ = canNotSupported
#endif

hashPortNum = hashUsing fromEnum

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

--------------------------------------------------------------------------------

#if !MIN_VERSION_network(3,0,0)
canNotSupported :: HasCallStack => a
canNotSupported = error "CAN addresses not supported"
#endif
10 changes: 9 additions & 1 deletion src/Network/Gossip/IO/Socket.hs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ import Data.Maybe (isJust)
import Data.Text (Text)
import Data.Void
import qualified Focus
#if !MIN_VERSION_network(3,0,0)
import GHC.Stack (HasCallStack)
#endif
import Network.Socket
( AddrInfo(..)
, AddrInfoFlag(..)
Expand Down Expand Up @@ -155,7 +157,9 @@ listen eval host port = do
(Sock.addrProtocol addr)
Sock.setSocketOption sock Sock.ReuseAddr 1
Sock.bind sock (Sock.addrAddress addr)
#if MIN_VERSION_network(2,7,0)
#if MIN_VERSION_network(3,0,0)
Sock.setCloseOnExecIfNeeded =<< Sock.fdSocket sock
#elif MIN_VERSION_network(2,7,0)
Sock.setCloseOnExecIfNeeded $ Sock.fdSocket sock
#endif
Sock.listen sock 10
Expand Down Expand Up @@ -280,12 +284,16 @@ family :: SockAddr -> Sock.Family
family Sock.SockAddrInet{} = Sock.AF_INET
family Sock.SockAddrInet6{} = Sock.AF_INET6
family Sock.SockAddrUnix{} = Sock.AF_UNIX
#if !MIN_VERSION_network(3,0,0)
--family Sock.SockAddrCan{} = Sock.AF_CAN
family _ = canNotSupported
#endif

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

#if !MIN_VERSION_network(3,0,0)
canNotSupported :: HasCallStack => a
canNotSupported = error "CAN addresses not supported"
#endif
10 changes: 8 additions & 2 deletions src/Network/Socket/Serialise.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{-# LANGUAGE CPP #-}
module Network.Socket.Serialise
( encodeSockAddr
, decodeSockAddr
Expand All @@ -8,7 +9,9 @@ import Codec.Serialise (decode, encode)
import Codec.Serialise.Decoding (Decoder, decodeListLen, decodeWord)
import Codec.Serialise.Encoding (Encoding, encodeListLen, encodeWord)
import Control.Applicative (liftA2)
#if !MIN_VERSION_network(3,0,0)
import GHC.Stack (HasCallStack)
#endif
import Network.Socket (SockAddr(..))
import qualified Network.Socket as Sock

Expand All @@ -34,8 +37,10 @@ encodeSockAddr = \case
<> encodeWord 2
<> encode path

#if !MIN_VERSION_network(3,0,0)
-- SockAddrCan{} ->
_ -> canNotSupported
#endif
where
encodePort = encode . fromEnum
encodeHost = encode . Sock.hostAddressToTuple
Expand All @@ -52,14 +57,15 @@ decodeSockAddr = do
<*> decodeHost6
<*> decode
(2, 2) -> SockAddrUnix <$> decode
_ -> fail canNotSupported
_ -> fail "Network.Socket.Serialise: Invalid wire tagging"
where
decodePort = toEnum <$> decode
decodeHost = Sock.tupleToHostAddress <$> decode
decodeHost6 = Sock.tupleToHostAddress6 <$> decode

--------------------------------------------------------------------------------

#if !MIN_VERSION_network(3,0,0)
canNotSupported :: HasCallStack => a
canNotSupported = error "CAN addresses not supported"

#endif
6 changes: 3 additions & 3 deletions stack.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
resolver: lts-12.17
resolver: lts-13.6
packages:
- .
extra-deps:
- hedgehog-quickcheck-0.1
- serialise-0.2.1.0
- focus-0.1.5.2@sha256:fc5c76a5be3a9a1c456106d6f389939299c7e05a1a24938b909f043e36a3e37b
- stm-containers-0.2.16@sha256:e98efa8dcf0045ea8a78a04b4e2763cf2d8bc33aad0750e2f30a67f8f4e933b1

0 comments on commit 88e3678

Please sign in to comment.