Skip to content

Commit

Permalink
Merge branch 'master' into thread-cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
jaspervdj committed Dec 22, 2023
2 parents 124c4e9 + 15bb687 commit 300d512
Show file tree
Hide file tree
Showing 5 changed files with 113 additions and 67 deletions.
40 changes: 0 additions & 40 deletions .circleci/config.yml

This file was deleted.

82 changes: 82 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: "build & test"
on:
push:
pull_request:
branches: [master]

jobs:
build:
name: GHC ${{ matrix.ghc-version }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
ghc-version: ['9.8', '9.6', '9.4', '9.2', '9.0']

include:
- os: windows-latest
ghc-version: '9.8'
- os: macos-latest
ghc-version: '9.8'

steps:
- uses: actions/checkout@v4

- name: Set up GHC ${{ matrix.ghc-version }}
uses: haskell-actions/setup@v2
id: setup
with:
ghc-version: ${{ matrix.ghc-version }}
# Defaults, added for clarity:
cabal-version: 'latest'
cabal-update: true

- name: Configure the build
run: |
cabal configure --enable-tests --enable-benchmarks --disable-documentation
cabal build all --dry-run
# The last step generates dist-newstyle/cache/plan.json for the cache key.

- name: Restore cached dependencies
uses: actions/cache/restore@v3
id: cache
env:
key: ${{ runner.os }}-ghc-${{ steps.setup.outputs.ghc-version }}-cabal-${{ steps.setup.outputs.cabal-version }}
with:
path: ${{ steps.setup.outputs.cabal-store }}
key: ${{ env.key }}-plan-${{ hashFiles('**/plan.json') }}
restore-keys: ${{ env.key }}-

- name: Install dependencies
# If we had an exact cache hit, the dependencies will be up to date.
if: steps.cache.outputs.cache-hit != 'true'
run: cabal build all --only-dependencies

# Cache dependencies already here, so that we do not have to rebuild them should the subsequent steps fail.
- name: Save cached dependencies
uses: actions/cache/save@v3
# If we had an exact cache hit, trying to save the cache would error because of key clash.
if: steps.cache.outputs.cache-hit != 'true'
with:
path: ${{ steps.setup.outputs.cabal-store }}
key: ${{ steps.cache.outputs.cache-primary-key }}

- name: Build
run: cabal build all

- name: Run tests
run: cabal test all

- name: Build documentation
run: cabal haddock all

- name: Install virtualenv
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get install --yes virtualenv python2.7-dev
pip install virtualenv
- name: Run autobahn tests
if: matrix.os == 'ubuntu-latest'
run: bash tests/autobahn/autobahn.sh
5 changes: 5 additions & 0 deletions src/Network/WebSockets/Connection.hs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ module Network.WebSockets.Connection
, sendClose
, sendCloseCode
, sendPing
, sendPong

, withPingThread
, forkPingThread
Expand Down Expand Up @@ -388,6 +389,10 @@ sendCloseCode conn code =
sendPing :: WebSocketsData a => Connection -> a -> IO ()
sendPing conn = send conn . ControlMessage . Ping . toLazyByteString

--------------------------------------------------------------------------------
-- | Send a pong
sendPong :: WebSocketsData a => Connection -> a -> IO ()
sendPong conn = send conn . ControlMessage . Pong . toLazyByteString

--------------------------------------------------------------------------------
-- | Forks a ping thread, sending a ping message every @n@ seconds over the
Expand Down
2 changes: 1 addition & 1 deletion src/Network/WebSockets/Stream.hs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ data Stream = Stream
-- writing from the stream will be thread-safe, i.e. this function will create
-- a receive and write lock to be used internally.
--
-- - Reading from or writing or to a closed 'Stream' will always throw an
-- - Reading from or writing to a closed 'Stream' will always throw an
-- exception, even if the underlying "receive" and "send" functions do not
-- (we do the bookkeeping).
--
Expand Down
51 changes: 25 additions & 26 deletions websockets.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,13 @@ Library
base64-bytestring >= 0.1 && < 1.3,
binary >= 0.8.1 && < 0.11,
bytestring >= 0.9 && < 0.12,
bytestring-builder < 0.11,
case-insensitive >= 0.3 && < 1.3,
containers >= 0.3 && < 0.7,
network >= 2.3 && < 3.2,
random >= 1.0 && < 1.3,
random >= 1.0.1 && < 1.3,
SHA >= 1.5 && < 1.7,
streaming-commons >= 0.1 && < 0.3,
text >= 0.10 && < 2.1,
text >= 0.10 && < 2.2,
entropy >= 0.2.1 && < 0.5

Test-suite websockets-tests
Expand Down Expand Up @@ -150,17 +149,16 @@ Test-suite websockets-tests
base64-bytestring >= 0.1 && < 1.3,
binary >= 0.8.1 && < 0.11,
bytestring >= 0.9 && < 0.12,
bytestring-builder < 0.11,
case-insensitive >= 0.3 && < 1.3,
containers >= 0.3 && < 0.7,
network >= 2.3 && < 3.2,
random >= 1.0 && < 1.3,
SHA >= 1.5 && < 1.7,
streaming-commons >= 0.1 && < 0.3,
text >= 0.10 && < 2.1,
text >= 0.10 && < 2.2,
entropy >= 0.2.1 && < 0.5

Executable websockets-example
Executable websockets-server-example
If !flag(Example)
Buildable: False

Expand All @@ -170,22 +168,25 @@ Executable websockets-example
Default-language: Haskell2010

Build-depends:
base,
websockets,
-- Copied from regular dependencies...
async >= 2.2 && < 2.3,
attoparsec >= 0.10 && < 0.15,
base >= 4 && < 5,
base64-bytestring >= 0.1 && < 1.3,
binary >= 0.8.1 && < 0.11,
bytestring >= 0.9 && < 0.12,
bytestring-builder < 0.11,
case-insensitive >= 0.3 && < 1.3,
containers >= 0.3 && < 0.7,
network >= 2.3 && < 3.2,
random >= 1.0 && < 1.3,
SHA >= 1.5 && < 1.7,
text >= 0.10 && < 2.1,
entropy >= 0.2.1 && < 0.5
text

Executable websockets-client-example
If !flag(Example)
Buildable: False

Hs-source-dirs: example
Main-is: client.hs
Ghc-options: -Wall
Default-language: Haskell2010

Build-depends:
base,
websockets,
text,
network,
mtl

Executable websockets-autobahn
If !flag(Example)
Expand All @@ -208,13 +209,12 @@ Executable websockets-autobahn
base64-bytestring >= 0.1 && < 1.3,
binary >= 0.8.1 && < 0.11,
bytestring >= 0.9 && < 0.12,
bytestring-builder < 0.11,
case-insensitive >= 0.3 && < 1.3,
containers >= 0.3 && < 0.7,
network >= 2.3 && < 3.2,
random >= 1.0 && < 1.3,
SHA >= 1.5 && < 1.7,
text >= 0.10 && < 2.1,
text >= 0.10 && < 2.2,
entropy >= 0.2.1 && < 0.5

Benchmark bench-mask
Expand All @@ -236,13 +236,12 @@ Benchmark bench-mask
base64-bytestring >= 0.1 && < 1.3,
binary >= 0.8.1 && < 0.11,
bytestring >= 0.9 && < 0.12,
bytestring-builder < 0.11,
case-insensitive >= 0.3 && < 1.3,
containers >= 0.3 && < 0.7,
network >= 2.3 && < 3.2,
random >= 1.0 && < 1.3,
SHA >= 1.5 && < 1.7,
text >= 0.10 && < 2.1,
text >= 0.10 && < 2.2,
entropy >= 0.2.1 && < 0.5

Executable websockets-website
Expand All @@ -251,7 +250,7 @@ Executable websockets-website

Main-is: site.hs
Hs-source-dirs: web

Default-language: Haskell2010
Build-depends:
base >= 4 && < 5,
filepath >= 1.4 && < 1.5,
Expand Down

0 comments on commit 300d512

Please sign in to comment.