Skip to content

Commit

Permalink
Merge branch 'master' into patch-2
Browse files Browse the repository at this point in the history
  • Loading branch information
jaspervdj committed Dec 21, 2023
2 parents 7ac04e7 + 6e9fb1a commit ed8e311
Show file tree
Hide file tree
Showing 11 changed files with 131 additions and 91 deletions.
35 changes: 0 additions & 35 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
3 changes: 3 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# CHANGELOG

- 0.12.7.3 (2021-10-26)
* Bump `attoparsec` dependency upper bound to 0.15

- 0.12.7.2 (2020-12-07)
* Bump `QuickCheck` dependency upper bound to 2.15
* Bump `base64-bytestring` dependency upper bound to 1.3
Expand Down
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
9 changes: 7 additions & 2 deletions stack.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
resolver: lts-15.6
resolver: lts-18.14
save-hackage-creds: false
flags:
websockets:
example: true
extra-deps: []
website: true
extra-deps:
- 'hakyll-4.15.1.0'
nix:
packages:
- 'zlib'
17 changes: 12 additions & 5 deletions stack.yaml.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,17 @@
# For more information, please see the documentation at:
# https://docs.haskellstack.org/en/stable/lock_files

packages: []
packages:
- completed:
hackage: hakyll-4.15.1.0@sha256:df90fdb1e7e09e90557ad23a6d402ce042f820f690595e7e73db82220edcadcf,9924
pantry-tree:
size: 8860
sha256: 474bd1e22b8eb6c7ad8e397c1c6741204fff4b30ebc5d9d47576c43820d17e13
original:
hackage: hakyll-4.15.1.0
snapshots:
- completed:
size: 491387
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/15/6.yaml
sha256: 8d81505a6de861e167a58534ab62330afb75bfa108735c7db1204f7ef2a39d79
original: lts-15.6
size: 586069
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/18/14.yaml
sha256: 87842ecbaa8ca9cee59a7e6be52369dbed82ed075cb4e0d152614a627e8fd488
original: lts-18.14
4 changes: 3 additions & 1 deletion tests/autobahn/autobahn.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ else
fi

echo "Launching websockets server in background..."
(stack exec websockets-autobahn) & WEBSOCKETS_AUTOBAHN_PID="$!"
(cabal run websockets-autobahn -f Example) & WEBSOCKETS_AUTOBAHN_PID="$!"

sleep 10

echo "Getting config..."
cp tests/autobahn/fuzzingclient.json .
Expand Down
20 changes: 0 additions & 20 deletions web/site.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,6 @@ module Main where
--------------------------------------------------------------------------------
import Hakyll
import System.FilePath (joinPath, splitFileName, splitPath, (</>))
import System.Process (rawSystem)


--------------------------------------------------------------------------------
makeHaddock :: IO ()
makeHaddock = do
putStrLn "Generating documentation..."
sh "cabal" ["configure"]
sh "cabal" ["haddock", "--hyperlink-source"]
where
-- Ignore exit code
sh c as = rawSystem c as >>= \_ -> return ()


--------------------------------------------------------------------------------
Expand All @@ -34,8 +22,6 @@ pageCompiler =
--------------------------------------------------------------------------------
main :: IO ()
main = hakyllWith config $ do
preprocess $ makeHaddock

match "README.md" $ do
route $ constRoute "index.html"
compile $ pageCompiler >>= relativizeUrls
Expand All @@ -52,12 +38,6 @@ main = hakyllWith config $ do
route $ idRoute
compile copyFileCompiler

match "dist/doc/html/websockets/*" $ do
route $ customRoute $ \ident ->
let (_dir, file) = splitFileName (toFilePath ident) in
"reference" </> file
compile copyFileCompiler

match "web/css/*" $ do
route dropWebRoute
compile compressCssCompiler
Expand Down
15 changes: 1 addition & 14 deletions web/templates/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

<title>websockets: A Haskell WebSocket library</title>

<!-- Stylesheets. -->
Expand All @@ -16,7 +15,7 @@
<div id="navigation">
<a href="/index.html">Home</a>
<a href="/example/server.html">Example</a>
<a href="/reference/">Reference</a>
<a href="https://hackage.haskell.org/package/websockets">Reference</a>
<a href="http://github.com/jaspervdj/websockets">Source</a>
</div>

Expand All @@ -30,17 +29,5 @@
Site proudly generated by
<a href="http://jaspervdj.be/hakyll">Hakyll</a>.
</div>

