Skip to content

Commit

Permalink
Merge branch 'master' into #118-handle-ECONNRESET
Browse files Browse the repository at this point in the history
  • Loading branch information
aantron committed Nov 12, 2023
2 parents e6bdf76 + 78cf84a commit 7df24a2
Show file tree
Hide file tree
Showing 329 changed files with 14,390 additions and 6,024 deletions.
112 changes: 88 additions & 24 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,20 @@ jobs:
matrix:
os:
- ubuntu-latest
- macos-latest
# - windows-latest
# Blocked until we no longer require libev; Dream still works on
# Windows, but testing it is awkward at the moment.
ocaml:
- 5.0.x
- 4.14.x
- 4.13.x
- 4.12.x
- 4.11.x
- 4.10.x
- 4.09.x
- 4.08.x
include:
- os: ubuntu-latest
ocaml: 4.08.x
- os: ubuntu-latest
ocaml: 4.09.x
- os: ubuntu-latest
ocaml: 4.10.x
- os: ubuntu-latest
ocaml: 4.11.x
- os: macos-latest
ocaml: 4.12.x
- os: windows-latest
ocaml: 4.14.x

runs-on: ${{matrix.os}}
steps:
Expand All @@ -31,27 +30,66 @@ jobs:
submodules: recursive

- uses: avsm/setup-ocaml@v2
if: runner.os != 'Windows'
with:
ocaml-compiler: ${{matrix.ocaml}}

- uses: avsm/setup-ocaml@v2
if: runner.os == 'Windows'
with:
ocaml-compiler: ${{matrix.ocaml}}
opam-repositories: |
opam-repository-mingw: https://github.com/ocaml-opam/opam-repository-mingw.git#sunset
default: https://github.com/ocaml/opam-repository.git
- run: opam depext --yes conf-sqlite3
- run: opam depext --yes conf-postgresql
- run: opam depext --yes conf-libev
- run: opam install --yes --deps-only --with-test .
- run: opam exec -- dune runtest
- run: |
if: runner.os != 'Windows'

