CI: try dune-cache (#353) #859
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: test | |
on: [push, pull_request] | |
jobs: | |
test: | |
strategy: | |
fail-fast: false | |
matrix: | |
os: | |
# Until https://github.com/ocaml/setup-ocaml/issues/872. | |
# When fixing, search for other instances of this string in this file. | |
- ubuntu-22.04 | |
ocaml: | |
- 5.2.x | |
- 4.14.x | |
include: | |
- os: macos-latest | |
ocaml: 4.14.x | |
- os: windows-latest | |
ocaml: 4.14.x | |
runs-on: ${{matrix.os}} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
- uses: ocaml/setup-ocaml@v3 | |
with: | |
ocaml-compiler: ${{matrix.ocaml}} | |
dune-cache: true | |
# For Caqti PostgreSQL examples. opam does actually install PostgreSQL for | |
# us. However, Homebrew doesn't link it by default, so we have to install | |
# and link it manually. | |
- run: brew install postgresql@15 && brew link --overwrite postgresql@15 | |
if: runner.os == 'macOS' | |
# Workaround https://github.com/savonet/ocaml-ssl/issues/155 and/or | |
# https://github.com/ocaml/setup-ocaml/issues/856. | |
- run: opam pin add ssl 0.6.0 --no-action | |
if: runner.os == 'Windows' | |
- run: opam exec -- make deps | |
- run: opam exec -- make | |
# Tests on Windows are disabled because of a difference in ppx_expect | |
# output. See https://github.com/aantron/dream/pull/282. This difference | |
# remains as of ppx_expect 0.16. | |
- run: opam exec -- make test | |
if: runner.os != 'Windows' | |
- run: opam lint --recursive example | |
- name: Build examples | |
if: runner.os != 'Windows' | |
run: | | |
set -e | |
set -x | |
EXCLUDED_EXAMPLES='w-mirage*|r-tyxml|w-dream-html' | |
EXAMPLES=$(find example -maxdepth 1 -type d | grep -Ev $EXCLUDED_EXAMPLES | grep -v "^example/0" | grep -v "^example$" | sort) | |
shopt -s nullglob | |
for EXAMPLE in $EXAMPLES | |
do | |
FILE=$(find $EXAMPLE -maxdepth 1 -type f -and -path "${EXAMPLE}/*.ml") | |
FILE+=$(find $EXAMPLE -maxdepth 1 -type f -and -path "${EXAMPLE}/*.re") | |
FILE+=$(find $EXAMPLE -maxdepth 2 -type f -and -path "${EXAMPLE}/server/*.ml") | |
FILE+=$(find $EXAMPLE -maxdepth 2 -type f -and -path "${EXAMPLE}/server/*.re") | |
if [[ "$FILE" == "" ]]; then | |
continue | |
fi | |
EXE=$(echo $FILE | sed 's/\..*$/.exe/g') | |
echo dune build $EXE | |
opam exec -- dune build $EXE | |
done | |
quickstart: | |
strategy: | |
fail-fast: false | |
matrix: | |
os: | |
- ubuntu-22.04 | |
ocaml: | |
- 5.2.x | |
- 4.14.x | |
include: | |
- os: macos-latest | |
ocaml: 4.14.x | |
runs-on: ${{matrix.os}} | |
steps: | |
- uses: ocaml/setup-ocaml@v3 | |
with: | |
ocaml-compiler: ${{matrix.ocaml}} | |
dune-cache: true | |
- name: Run quickstart.sh | |
shell: bash | |
run: | | |
set -x | |
touch output | |
tail -f output | grep --line-buffered 'Ctrl' | xargs -L1 -I FOO bash -c "echo Success && touch success && killall middleware.exe" & | |
tail -f output & | |
((curl -fsSL https://raw.githubusercontent.com/aantron/dream/$GITHUB_SHA/example/quickstart.sh | bash -s $GITHUB_SHA) || true) > output 2>&1 | |
sleep 1 | |
if [ -f success ] | |
then | |
exit 0 | |
else | |
exit 1 | |
fi | |
mirage: | |
if: false | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
- run: mkdir ../repo-copy | |
- run: cp -r * ../repo-copy/ | |
- uses: ocaml/setup-ocaml@v3 | |
with: | |
ocaml-compiler: 4.14.x | |
dune-cache: true | |
# Needed until https://github.com/robur-coop/ocaml-letsencrypt/pull/34. | |
- run: opam pin add letsencrypt git+https://github.com/hannesm/ocaml-letsencrypt.git#no-cstruct --no-action | |
- 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 mirage-crypto-rng-mirage | |
- 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 digestif eqaf mirage-crypto mirage-runtime | |
- 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 |