<!-- Google Analytics -->
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-11993001-1");
pageTracker._trackPageview();
} catch(err) {}
</script>
</body>
</html>
30 changes: 17 additions & 13 deletions websockets.cabal
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Name: websockets
Version: 0.12.7.2
Version: 0.12.7.3

Synopsis:
A sensible and clean way to write WebSocket-capable servers in Haskell.
Expand Down Expand Up @@ -52,6 +52,11 @@ Flag Example
Default: False
Manual: True

Flag Website
Description: Build the website
Default: False
Manual: True

Library
Hs-source-dirs: src
Ghc-options: -Wall
Expand Down Expand Up @@ -81,7 +86,7 @@ Library

Build-depends:
async >= 2.2 && < 2.3,
attoparsec >= 0.10 && < 0.14,
attoparsec >= 0.10 && < 0.15,
base >= 4.8 && < 5,
base64-bytestring >= 0.1 && < 1.3,
binary >= 0.8.1 && < 0.11,
Expand All @@ -90,10 +95,10 @@ Library
clock >= 0.8 && < 0.9,
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 && < 1.3,
text >= 0.10 && < 2.2,
entropy >= 0.2.1 && < 0.5

Test-suite websockets-tests
Expand Down Expand Up @@ -140,7 +145,7 @@ Test-suite websockets-tests
test-framework-quickcheck2 >= 0.2 && < 0.4,
-- Copied from regular dependencies...
async >= 2.2 && < 2.3,
attoparsec >= 0.10 && < 0.14,
attoparsec >= 0.10 && < 0.15,
base >= 4 && < 5,
base64-bytestring >= 0.1 && < 1.3,
binary >= 0.8.1 && < 0.11,
Expand All @@ -152,7 +157,7 @@ Test-suite websockets-tests
random >= 1.0 && < 1.3,
SHA >= 1.5 && < 1.7,
streaming-commons >= 0.1 && < 0.3,
text >= 0.10 && < 1.3,
text >= 0.10 && < 2.2,
entropy >= 0.2.1 && < 0.5

Executable websockets-example
Expand All @@ -168,7 +173,7 @@ Executable websockets-example
websockets,
-- Copied from regular dependencies...
async >= 2.2 && < 2.3,
attoparsec >= 0.10 && < 0.14,
attoparsec >= 0.10 && < 0.15,
base >= 4 && < 5,
base64-bytestring >= 0.1 && < 1.3,
binary >= 0.8.1 && < 0.11,
Expand All @@ -179,7 +184,7 @@ Executable websockets-example
network >= 2.3 && < 3.2,
random >= 1.0 && < 1.3,
SHA >= 1.5 && < 1.7,
text >= 0.10 && < 1.3,
text >= 0.10 && < 2.2,
entropy >= 0.2.1 && < 0.5

Executable websockets-autobahn
Expand All @@ -198,7 +203,7 @@ Executable websockets-autobahn
websockets,
-- Copied from regular dependencies...
async >= 2.2 && < 2.3,
attoparsec >= 0.10 && < 0.14,
attoparsec >= 0.10 && < 0.15,
base >= 4 && < 5,
base64-bytestring >= 0.1 && < 1.3,
binary >= 0.8.1 && < 0.11,
Expand All @@ -209,7 +214,7 @@ Executable websockets-autobahn
network >= 2.3 && < 3.2,
random >= 1.0 && < 1.3,
SHA >= 1.5 && < 1.7,
text >= 0.10 && < 1.3,
text >= 0.10 && < 2.2,
entropy >= 0.2.1 && < 0.5

Benchmark bench-mask
Expand All @@ -226,7 +231,7 @@ Benchmark bench-mask
criterion,
-- Copied from regular dependencies...
async >= 2.2 && < 2.3,
attoparsec >= 0.10 && < 0.14,
attoparsec >= 0.10 && < 0.15,
base >= 4 && < 5,
base64-bytestring >= 0.1 && < 1.3,
binary >= 0.8.1 && < 0.11,
Expand All @@ -237,6 +242,5 @@ Benchmark bench-mask
network >= 2.3 && < 3.2,
random >= 1.0 && < 1.3,
SHA >= 1.5 && < 1.7,
text >= 0.10 && < 1.3,
text >= 0.10 && < 2.2,
entropy >= 0.2.1 && < 0.5

0 comments on commit ed8e311

Please sign in to comment.