From bda6db2bfb07cae25343b5369be6f23c80a12951 Mon Sep 17 00:00:00 2001 From: Romain Calascibetta Date: Mon, 13 Jun 2022 17:50:52 +0200 Subject: [PATCH] Add a GitHub action for Esperanto --- .github/workflows/esperanto.yml | 110 ++++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 .github/workflows/esperanto.yml diff --git a/.github/workflows/esperanto.yml b/.github/workflows/esperanto.yml new file mode 100644 index 000000000..121524a31 --- /dev/null +++ b/.github/workflows/esperanto.yml @@ -0,0 +1,110 @@ +name: Esperanto support +on: [ push ] +jobs: + test: + strategy: + matrix: + operating-system: [ ubuntu-latest ] + ocaml-version: [ "4.13.1", "4.14.0" ] + local-packages: + - | + *.opam + !lwt_domain.opam + runs-on: ${{ matrix.operating-system }} + steps: + - uses: actions/checkout@v2 + - uses: ocaml/setup-ocaml@v2 + with: + ocaml-compiler: ${{ matrix.ocaml-version }} + opam-local-packages: ${{ matrix.local-packages }} + - name: Fix binfmt and Cosmopolitan + run: sudo sh -c "echo ':APE:M::MZqFpD::/bin/sh:' >/proc/sys/fs/binfmt_misc/register" + - name: Pin Esperanto + run: opam pin add git+https://github.com/dinosaure/esperanto + - name: Install Esperanto, Dune & ocamlfind + run: opam install cosmopolitan cosmopolitan-pth esperanto dune ocamlfind + - name: Install opam-monorepo + run: opam install opam-monorepo + - name: Add opam-monorepo overlays + run: opam repo add dune-universe git+https://github.com/dune-universe/opam-overlays.git + - name: Example with LWT & Esperanto + run: | + mkdir esperanto-example + cd esperanto-example + cat >dune-workspace <dune-project <cat.ml <>= fun len' -> + if len - len' > 0 + then full_write fd buf (off + len') (len - len') + else Lwt.return_unit + + let tmp = Bytes.create 0x1000 + + let rec cat () = + Lwt.catch begin fun () -> + Lwt_unix.read Lwt_unix.stdin tmp 0 (Bytes.length tmp) >>= fun len -> + match len with + | 0 -> Lwt.return_unit + | len -> full_write Lwt_unix.stdout tmp 0 len >>= cat + end @@ function + | End_of_file -> Lwt.return_unit + | exn -> raise exn + + let () = Lwt_main.run (cat ()) + EOF + cat >dune <cat.opam <" ] + authors: [ "Romain Calascibetta " ] + homepage: "https://github.com/dinosaure/esperanto" + bug-reports: "https://github.com/dinosaure/esperanto/issues" + dev-repo: "git+https://github.com/dinosaure/esperanto" + doc: "https://dinosaure.github.io/esperanto/" + license: "MIT" + synopsis: "The cat.com tool produced by esperanto" + description: "The cat.com tool produced by esperanto" + + build: [ + [ "dune" "build" "-p" name "-j" jobs ] + ] + install: [ + [ "dune" "install" "-p" name ] {with-test} + ] + + depends: [ + "ocaml" {>= "4.12.0"} + "dune" {>= "2.8.0"} + "lwt" + ] + EOF + opam monorepo lock + opam monorepo pull + opam exec -- dune build ./cat.com + ./cat.com < cat.ml