From 74022be198be41ac9f0f0686753065ea1b7ba2fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Proust?= Date: Fri, 13 Mar 2026 20:17:09 +0100 Subject: [PATCH] compatibility with lwt 6 (#128) * compatibility with lwt 6 * try to work for lwt 5 and lwt 6 * CI: try lwt 5 then lwt 6 * only try lwt 6 on OCaml >= 5 * relax lwt bounds * more robust dune rule * CI --------- Co-authored-by: Simon Cruanes --- .github/workflows/main.yml | 9 ++++++--- src/client/lwt/dune | 16 ++++++++++++++++ src/client/lwt/notifier_lwt.ml | 2 +- src/client/lwt/types_.ml.5 | 2 ++ src/client/lwt/types_.ml.6 | 2 ++ 5 files changed, 27 insertions(+), 4 deletions(-) create mode 100644 src/client/lwt/types_.ml.5 create mode 100644 src/client/lwt/types_.ml.6 diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index bdb87e16..53aa0b0b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -42,10 +42,8 @@ jobs: allow-prerelease-opam: true - run: | - opam pin trace https://github.com/ocaml-tracing/ocaml-trace.git#main -y -n - opam pin https://github.com/ocaml-tracing/ambient-context.git#HEAD -y -n opam install pbrt.4.0 -y - opam install ambient-context + opam install ambient-context lwt.5.9.2 # We cannot install packages that need eio on ocaml versions before 5 - run: | @@ -62,6 +60,11 @@ jobs: - run: opam install trace - run: opam exec -- dune build @install -p opentelemetry + - run: opam install lwt.6.1.1 -y + if: ${{ matrix.ocaml-compiler == '5.3.x' }} + - run: opam exec -- dune build @install -p opentelemetry,opentelemetry-client,opentelemetry-lwt,opentelemetry-client-cohttp-lwt + if: ${{ matrix.ocaml-compiler == '5.3.x' }} + - run: opam install ocaml-protoc - run: opam exec -- dune build @lint diff --git a/src/client/lwt/dune b/src/client/lwt/dune index e5e2bdfb..be9e6d1c 100644 --- a/src/client/lwt/dune +++ b/src/client/lwt/dune @@ -25,3 +25,19 @@ mtime.clock.os lwt.unix) (synopsis "Lwt-specific helpers for opentelemetry-client")) + +(rule + (enabled_if + (and + %{lib-available:lwt} + (>= %{version:lwt} 6.0))) + (action + (copy types_.ml.6 types_.ml))) + +(rule + (enabled_if + (and + %{lib-available:lwt} + (< %{version:lwt} 6.0))) + (action + (copy types_.ml.5 types_.ml))) diff --git a/src/client/lwt/notifier_lwt.ml b/src/client/lwt/notifier_lwt.ml index 1e61a124..c9a241aa 100644 --- a/src/client/lwt/notifier_lwt.ml +++ b/src/client/lwt/notifier_lwt.ml @@ -5,7 +5,7 @@ module IO = Io_lwt type t = { notified: bool Atomic.t; cond: unit Lwt_condition.t; - notification: int; + notification: Types_.notification; lwt_tid: int; (** thread ID where lwt runs *) deleted: bool Atomic.t; } diff --git a/src/client/lwt/types_.ml.5 b/src/client/lwt/types_.ml.5 new file mode 100644 index 00000000..c34ffc81 --- /dev/null +++ b/src/client/lwt/types_.ml.5 @@ -0,0 +1,2 @@ + +type notification = int diff --git a/src/client/lwt/types_.ml.6 b/src/client/lwt/types_.ml.6 new file mode 100644 index 00000000..bff82f73 --- /dev/null +++ b/src/client/lwt/types_.ml.6 @@ -0,0 +1,2 @@ + +type notification = Lwt_unix.notification