# The tests require ppx_expect. The latest versions of it introduced changes
# in the formatting of the output, and also require OCaml >= 4.10, which
# makes testing on < 4.10 awkward. So, we skip tests on < 4.10.
- shell: bash
run: |
set -e
set -x
EXAMPLES=$(find example -maxdepth 1 -type d -not -name "m-mirage*"| grep -v "^example/0" | grep -v "^example$" | sort)
shopt -s nullglob
WITH_TEST=--with-test
case ${{matrix.ocaml}} in
4.09.x) WITH_TEST=;;
4.08.x) WITH_TEST=;;
esac
# Tests on Windows are disabled because of a difference in ppx_expect
# output. See https://github.com/aantron/dream/pull/282.
case ${{runner.os}} in
Windows) WITH_TEST=;;
esac
OPAM=$(which opam || true)
if [ -z "$OPAM" ]
then
OPAM=D:\\cygwin\\wrapperbin\\opam.cmd
fi
for EXAMPLE in $EXAMPLES
do
FILE=$(ls $EXAMPLE/*.ml $EXAMPLE/*.re $EXAMPLE/server/*.ml $EXAMPLE/server/*.re)
EXE=$(echo $FILE | sed 's/\..*$/.exe/g')
echo dune build $EXE
opam exec -- dune build $EXE
done
$OPAM install --yes --deps-only $WITH_TEST ./dream-pure.opam ./dream-httpaf.opam ./dream.opam
if [ ! -z "$WITH_TEST" ]
then
$OPAM exec -- dune runtest
EXAMPLES=$(find example -maxdepth 1 -type d -not -name "w-mirage*" -not -name "r-tyxml" | grep -v "^example/0" | grep -v "^example$" | sort)
shopt -s nullglob
for EXAMPLE in $EXAMPLES
do
FILE=$(ls $EXAMPLE/*.ml $EXAMPLE/*.re $EXAMPLE/server/*.ml $EXAMPLE/server/*.re)
EXE=$(echo $FILE | sed 's/\..*$/.exe/g')
echo dune build $EXE
$OPAM exec -- dune build $EXE
done
fi
quickstart:
strategy:
Expand All @@ -77,3 +115,29 @@ jobs:
else
exit 1
fi
mirage:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- run: mkdir ../repo-copy
- run: cp -r * ../repo-copy/
- uses: avsm/setup-ocaml@v2
with:
ocaml-compiler: 4.14.x
- run: opam install --yes --deps-only ./dream-pure.opam ./dream-httpaf.opam ./dream.opam ./dream-mirage.opam
- run: opam install --yes mirage mirage-clock-unix
- run: cd example/w-mirage && mv config.ml config.ml.backup
- run: cd example/w-mirage && sed -e 's/package "dream-mirage"//' < config.ml.backup > config.ml
- run: cd example/w-mirage && opam exec -- mirage configure -t unix
- run: cd example/w-mirage && opam exec -- make depends
- run: cd example/w-mirage && ls duniverse
- run: cp -r ../repo-copy example/w-mirage/duniverse/dream
- run: cd example/w-mirage/duniverse && rm -rf ocaml-cstruct logs ke fmt lwt bytes seq mirage-flow sexplib0 ptime tls domain-name ocaml-ipaddr mirage-clock ocplib-endian
- run: cd example/w-mirage && mv config.ml.backup config.ml
- run: cd example/w-mirage && sed -e 's/(libraries/(libraries dream-mirage/' < dune.build > dune.build.2
- run: cd example/w-mirage && mv dune.build.2 dune.build
- run: cd example/w-mirage && opam exec -- dune build
- run: file example/w-mirage/_build/default/main.exe
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,15 @@ _esy/
esy.lock

# Release script
dream-*
dream-*.gz
dream-*/

# Bisect_ppx
_coverage/

# Humans
scratch/

# Editors
.vscode/
*.swp
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@
url = https://github.com/aantron/ocaml-h2.git
[submodule "src/vendor/paf"]
path = src/vendor/paf
url = https://github.com/dinosaure/paf-le-chien.git
url = https://github.com/aantron/paf-le-chien.git
branch = dream
9 changes: 2 additions & 7 deletions .ocamlformat
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
version = 0.19.0
version = 0.25.1
profile = conventional

leading-nested-match-parens = false
align-constructors-decl = true
align-variants-decl = true
space-around-variants = false
space-around-arrays = false
space-around-lists = false
space-around-records = false
break-before-in = auto
break-infix = fit-or-vertical
break-separators = after
space-around-records = true
break-cases = all
break-cases = fit-or-vertical
cases-exp-indent = 2
exp-grouping = preserve
nested-match = align
if-then-else = fit-or-vertical
let-and = sparse
type-decl = sparse
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2021, Anton Bachin
Copyright (c) 2021-2023, Anton Bachin

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
48 changes: 36 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,31 +1,40 @@
PACKAGES := dream-pure,dream-httpaf,dream

.PHONY : build
build :
@dune build -p dream --no-print-directory @install
@dune build --only-packages $(PACKAGES) --no-print-directory @install

.PHONY : watch
watch :
@dune build -p dream --no-print-directory -w
@dune build --only-packages $(PACKAGES) --no-print-directory @install -w

.PHONY : deps
deps :
opam install --deps-only --with-test ./dream-pure.opam ./dream-httpaf.opam ./dream.opam

TEST ?= test
ROOT := $(shell [ -f ../dune-workspace ] && echo .. || echo .)

.PHONY : test
test :
@find . -name '*.coverage' | xargs rm -f
@find $(ROOT) -name '*.coverage' | xargs rm -f
@dune build --no-print-directory \
--instrument-with bisect_ppx --force @test/runtest
--instrument-with bisect_ppx --force @$(TEST)/runtest
@bisect-ppx-report html
@bisect-ppx-report summary
@echo See _coverage/index.html

.PHONY : test-watch
test-watch :
@dune build --no-print-directory -w --root . @test/runtest
@dune build --no-print-directory -w @$(TEST)/runtest

.PHONY : coverage-serve
coverage-serve :
cd _coverage && dune exec -- serve -p 8082
cd _coverage && dune exec -- dream-serve -p 8082

.PHONY : promote
promote :
dune promote --root .
dune promote
@make --no-print-directory test

.PHONY : docs
Expand Down Expand Up @@ -66,7 +75,7 @@ clean : clean-coverage
dune clean
dune clean --root .
make --no-print-directory -C docs/web clean
rm -rf src/graphiql/node_modules dream-* _release
rm -rf src/graphiql/node_modules

.PHONY : test-ocamlformat
test-ocamlformat :
Expand All @@ -92,21 +101,25 @@ todo-all :

VERSION := $(shell git describe --abbrev=0)
RELEASE := dream-$(VERSION)
FILES := src dream.opam dune-project LICENSE.md README.md
FILES := \
src dream.opam dream-httpaf.opam dream-pure.opam dream-mirage.opam \
dune-project LICENSE.md README.md

.PHONY : release
release : clean
rm -rf $(RELEASE) $(RELEASE).tar $(RELEASE).tar.gz _release
mkdir $(RELEASE)
mkdir -p $(RELEASE)
cp -r $(FILES) $(RELEASE)
rm -rf $(RELEASE)/src/vendor/gluten/.github
rm -rf $(RELEASE)/src/vendor/gluten/async
rm -rf $(RELEASE)/src/vendor/gluten/eio
rm -rf $(RELEASE)/src/vendor/gluten/mirage
rm -rf $(RELEASE)/src/vendor/gluten/nix
rm -rf $(RELEASE)/src/vendor/httpaf/.github
rm -rf $(RELEASE)/src/vendor/httpaf/async
rm -rf $(RELEASE)/src/vendor/httpaf/benchmarks
rm -rf $(RELEASE)/src/vendor/httpaf/certificates
rm -rf $(RELEASE)/src/vendor/httpaf/eio
rm -rf $(RELEASE)/src/vendor/httpaf/examples
rm -rf $(RELEASE)/src/vendor/httpaf/images
rm -rf $(RELEASE)/src/vendor/httpaf/lib_test
Expand All @@ -115,6 +128,7 @@ release : clean
rm -rf $(RELEASE)/src/vendor/h2/.github
rm -rf $(RELEASE)/src/vendor/h2/async
rm -rf $(RELEASE)/src/vendor/h2/certificates
rm -rf $(RELEASE)/src/vendor/h2/eio
rm -rf $(RELEASE)/src/vendor/h2/examples
rm -rf $(RELEASE)/src/vendor/h2/lib_test
rm -rf $(RELEASE)/src/vendor/h2/mirage
Expand All @@ -123,20 +137,30 @@ release : clean
rm -rf $(RELEASE)/src/vendor/h2/vegeta-plot.png
rm -rf $(RELEASE)/src/vendor/websocketaf/.github
rm -rf $(RELEASE)/src/vendor/websocketaf/async
rm -rf $(RELEASE)/src/vendor/websocketaf/eio
rm -rf $(RELEASE)/src/vendor/websocketaf/examples
rm -rf $(RELEASE)/src/vendor/websocketaf/lib_test
rm -rf $(RELEASE)/src/vendor/websocketaf/mirage
rm -rf $(RELEASE)/src/vendor/websocketaf/nix
rm -rf $(RELEASE)/src/vendor/paf
tar cf $(RELEASE).tar $(RELEASE)
ls -l $(RELEASE).tar
gzip -9 $(RELEASE).tar
mkdir -p _release
cp $(RELEASE).tar.gz _release
(cd _release && tar xf $(RELEASE).tar.gz)
opam remove -y dream-pure dream-httpaf dream gluten httpaf h2 websocketaf paf
opam pin remove -y dream-pure dream-httpaf dream
opam pin add -y --no-action dream-pure _release/$(RELEASE) --kind=path
opam pin add -y --no-action dream-httpaf _release/$(RELEASE) --kind=path
opam pin add -y --no-action dream _release/$(RELEASE) --kind=path
opam reinstall -y --verbose dream
@echo Run make release-finish to complete after killing the server
cd example/1-hello && dune exec --root . ./hello.exe || true
opam remove -y dream
opam pin remove -y dream

.PHONY : release-finish
release-finish :
opam remove -y dream-pure dream-httpaf dream
opam pin remove -y dream-pure dream-httpaf dream
md5sum $(RELEASE).tar.gz
ls -l $(RELEASE).tar.gz
Loading

0 comments on commit 7df24a2

Please sign in to comment.