Skip to content

Commit

Permalink
Add example/w-mirage and build it in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
aantron committed Mar 14, 2023
1 parent f20a335 commit a1ca19e
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 0 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,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
15 changes: 15 additions & 0 deletions example/w-mirage/config.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
open Mirage

let main =
main
~packages:[package "dream-mirage"]
"Unikernel.Hello_world"
(pclock @-> time @-> stackv4v6 @-> job)

let () =
register "hello" [
main
$ default_posix_clock
$ default_time
$ generic_stackv4v6 default_network
]
13 changes: 13 additions & 0 deletions example/w-mirage/unikernel.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module Hello_world
(Pclock : Mirage_clock.PCLOCK)
(Time : Mirage_time.S)
(Stack : Tcpip.Stack.V4V6) =
struct
module Dream =
Dream__mirage.Mirage.Make (Pclock) (Time) (Stack)

let start _pclock _time stack =
Dream.http ~port:8080 (Stack.tcp stack)
@@ Dream.logger
@@ fun _ -> Dream.html "Good morning, world!"
end

0 comments on commit a1ca19e

Please sign in to comment.